KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > deployer > DeployButtonPanel


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Paul Mahar
21  *
22  */

23 package org.enhydra.kelp.common.deployer;
24
25 // ToolBox imports
26
import org.enhydra.tool.common.ButtonPanel;
27
28 // Standard imports
29
import java.awt.*;
30 import java.awt.event.ActionEvent JavaDoc;
31 import java.awt.event.ActionListener JavaDoc;
32 import java.beans.*;
33 import javax.swing.*;
34
35 //
36
public class DeployButtonPanel extends ButtonPanel {
37     //
38
private GridBagLayout layoutMain = null;
39     private JButton buttonBack = null;
40     private JButton buttonNext = null;
41     private JButton buttonDeploy = null;
42     private JButton buttonClose = null;
43     private JButton buttonHelp = null;
44     private JButton buttonAbout = null;
45     private LocalButtonListener buttonListener = null;
46     private JPanel panelFiller;
47
48     public static final String JavaDoc[] getOptions() {
49       final String JavaDoc[] options = {ButtonPanel.COMMAND_BACK,
50          ButtonPanel.COMMAND_NEXT, ButtonPanel.COMMAND_DEPLOY,
51          ButtonPanel.COMMAND_CLOSE, ButtonPanel.COMMAND_HELP,
52          ButtonPanel.COMMAND_ABOUT};
53       return options;
54     }
55
56     public DeployButtonPanel() {
57         try {
58             jbInit();
59             pmInit();
60         } catch (Exception JavaDoc e) {
61             e.printStackTrace();
62         }
63     }
64
65     // override ButtonPanel
66
public void removeHelp() {
67         remove(buttonHelp);
68         invalidate();
69         doLayout();
70     }
71
72     //
73
//
74
private void pmInit() {
75         buttonListener = new LocalButtonListener();
76         buttonBack.addActionListener(buttonListener);
77         buttonNext.addActionListener(buttonListener);
78         buttonDeploy.addActionListener(buttonListener);
79         buttonClose.addActionListener(buttonListener);
80         buttonAbout.addActionListener(buttonListener);
81         buttonHelp.addActionListener(buttonListener);
82
83         buttonBack.setText(ButtonPanel.COMMAND_BACK);
84         buttonNext.setText(ButtonPanel.COMMAND_NEXT);
85         buttonDeploy.setText(ButtonPanel.COMMAND_DEPLOY);
86         buttonClose.setText(ButtonPanel.COMMAND_CLOSE);
87         buttonAbout.setText(ButtonPanel.COMMAND_ABOUT);
88         buttonHelp.setText(ButtonPanel.COMMAND_HELP);
89         //
90
buttonBack.setActionCommand(buttonBack.getText());
91         buttonNext.setActionCommand(buttonNext.getText());
92         buttonDeploy.setActionCommand(buttonDeploy.getText());
93         buttonClose.setActionCommand(buttonClose.getText());
94         buttonAbout.setActionCommand(buttonAbout.getText());
95         buttonHelp.setActionCommand(buttonHelp.getText());
96         //
97
buttonClose.requestFocus();
98     }
99
100     private void jbInit() throws Exception JavaDoc {
101         layoutMain =
102             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
103                                               GridBagLayout.class.getName());
104         buttonBack = (JButton) Beans.instantiate(getClass().getClassLoader(),
105                                                  JButton.class.getName());
106         buttonNext = (JButton) Beans.instantiate(getClass().getClassLoader(),
107                                                  JButton.class.getName());
108         buttonDeploy =
109             (JButton) Beans.instantiate(getClass().getClassLoader(),
110                                         JButton.class.getName());
111         buttonClose =
112             (JButton) Beans.instantiate(getClass().getClassLoader(),
113                                         JButton.class.getName());
114         buttonAbout = (JButton) Beans.instantiate(getClass().getClassLoader(),
115                                                   JButton.class.getName());
116         buttonHelp = (JButton) Beans.instantiate(getClass().getClassLoader(),
117                                                  JButton.class.getName());
118         panelFiller = (JPanel) Beans.instantiate(getClass().getClassLoader(),
119                                                  JPanel.class.getName());
120         buttonBack.setText("BACK");
121         buttonNext.setText("NEXT");
122         buttonDeploy.setText("DEPLOY");
123         buttonClose.setText("CLOSE");
124         buttonAbout.setText("ABOUT");
125         buttonHelp.setText("HELP");
126         this.setLayout(layoutMain);
127         this.add(buttonBack, new GridBagConstraints(1, 0, 1, 1, 0.1, 0.0
128             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 20, 5, 2), 0, 0));
129         this.add(buttonNext, new GridBagConstraints(2, 0, 1, 1, 0.1, 0.0
130             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0));
131         this.add(buttonDeploy, new GridBagConstraints(3, 0, 1, 1, 0.1, 0.0
132             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0));
133         this.add(buttonClose, new GridBagConstraints(4, 0, 1, 1, 0.1, 0.0
134             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0));
135         this.add(buttonAbout, new GridBagConstraints(6, 0, 1, 1, 0.1, 0.0
136             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 10), 0, 0));
137         this.add(buttonHelp, new GridBagConstraints(5, 0, 1, 1, 0.1, 0.0
138             ,GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0));
139         this.add(panelFiller, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0
140             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 50, 0));
141     }
142
143     private class LocalButtonListener implements ActionListener JavaDoc {
144
145         /**
146          * ActionListener implementation.
147          *
148          * @param event
149          * Event that triggered this listener.
150          *
151          */

152         public void actionPerformed(ActionEvent JavaDoc e) {
153             Object JavaDoc source = null;
154             ActionEvent JavaDoc event = null;
155
156             source = e.getSource();
157             if (source == buttonBack) {
158                 event = new ActionEvent JavaDoc(buttonBack, ButtonPanel.BACK,
159                                         buttonBack.getActionCommand());
160             } else if (source == buttonNext) {
161                 event = new ActionEvent JavaDoc(buttonNext, ButtonPanel.NEXT,
162                                         buttonNext.getActionCommand());
163             } else if (source == buttonDeploy) {
164                 event = new ActionEvent JavaDoc(buttonDeploy,
165                                         ButtonPanel.DEPLOY,
166                                         buttonDeploy.getActionCommand());
167             } else if (source == buttonClose) {
168                 event = new ActionEvent JavaDoc(buttonClose,
169                                         ButtonPanel.CLOSE,
170                                         buttonClose.getActionCommand());
171             } else if (source == buttonHelp) {
172                 event = new ActionEvent JavaDoc(buttonHelp, ButtonPanel.HELP,
173                                         buttonHelp.getActionCommand());
174             } else if (source == buttonAbout) {
175                 event = new ActionEvent JavaDoc(buttonAbout, ButtonPanel.ABOUT,
176                                         buttonAbout.getActionCommand());
177             }
178             if (event != null) {
179                 notifyActionListeners(event);
180             }
181         }
182
183     }
184 }
185
Popular Tags