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    import java.rmi.*;
030    import org.dbreplicator.replication.DBHandler.AbstractDataBaseHandler;
031    import java.sql.Connection;
032    import java.sql.Statement;
033    import java.sql.ResultSet;
034    
035    /**
036     * <p>Title: </p>
037     * <p>Description: </p>
038     * <p>Copyright: Copyright (c) 2003</p>
039     * <p>Company: </p>
040     * @author not attributable
041     * @version 1.0
042     */
043    
044    public class UpdatePublication extends JDialog implements FocusListener, KeyListener, ItemListener
045    {
046        JPanel panel1 = new JPanel();
047        JLabel jLabel1 = new JLabel();
048        JLabel jLabel2 = new JLabel();
049    
050        JButton jButtonNext = new JButton();
051        JButton jButtonfinish = new JButton();
052        JButton jButtonCancle = new JButton();
053        JLabel jLabel4 = new JLabel();
054    
055        JTextField jTextPubName = new JTextField();
056        _ReplicationServer repServer;
057        _Publication pub=null;
058        private AbstractDataBaseHandler dbHandler;
059        String pubName;
060        DefaultMutableTreeNode pubRootNode;
061        DefaultTreeModel defaultTreeModel;
062        Border border1;
063        JEditorPane help = new JEditorPane();
064        String operationType=null;
065        boolean able = true;
066    
067        public UpdatePublication(Frame frame, String title, boolean modal)
068        {
069            super(frame, title, modal);
070            try
071            {
072                jbInit();
073                pack();
074            }
075            catch (Exception ex)
076            {
077                JOptionPane.showMessageDialog(this, ex, "Error Message",
078                                              JOptionPane.ERROR_MESSAGE);
079                return;
080            }
081        }
082    
083        public UpdatePublication(_ReplicationServer repServer0,
084                                 DefaultMutableTreeNode pubRootNode,
085                                 DefaultTreeModel defaultTreeModel0,String operation)
086        {
087            this(StartRepServer.getMainFrame(), "Update Publication", true);
088            repServer = repServer0;
089            able=true;
090            this.pubRootNode = pubRootNode;
091            defaultTreeModel = defaultTreeModel0;
092            operationType=operation;
093        }
094    
095        public UpdatePublication(_ReplicationServer repServer0,String pubName0,
096                                DefaultMutableTreeNode pubRootNode,
097                                DefaultTreeModel defaultTreeModel0,String operation)
098       {
099           this(StartRepServer.getMainFrame(), "Update Publication", true);
100           repServer = repServer0;
101           operationType=operation;
102           pubName=pubName0;
103           able=false;
104           this.pubRootNode = pubRootNode;
105           defaultTreeModel = defaultTreeModel0;
106    // System.out.println("pubNAme="+pubName);
107            init();
108       }
109    
110       private void init()
111          {
112            try {
113              pub = repServer.getPublication(pubName);
114              jTextPubName.setText(pubName);
115              jTextPubName.setEnabled(able);
116            }
117            catch (Exception ex) {
118              JOptionPane.showMessageDialog(this, ex, "Error Message",
119                                            JOptionPane.ERROR_MESSAGE);
120              //      ex.printStackTrace();
121              return;
122            }
123     }
124    
125        private void jbInit() throws Exception
126        {
127            this.setResizable(false);
128            border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white,
129                                       new Color(148, 145, 140));
130            panel1.setLayout(null);
131            panel1.setDebugGraphicsOptions(0);
132            jLabel1.setFont(new java.awt.Font("Serif", 3, 25));
133            jLabel1.setForeground(SystemColor.infoText);
134            jLabel1.setBorder(null);
135            jLabel1.setText("      Update Publication");
136            jLabel1.setBounds(new Rectangle(55, 9, 254, 33));
137            jLabel2.setFont(new java.awt.Font("Dialog", 1, 13));
138            jLabel2.setRequestFocusEnabled(true);
139            jLabel2.setHorizontalAlignment(SwingConstants.LEFT);
140            jLabel2.setText("Publication Name");
141            jLabel2.setBounds(new Rectangle(27, 82, 121, 15));
142    
143            jTextPubName.setFont(new java.awt.Font("Dialog", 0, 12));
144            jTextPubName.setRequestFocusEnabled(true);
145            jTextPubName.setText(pubName);
146            jTextPubName.setScrollOffset(1);
147            jTextPubName.setBounds(new Rectangle(152, 79, 202, 21));
148    
149    
150            jButtonNext.setBounds(new Rectangle(108, 165, 81, 26));
151            jButtonNext.setEnabled(false);
152            jButtonNext.setFont(new java.awt.Font("Dialog", 1, 12));
153            jButtonNext.setText("Next>");
154            jButtonfinish.setBounds(new Rectangle(200, 165, 81, 26));
155            jButtonfinish.setEnabled(false);
156            jButtonfinish.setFont(new java.awt.Font("Dialog", 1, 12));
157            jButtonfinish.setText("Finish");
158            jButtonCancle.setBounds(new Rectangle(291, 165, 81, 26));
159            jButtonCancle.setFont(new java.awt.Font("Dialog", 1, 12));
160            jButtonCancle.setSelected(false);
161            jButtonCancle.setText("Cancel");
162            jButtonCancle.addActionListener(new UpdatePublication_jButtonCancle_actionAdapter(this));
163            this.setForeground(Color.darkGray);
164    
165            jTextPubName.addFocusListener(this);
166    
167            jTextPubName.addKeyListener(this);
168    
169            jTextPubName.grabFocus();
170            jLabel4.setBorder(border1);
171            jLabel4.setMaximumSize(new Dimension(0, 0));
172            jLabel4.setMinimumSize(new Dimension(2, 2));
173            jLabel4.setOpaque(false);
174            jLabel4.setRequestFocusEnabled(false);
175            jLabel4.setText("");
176            jLabel4.setBounds(new Rectangle(13, 59, 353, 58));
177            help.setBackground(UIManager.getColor("Button.background"));
178            help.setEnabled(false);
179            help.setFont(new java.awt.Font("Dialog", 2, 12));
180            help.setOpaque(true);
181            help.setRequestFocusEnabled(false);
182            help.setDisabledTextColor(Color.black);
183            help.setEditable(false);
184            help.setText(
185                "Update Publication by adding or dropping tables");
186            help.setBounds(new Rectangle(21, 121, 349, 35));
187    
188            panel1.add(jTextPubName, null);
189            panel1.add(jLabel2, null);
190            panel1.add(jLabel4, null);
191            panel1.add(jLabel1, null);
192            panel1.add(help, null);
193            panel1.add(jButtonNext, null);
194            panel1.add(jButtonfinish, null);
195            panel1.add(jButtonCancle, null);
196            this.getContentPane().add(panel1, BorderLayout.CENTER);
197            jButtonNext.addActionListener(new UpdatePublication_jButtonNext_actionAdapter(this));
198        }
199    
200        void jButton2_actionPerformed(ActionEvent e)
201        {
202            hide();
203        }
204    
205        public void setPubName(String pubName0)
206        {
207            pubName = pubName0;
208        }
209    
210        public String getPubName()
211        {
212            return pubName;
213        }
214    
215    
216    
217    
218        void jButtonNext_actionPerformed(ActionEvent e)
219        {
220          try{
221            pubName=jTextPubName.getText();
222            if (pubName == null || pubName.equalsIgnoreCase("")) {
223              throw new RepException("REP092", new Object[] {null});
224            }
225              _Publication pub = repServer.getPublication(pubName);
226    
227            if(pub==null){
228    
229              throw new RepException("REP036", new Object[] {pubName});
230            }
231    
232            SelectTable st = new SelectTable(defaultTreeModel, pubRootNode, pubName,
233                                             repServer, null, this, operationType);
234            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
235            Dimension frameSize = new Dimension(440, 325);
236            st.setBounds( (screenSize.width - frameSize.width) / 2,
237                         (screenSize.height - frameSize.height) / 2, 535, 325);
238            hide();
239            st.show();
240          }catch(Exception ex){
241            JOptionPane.showMessageDialog(this,
242                ex,"Error Message",JOptionPane.ERROR_MESSAGE);
243             return;
244          }
245        }
246    
247        void jButtonCancle_actionPerformed(ActionEvent e)
248        {
249            hide();
250        }
251    
252        public void keyTyped(KeyEvent keyEvent)
253        {
254        }
255    
256        public void keyPressed(KeyEvent keyEvent)
257        {
258        }
259    
260        public void keyReleased(KeyEvent keyEvent)
261        {
262            jButtonNext.setEnabled(true);
263    
264                if (jTextPubName.getText().equals(""))
265                {
266                    jButtonNext.setEnabled(false);
267                }
268                else
269                {
270                    if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER)
271                    {
272                        jButtonNext_actionPerformed(null);
273                    }
274                }
275        }
276    
277        public void focusGained(FocusEvent fe)
278        {
279            if (fe.getSource() instanceof JTextField)
280            {
281                help.setText("Enter Publication Name in this Box");
282    
283            }
284        }
285    
286        public void focusLost(FocusEvent focusEvent)
287        {
288            jButtonNext.setEnabled(true);
289    
290                if (jTextPubName.getText().equals(""))
291                {
292                    jButtonNext.setEnabled(false);
293                }
294        }
295    
296        public void itemStateChanged(ItemEvent itemEvent)
297        {
298    
299        }
300    }
301    
302    class UpdatePublication_jButtonNext_actionAdapter implements java.awt.event.ActionListener
303    {
304        UpdatePublication adaptee;
305    
306        UpdatePublication_jButtonNext_actionAdapter(UpdatePublication adaptee)
307        {
308            this.adaptee = adaptee;
309        }
310    
311        public void actionPerformed(ActionEvent e)
312        {
313            adaptee.jButtonNext_actionPerformed(e);
314        }
315    }
316    
317    class UpdatePublication_jButtonCancle_actionAdapter implements java.awt.event.ActionListener
318    {
319        UpdatePublication adaptee;
320    
321       UpdatePublication_jButtonCancle_actionAdapter(UpdatePublication adaptee)
322        {
323            this.adaptee = adaptee;
324        }
325    
326        public void actionPerformed(ActionEvent e)
327        {
328            adaptee.jButtonCancle_actionPerformed(e);
329        }
330    }
331    
332    
333    





























































Powered by Drupal - Theme by Danger4k