1   package org.wcb.gui.dialog;
2   
3   import org.wcb.gui.forms.auth.JLoginUpdatePanel;
4   import org.wcb.gui.util.UIHelper;
5   
6   import javax.swing.*;
7   import java.awt.event.ActionListener;
8   import java.awt.event.ActionEvent;
9   import java.awt.*;
10  
11  /**
12   * <small>
13   * <p/>
14   * Copyright (c)  2006  wbogaardt.
15   * This library is free software; you can redistribute it and/or
16   * modify it under the terms of the GNU Lesser General Public
17   * License as published by the Free Software Foundation; either
18   * version 2.1 of the License, or (at your option) any later version.
19   *
20   * This library is distributed in the hope that it will be useful,
21   * but WITHOUT ANY WARRANTY; without even the implied warranty of
22   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23   * Lesser General Public License for more details.
24   *
25   * You should have received a copy of the GNU Lesser General Public
26   * License along with this library; if not, write to the Free Software
27   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
28   * <p/>
29   * $File:  $ <br>
30   * $Change:  $ submitted by $Author: wbogaardt $ at $DateTime: Sep 27, 2006 11:43:42 AM $ <br>
31   * </small>
32   *
33   * @author wbogaardt
34   *         This dialog allows updating the user information for the application
35   */
36  public class JLoginUpdateUserDialog extends JDialog implements ActionListener {
37  
38      private JLoginUpdatePanel panel;
39      private JButton loginButton;
40      private JButton cancelButton;
41  
42      public JLoginUpdateUserDialog() {
43          super();
44          init();
45      }
46  
47      public JLoginUpdateUserDialog(Frame owner) {
48          super(owner);
49          init();
50      }
51  
52      public JLoginUpdateUserDialog(Frame owner, boolean modal) throws HeadlessException {
53          super(owner, modal);
54          init();
55      }
56  
57      public JLoginUpdateUserDialog(Frame owner, String title) throws HeadlessException {
58          super(owner, title);
59          init();
60      }
61  
62      public JLoginUpdateUserDialog(Frame owner, String title, boolean modal)
63              throws HeadlessException {
64          super(owner, title, modal);
65          init();
66      }
67  
68      protected void init() {
69          setLayout(new BorderLayout());
70          setPanel(new JLoginUpdatePanel());
71          add(createButtonPanel(), BorderLayout.SOUTH);
72          pack();
73      }
74  
75      private JPanel createButtonPanel() {
76          loginButton = new JButton("Update");
77          cancelButton = new JButton("Cancel");
78          loginButton.addActionListener(this);
79          cancelButton.addActionListener(this);
80  
81          JPanel buttonPanel = new JPanel(new GridBagLayout());
82          buttonPanel.add(loginButton, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(17, 12, 11, 5), 0, 0));
83          buttonPanel.add(cancelButton, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_END, GridBagConstraints.NONE, new Insets(17, 0, 11, 11), 0, 0));
84          return buttonPanel;
85      }
86  
87      public JLoginUpdatePanel getPanel() {
88          return panel;
89      }
90  
91      public void setPanel(JLoginUpdatePanel panel) {
92          this.panel = panel;
93          add(this.panel, BorderLayout.NORTH);
94          UIHelper.centerDialogToScreen(this);
95      }
96  
97  
98      public void actionPerformed(ActionEvent evt) {
99          Object src = evt.getSource();
100         if(src.equals(loginButton)) {
101             boolean show = getPanel().updateUser();
102             if(show) {
103                 this.dispose();
104             }
105         }
106         if(src.equals(cancelButton)) {
107             this.dispose();
108         }
109     }
110 
111 }