JavaDoc


001    /**
002     * Copyright (c) 2003 Daffodil Software Ltd all rights reserved,
003     * Modifications Copyright (c) 2008 Regiscope Digital Imaging Co, LLC, All rights reserved.
004     * This program is free software; you can redistribute it and/or modify
005     * it under the terms of version 2 of the GNU General Public License as
006     * published by the Free Software Foundation.
007     * There are special exceptions to the terms and conditions of the GPL
008     * as it is applied to this software. See the GNU General Public License for more details.
009     *
010     * This program is distributed in the hope that it will be useful,
011     * but WITHOUT ANY WARRANTY; without even the implied warranty of
012     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013     * GNU General Public License for more details.
014     *
015     * You should have received a copy of the GNU General Public License
016     * along with this program; if not, write to the Free Software
017     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
018     */
019    
020    package org.dbreplicator.repconsole;
021    
022    import java.awt.*;
023    import java.awt.event.*;
024    import javax.swing.*;
025    import javax.swing.border.*;
026    import javax.swing.tree.*;
027    
028    import org.dbreplicator.replication.*;
029    
030    /**
031     * <p>Title: </p>
032     * <p>Description: </p>
033     * <p>Copyright: Copyright (c) 2003</p>
034     * <p>Company: </p>
035     * @author not attributable
036     * @version 1.0
037     */
038    
039    public class CreatePublication extends JDialog implements FocusListener, KeyListener, ItemListener
040    {
041        JPanel panel1 = new JPanel();
042        JLabel jLabel1 = new JLabel();
043        JLabel jLabel2 = new JLabel();
044        JLabel jLabel3 = new JLabel();
045        JTextField jTextPubName = new JTextField();
046        JComboBox jComboBoxConflictResolver = new JComboBox();
047        _ReplicationServer repServer;
048        String pubName;
049        DefaultMutableTreeNode pubRootNode;
050        DefaultTreeModel defaultTreeModel;
051        JButton jButtonNext = new JButton();
052        JButton jButtonfinish = new JButton();
053        JButton jButtonCancle = new JButton();
054        JLabel jLabel4 = new JLabel();
055        Border border1;
056        JEditorPane help = new JEditorPane();
057    
058        public CreatePublication(Frame frame, String title, boolean modal)
059        {
060            super(frame, title, modal);
061            try
062            {
063                jbInit();
064                pack();
065            }
066            catch (Exception ex)
067            {
068                JOptionPane.showMessageDialog(this, ex, "Error Message",
069                                              JOptionPane.ERROR_MESSAGE);
070                return;
071            }
072        }
073    
074        public CreatePublication(_ReplicationServer repServer0,
075                                 DefaultMutableTreeNode pubRootNode,
076                                 DefaultTreeModel defaultTreeModel0)
077    {
078            this(StartRepServer.getMainFrame(), "Create Publication", true);
079            repServer = repServer0;
080            this.pubRootNode = pubRootNode;
081            defaultTreeModel = defaultTreeModel0;
082        }
083    
084        private void jbInit() throws Exception
085        {
086    
087            this.setResizable(false);
088            border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white,
089                                       new Color(148, 145, 140));
090            panel1.setLayout(null);
091            panel1.setDebugGraphicsOptions(0);
092            jLabel1.setFont(new java.awt.Font("Serif", 3, 25));
093            jLabel1.setForeground(SystemColor.infoText);
094            jLabel1.setBorder(null);
095            jLabel1.setText("      Create Publication");
096            jLabel1.setBounds(new Rectangle(55, 9, 254, 33));
097            jLabel2.setFont(new java.awt.Font("Dialog", 1, 13));
098            jLabel2.setRequestFocusEnabled(true);
099            jLabel2.setHorizontalAlignment(SwingConstants.LEFT);
100            jLabel2.setText("Publication Name");
101            jLabel2.setBounds(new Rectangle(27, 82, 121, 15));
102            jLabel3.setFont(new java.awt.Font("Dialog", 1, 13));
103            jLabel3.setOpaque(false);
104            jLabel3.setRequestFocusEnabled(true);
105            jLabel3.setHorizontalAlignment(SwingConstants.LEFT);
106            jLabel3.setText("Conflict Resolver");
107            jLabel3.setBounds(new Rectangle(26, 108, 119, 15));
108            jTextPubName.setFont(new java.awt.Font("Dialog", 0, 12));
109            jTextPubName.setRequestFocusEnabled(true);
110            jTextPubName.setToolTipText("");
111            jTextPubName.setText("");
112            jTextPubName.setScrollOffset(1);
113            jTextPubName.setBounds(new Rectangle(152, 79, 202, 21));
114            jComboBoxConflictResolver.setFont(new java.awt.Font("Dialog", 0, 12));
115            jComboBoxConflictResolver.setDebugGraphicsOptions(0);
116            jComboBoxConflictResolver.setRequestFocusEnabled(true);
117            jComboBoxConflictResolver.setToolTipText("");
118            jComboBoxConflictResolver.setBounds(new Rectangle(152, 104, 202, 21));
119            jComboBoxConflictResolver.addItem(_Publication.publisher_wins);
120            jComboBoxConflictResolver.addItem(_Publication.subscriber_wins);
121            jButtonNext.setBounds(new Rectangle(106, 187, 81, 26));
122            jButtonNext.setEnabled(false);
123            jButtonNext.setFont(new java.awt.Font("Dialog", 1, 12));
124            jButtonNext.setText("Next>");
125            jButtonfinish.setBounds(new Rectangle(196, 187, 81, 26));
126            jButtonfinish.setEnabled(false);
127            jButtonfinish.setFont(new java.awt.Font("Dialog", 1, 12));
128            jButtonfinish.setText("Finish");
129            jButtonCancle.setBounds(new Rectangle(285, 187, 81, 26));
130            jButtonCancle.setFont(new java.awt.Font("Dialog", 1, 12));
131            jButtonCancle.setSelected(false);
132            jButtonCancle.setText("Cancel");
133            jButtonCancle.addActionListener(new
134                                            CreatePublication_jButtonCancle_actionAdapter(this));
135            this.setForeground(Color.darkGray);
136    
137            jTextPubName.addFocusListener(this);
138            jComboBoxConflictResolver.addItemListener(this);
139            jComboBoxConflictResolver.addFocusListener(this);
140    
141            jTextPubName.addKeyListener(this);
142    
143            jTextPubName.grabFocus();
144            jLabel4.setBorder(border1);
145            jLabel4.setMaximumSize(new Dimension(0, 0));
146            jLabel4.setMinimumSize(new Dimension(2, 2));
147            jLabel4.setOpaque(false);
148            jLabel4.setRequestFocusEnabled(false);
149            jLabel4.setText("");
150            jLabel4.setBounds(new Rectangle(13, 59, 353, 79));
151            help.setBackground(UIManager.getColor("Button.background"));
152            help.setEnabled(false);
153            help.setFont(new java.awt.Font("Dialog", 2, 12));
154            help.setOpaque(true);
155            help.setRequestFocusEnabled(false);
156            help.setDisabledTextColor(Color.black);
157            help.setEditable(false);
158            help.setText(
159                "Creates Publication with default conflict resolver set to        " +
160                "          publisher_wins");
161            help.setBounds(new Rectangle(21, 141, 349, 35));
162            panel1.add(jButtonfinish, null);
163            panel1.add(jComboBoxConflictResolver, null);
164            panel1.add(jTextPubName, null);
165            panel1.add(jLabel2, null);
166            panel1.add(jLabel3, null);
167            panel1.add(jLabel4, null);
168            panel1.add(help, null);
169            panel1.add(jButtonNext, null);
170            panel1.add(jButtonCancle, null);
171            panel1.add(jLabel1, null);
172            this.getContentPane().add(panel1, BorderLayout.CENTER);
173            jButtonNext.addActionListener(new
174                                          CreatePublication_jButtonNext_actionAdapter(this));
175        }
176    
177        void jButton2_actionPerformed(ActionEvent e)
178        {
179            hide();
180        }
181    
182        public void setPubName(String pubName0)
183        {
184            pubName = pubName0;
185        }
186    
187        public String getPubName()
188        {
189            return pubName;
190        }
191    
192        void jButtonNext_actionPerformed(ActionEvent e)
193        {
194    
195            String pubName = jTextPubName.getText().trim();
196            try {
197                if (pubName == null || pubName.equalsIgnoreCase("") ||
198                    pubName.startsWith("\"") || pubName.startsWith("\\") ||
199                    pubName.startsWith("/") || pubName.startsWith(":") ||
200                    pubName.startsWith("<") || pubName.startsWith(">") ||
201                  pubName.startsWith("|") || pubName.startsWith("?")) {
202                throw new RepException("REP092", new Object[] {null});
203                }
204            }
205            catch (Exception ex) {
206              JOptionPane.showMessageDialog(this,
207                                            "Publication Name is not  Specified",
208                                              "Error Message",
209                                              JOptionPane.INFORMATION_MESSAGE);
210                return;
211            }
212    
213            String conflictResolver = (String) jComboBoxConflictResolver.
214                getSelectedItem();
215            SelectTable st = new SelectTable(defaultTreeModel, pubRootNode, pubName,
216                                             repServer, conflictResolver, this,
217                                             RepConstants.create_Publication);
218            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
219            Dimension frameSize = new Dimension(440, 325);
220            st.setBounds( (screenSize.width - frameSize.width) / 2,
221                         (screenSize.height - frameSize.height) / 2, 535, 325);
222            hide();
223            st.show();
224        }
225    
226        void jButtonCancle_actionPerformed(ActionEvent e)
227        {
228            hide();
229        }
230    
231        public void keyTyped(KeyEvent keyEvent)
232        {
233        }
234    
235        public void keyPressed(KeyEvent keyEvent)
236        {
237        }
238    
239        public void keyReleased(KeyEvent keyEvent)
240        {
241            jButtonNext.setEnabled(true);
242            if (jComboBoxConflictResolver.getItemCount() > 0)
243            {
244                if (jComboBoxConflictResolver.getSelectedItem().equals("") ||
245                    jTextPubName.getText().equals(""))
246                {
247                    jButtonNext.setEnabled(false);
248                }
249                else
250                {
251                    if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER)
252                    {
253                        jButtonNext_actionPerformed(null);
254                    }
255                }
256            }
257        }
258    
259        public void focusGained(FocusEvent fe)
260        {
261            if (fe.getSource() instanceof JTextField)
262            {
263                help.setText("Enter Publication Name in this Box");
264    
265            }
266            if (fe.getSource() instanceof JComboBox)
267            {
268                help.setText("Select Conflict Resolver from this Combo Box");
269            }
270        }
271    
272        public void focusLost(FocusEvent focusEvent)
273        {
274            jButtonNext.setEnabled(true);
275            if (jComboBoxConflictResolver.getItemCount() > 0)
276            {
277                if (jComboBoxConflictResolver.getSelectedItem().equals("") ||
278                    jTextPubName.getText().equals(""))
279                {
280                    jButtonNext.setEnabled(false);
281                }
282            }
283    
284        }
285    
286        public void itemStateChanged(ItemEvent itemEvent)
287        {
288            if ( ( (JComboBox) itemEvent.getSource()).equals(jComboBoxConflictResolver))
289            {
290                help.setText("Select Conflict Resolver from this Combo Box");
291            }
292    
293        }
294    }
295    
296    class CreatePublication_jButtonNext_actionAdapter implements java.awt.event.ActionListener
297    {
298        CreatePublication adaptee;
299    
300        CreatePublication_jButtonNext_actionAdapter(CreatePublication adaptee)
301        {
302            this.adaptee = adaptee;
303        }
304    
305        public void actionPerformed(ActionEvent e)
306        {
307            adaptee.jButtonNext_actionPerformed(e);
308        }
309    }
310    
311    class CreatePublication_jButtonCancle_actionAdapter implements java.awt.event.ActionListener
312    {
313        CreatePublication adaptee;
314    
315        CreatePublication_jButtonCancle_actionAdapter(CreatePublication adaptee)
316        {
317            this.adaptee = adaptee;
318        }
319    
320        public void actionPerformed(ActionEvent e)
321        {
322            adaptee.jButtonCancle_actionPerformed(e);
323        }
324    }





























































Powered by Drupal - Theme by Danger4k