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    
027    import org.dbreplicator.replication.*;
028    
029    /**
030     * <p>Title: </p>
031     * <p>Description: </p>
032     * <p>Copyright: Copyright (c) 2003</p>
033     * <p>Company: </p>
034     * @author not attributable
035     * @version 1.0
036     */
037    
038    public class Push extends JDialog implements FocusListener, KeyListener
039    {
040        JPanel panel1 = new JPanel();
041        JLabel jLabel1 = new JLabel();
042        JTextField jTextSubName = new JTextField();
043        JButton jButtonPush = new JButton();
044        JButton jButtonCancle = new JButton();
045        _ReplicationServer repServer;
046        JLabel jLabel2 = new JLabel();
047        JLabel jLabel4 = new JLabel();
048        JTextField jTextRemoteServerName = new JTextField();
049        JTextField jTextRemoteRepPortNo = new JTextField();
050        JLabel jLabel3 = new JLabel();
051        JLabel jLabel6 = new JLabel();
052        JEditorPane help = new JEditorPane();
053        String subName;
054        boolean able = true;
055        _Subscription sub = null;
056        Border border1;
057    
058        public Push(Frame frame, String title, boolean modal, boolean able0)
059        {
060            super(frame, title, modal);
061            able = able0;
062            try
063            {
064                jbInit();
065                pack();
066            }
067            catch (Exception ex)
068            {
069                JOptionPane.showMessageDialog(this, ex, "Error Message",
070                                              JOptionPane.ERROR_MESSAGE);
071                return;
072            }
073        }
074    
075        public Push(_ReplicationServer repServer0, boolean able0)
076        {
077            this(StartRepServer.getMainFrame(), "Push", true, able0);
078            repServer = repServer0;
079            able = able0;
080        }
081    
082        public Push(_ReplicationServer repServer0, String subName0,
083                           boolean able0)
084        {
085            this(null, "Push", true, able0);
086            repServer = repServer0;
087            subName = subName0;
088            able = able0;
089            init();
090        }
091    
092        private void init()
093        {
094            try
095            {
096                sub = repServer.getSubscription(subName);
097                jTextSubName.setText(subName);
098                jTextSubName.setEnabled(able);
099                jTextRemoteRepPortNo.setText("" + sub.getRemoteServerPortNo());
100                jTextRemoteServerName.setText(sub.getRemoteServerUrl());
101                if (!jTextRemoteRepPortNo.getText().trim().equalsIgnoreCase("") &&
102                    !jTextRemoteServerName.getText().trim().equalsIgnoreCase(""))
103                {
104                    jButtonPush.setEnabled(true);
105                }
106            }
107            catch (RepException ex)
108            {
109                JOptionPane.showMessageDialog(this, ex, "Error Message",
110                                              JOptionPane.ERROR_MESSAGE);
111    //      ex.printStackTrace();
112                return;
113            }
114        }
115    
116        private void jbInit() throws Exception
117        {
118            border1 = new EtchedBorder(EtchedBorder.RAISED, Color.white,
119                                       new Color(148, 145, 140));
120            panel1.setLayout(null);
121            jLabel1.setFont(new java.awt.Font("Dialog", 1, 13));
122            jLabel1.setToolTipText("");
123            jLabel1.setHorizontalAlignment(SwingConstants.LEFT);
124            jLabel1.setText("Subscription Name");
125            jLabel1.setBounds(new Rectangle(20, 65, 141, 23));
126            panel1.setAlignmentY( (float) 0.5);
127            panel1.setDebugGraphicsOptions(0);
128            jTextSubName.setFont(new java.awt.Font("Dialog", 0, 12));
129            jTextSubName.setText("");
130            jTextSubName.setBounds(new Rectangle(186, 63, 147, 23));
131            jButtonPush.setBounds(new Rectangle(111, 211, 116, 25));
132            jButtonPush.setEnabled(false);
133            jButtonPush.setFont(new java.awt.Font("Dialog", 1, 12));
134            jButtonPush.setText("Push");
135            jButtonPush.addActionListener(new Push_jButtonPush_actionAdapter(this));
136            jButtonCancle.setBounds(new Rectangle(236, 211, 116, 25));
137            jButtonCancle.setFont(new java.awt.Font("Dialog", 1, 12));
138            jButtonCancle.setText("Cancel");
139            jButtonCancle.addActionListener(new Push_jButtonCancle_actionAdapter(this));
140            jLabel2.setFont(new java.awt.Font("Serif", 3, 25));
141            jLabel2.setForeground(SystemColor.infoText);
142            jLabel2.setVerifyInputWhenFocusTarget(true);
143            jLabel2.setText("Push");
144            jLabel2.setBounds(new Rectangle(155, 12, 167, 27));
145            jLabel4.setFont(new java.awt.Font("Dialog", 1, 13));
146            jLabel4.setRequestFocusEnabled(true);
147            jLabel4.setHorizontalAlignment(SwingConstants.LEFT);
148            jLabel4.setText("Publication Server Name");
149            jLabel4.setBounds(new Rectangle(20, 91, 165, 23));
150            jTextRemoteServerName.setFont(new java.awt.Font("Dialog", 0, 12));
151            jTextRemoteServerName.setText("");
152            jTextRemoteServerName.setBounds(new Rectangle(186, 90, 147, 23));
153            jTextRemoteRepPortNo.setFont(new java.awt.Font("Dialog", 0, 12));
154            jTextRemoteRepPortNo.setText("");
155            jTextRemoteRepPortNo.setBounds(new Rectangle(186, 117, 147, 23));
156            jLabel3.setFont(new java.awt.Font("Dialog", 1, 13));
157            jLabel3.setRequestFocusEnabled(true);
158            jLabel3.setHorizontalAlignment(SwingConstants.LEFT);
159            jLabel3.setText("Publication Port Number");
160            jLabel3.setBounds(new Rectangle(20, 119, 161, 23));
161            jLabel6.setBorder(border1);
162            jLabel6.setPreferredSize(new Dimension(2, 2));
163            jLabel6.setToolTipText("");
164            jLabel6.setText("");
165            jLabel6.setVerticalAlignment(SwingConstants.CENTER);
166            jLabel6.setBounds(new Rectangle(12, 51, 340, 104));
167    
168            jTextRemoteRepPortNo.setDocument(new NumericDocument());
169    
170            jTextRemoteRepPortNo.addKeyListener(this);
171            jTextRemoteServerName.addKeyListener(this);
172            jTextSubName.addKeyListener(this);
173            jTextRemoteRepPortNo.addFocusListener(this);
174            jTextRemoteServerName.addFocusListener(this);
175            jTextSubName.addFocusListener(this);
176    
177            jTextSubName.grabFocus();
178            help.setBackground(UIManager.getColor("Button.background"));
179            help.setEnabled(false);
180            help.setFont(new java.awt.Font("Dialog", 2, 12));
181            help.setAlignmentY( (float) 0.5);
182            help.setMinimumSize(new Dimension(352, 21));
183            help.setDisabledTextColor(Color.black);
184            help.setText(
185                " The changes made to the data by Publisher" +
186                "will be uploaded to Subscriber");
187            help.setBounds(new Rectangle(12, 159, 339, 35));
188            panel1.add(help, null);
189            panel1.add(jTextRemoteServerName, null);
190            panel1.add(jTextRemoteRepPortNo, null);
191            panel1.add(jTextSubName, null);
192            panel1.add(jLabel4, null);
193            panel1.add(jLabel1, null);
194            panel1.add(jLabel3, null);
195            panel1.add(jLabel6, null);
196            panel1.add(jButtonCancle, null);
197            panel1.add(jButtonPush, null);
198            panel1.add(jLabel2, null);
199            this.getContentPane().add(panel1, BorderLayout.CENTER);
200        }
201    
202        void jButtonCancle_actionPerformed(ActionEvent e)
203        {
204            hide();
205        }
206    
207        void jButtonPush_actionPerformed(ActionEvent e)
208        {
209            try
210            {
211                String subName = jTextSubName.getText().trim();
212                if (subName.equalsIgnoreCase(""))
213                {
214                    throw new RepException("REP093", new Object[]
215                                           {null});
216                }
217                String port = jTextRemoteRepPortNo.getText().trim();
218                if (port.equalsIgnoreCase(""))
219                {
220                    throw new RepException("REP094", new Object[]
221                                           {null});
222                }
223                int remoteRepPortNo = Integer.valueOf(port).intValue();
224                if (remoteRepPortNo <= 0)
225                {
226                    throw new NumberFormatException();
227                }
228    
229                String remoteServerName = jTextRemoteServerName.getText().trim();
230                if (remoteServerName.equalsIgnoreCase(""))
231                {
232                    throw new RepException("REP095", new Object[]
233                                           {null});
234                }
235    
236                sub = repServer.getSubscription(subName);
237                if (sub == null)
238                {
239                    throw new RepException("REP0107", new Object[]
240                                           {subName});
241                }
242                sub.setRemoteServerPortNo(remoteRepPortNo);
243                sub.setRemoteServerUrl(remoteServerName);
244                sub.push();
245                JOptionPane.showMessageDialog(this, "Pushed Successfully",
246                                              "Success", JOptionPane.INFORMATION_MESSAGE);
247                hide();
248            }
249            catch (RepException ex)
250            {
251                JOptionPane.showMessageDialog(this, ex, "Error Message",
252                                              JOptionPane.ERROR_MESSAGE);
253                return;
254            }
255            catch (NumberFormatException ex2)
256            {
257                JOptionPane.showMessageDialog(this,
258                                              "Enter only Positive Integer in Server Port No",
259                                              "Error Message",
260                                              JOptionPane.ERROR_MESSAGE);
261                return;
262            }
263            catch (Exception ex1)
264            {
265                JOptionPane.showMessageDialog(this, ex1, "Error Message",
266                                              JOptionPane.ERROR_MESSAGE);
267                return;
268            }
269        }
270    
271        public void focusGained(FocusEvent fe)
272        {
273            if ( ( (JTextField) fe.getSource()).equals(jTextRemoteRepPortNo))
274            {
275                help.setText("Enter Port number in this box");
276            }
277            else if ( ( (JTextField) fe.getSource()).equals(jTextSubName))
278            {
279                help.setText("Enter Subscription Name in this box");
280            }
281            else if ( ( (JTextField) fe.getSource()).equals(jTextRemoteServerName))
282            {
283                help.setText("Enter Server Name in this box");
284    
285            }
286            if (! (jTextRemoteRepPortNo.getText().equals("") ||
287                   jTextRemoteServerName.getText().equals("") ||
288                   jTextSubName.getText().equals("")))
289            {
290                jButtonPush.setEnabled(true);
291            }
292        }
293    
294        public void focusLost(FocusEvent fe)
295        {
296            jButtonPush.setEnabled(true);
297            if (jTextRemoteRepPortNo.getText().equals("") ||
298                jTextRemoteServerName.getText().equals("") ||
299                jTextSubName.getText().equals(""))
300            {
301                jButtonPush.setEnabled(false);
302    
303            }
304        }
305    
306        public void keyTyped(KeyEvent keyEvent)
307        {
308        }
309    
310        public void keyPressed(KeyEvent keyEvent)
311        {
312        }
313    
314        public void keyReleased(KeyEvent keyEvent)
315        {
316            jButtonPush.setEnabled(true);
317            if (jTextRemoteRepPortNo.getText().equals("") ||
318                jTextRemoteServerName.getText().equals("") ||
319                jTextSubName.getText().equals(""))
320            {
321                jButtonPush.setEnabled(false);
322            }
323            else
324            {
325                if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER)
326                {
327                    jButtonPush_actionPerformed(null);
328                }
329            }
330    
331        }
332    }
333    
334    class Push_jButtonCancle_actionAdapter implements java.awt.event.ActionListener
335    {
336        Push adaptee;
337    
338        Push_jButtonCancle_actionAdapter(Push adaptee)
339        {
340            this.adaptee = adaptee;
341        }
342    
343        public void actionPerformed(ActionEvent e)
344        {
345            adaptee.jButtonCancle_actionPerformed(e);
346        }
347    }
348    
349    class Push_jButtonPush_actionAdapter implements java.awt.event.ActionListener
350    {
351        Push adaptee;
352    
353        Push_jButtonPush_actionAdapter(Push adaptee)
354        {
355            this.adaptee = adaptee;
356        }
357    
358        public void actionPerformed(ActionEvent e)
359        {
360            adaptee.jButtonPush_actionPerformed(e);
361        }
362    }





























































Powered by Drupal - Theme by Danger4k