001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: * Paul Mahar
021: *
022: */
023: package org.enhydra.kelp.common.deployer;
024:
025: // ToolBox imports
026: import org.enhydra.tool.common.ButtonPanel;
027:
028: // Standard imports
029: import java.awt.*;
030: import java.awt.event.ActionEvent;
031: import java.awt.event.ActionListener;
032: import java.beans.*;
033: import javax.swing.*;
034:
035: //
036: public class DeployButtonPanel extends ButtonPanel {
037: //
038: private GridBagLayout layoutMain = null;
039: private JButton buttonBack = null;
040: private JButton buttonNext = null;
041: private JButton buttonDeploy = null;
042: private JButton buttonClose = null;
043: private JButton buttonHelp = null;
044: private JButton buttonAbout = null;
045: private LocalButtonListener buttonListener = null;
046: private JPanel panelFiller;
047:
048: public static final String[] getOptions() {
049: final String[] options = { ButtonPanel.COMMAND_BACK,
050: ButtonPanel.COMMAND_NEXT, ButtonPanel.COMMAND_DEPLOY,
051: ButtonPanel.COMMAND_CLOSE, ButtonPanel.COMMAND_HELP,
052: ButtonPanel.COMMAND_ABOUT };
053: return options;
054: }
055:
056: public DeployButtonPanel() {
057: try {
058: jbInit();
059: pmInit();
060: } catch (Exception e) {
061: e.printStackTrace();
062: }
063: }
064:
065: // override ButtonPanel
066: public void removeHelp() {
067: remove(buttonHelp);
068: invalidate();
069: doLayout();
070: }
071:
072: //
073: //
074: private void pmInit() {
075: buttonListener = new LocalButtonListener();
076: buttonBack.addActionListener(buttonListener);
077: buttonNext.addActionListener(buttonListener);
078: buttonDeploy.addActionListener(buttonListener);
079: buttonClose.addActionListener(buttonListener);
080: buttonAbout.addActionListener(buttonListener);
081: buttonHelp.addActionListener(buttonListener);
082:
083: buttonBack.setText(ButtonPanel.COMMAND_BACK);
084: buttonNext.setText(ButtonPanel.COMMAND_NEXT);
085: buttonDeploy.setText(ButtonPanel.COMMAND_DEPLOY);
086: buttonClose.setText(ButtonPanel.COMMAND_CLOSE);
087: buttonAbout.setText(ButtonPanel.COMMAND_ABOUT);
088: buttonHelp.setText(ButtonPanel.COMMAND_HELP);
089: //
090: buttonBack.setActionCommand(buttonBack.getText());
091: buttonNext.setActionCommand(buttonNext.getText());
092: buttonDeploy.setActionCommand(buttonDeploy.getText());
093: buttonClose.setActionCommand(buttonClose.getText());
094: buttonAbout.setActionCommand(buttonAbout.getText());
095: buttonHelp.setActionCommand(buttonHelp.getText());
096: //
097: buttonClose.requestFocus();
098: }
099:
100: private void jbInit() throws Exception {
101: layoutMain = (GridBagLayout) Beans.instantiate(getClass()
102: .getClassLoader(), GridBagLayout.class.getName());
103: buttonBack = (JButton) Beans.instantiate(getClass()
104: .getClassLoader(), JButton.class.getName());
105: buttonNext = (JButton) Beans.instantiate(getClass()
106: .getClassLoader(), JButton.class.getName());
107: buttonDeploy = (JButton) Beans.instantiate(getClass()
108: .getClassLoader(), JButton.class.getName());
109: buttonClose = (JButton) Beans.instantiate(getClass()
110: .getClassLoader(), JButton.class.getName());
111: buttonAbout = (JButton) Beans.instantiate(getClass()
112: .getClassLoader(), JButton.class.getName());
113: buttonHelp = (JButton) Beans.instantiate(getClass()
114: .getClassLoader(), JButton.class.getName());
115: panelFiller = (JPanel) Beans.instantiate(getClass()
116: .getClassLoader(), JPanel.class.getName());
117: buttonBack.setText("BACK");
118: buttonNext.setText("NEXT");
119: buttonDeploy.setText("DEPLOY");
120: buttonClose.setText("CLOSE");
121: buttonAbout.setText("ABOUT");
122: buttonHelp.setText("HELP");
123: this .setLayout(layoutMain);
124: this
125: .add(buttonBack, new GridBagConstraints(1, 0, 1, 1,
126: 0.1, 0.0, GridBagConstraints.CENTER,
127: GridBagConstraints.NONE,
128: new Insets(5, 20, 5, 2), 0, 0));
129: this .add(buttonNext, new GridBagConstraints(2, 0, 1, 1, 0.1,
130: 0.0, GridBagConstraints.CENTER,
131: GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0));
132: this .add(buttonDeploy, new GridBagConstraints(3, 0, 1, 1, 0.1,
133: 0.0, GridBagConstraints.CENTER,
134: GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0));
135: this .add(buttonClose, new GridBagConstraints(4, 0, 1, 1, 0.1,
136: 0.0, GridBagConstraints.CENTER,
137: GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0));
138: this
139: .add(buttonAbout, new GridBagConstraints(6, 0, 1, 1,
140: 0.1, 0.0, GridBagConstraints.CENTER,
141: GridBagConstraints.NONE,
142: new Insets(5, 2, 5, 10), 0, 0));
143: this .add(buttonHelp, new GridBagConstraints(5, 0, 1, 1, 0.1,
144: 0.0, GridBagConstraints.CENTER,
145: GridBagConstraints.NONE, new Insets(5, 2, 5, 2), 0, 0));
146: this .add(panelFiller, new GridBagConstraints(0, 0, 1, 1, 1.0,
147: 0.0, GridBagConstraints.CENTER,
148: GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0),
149: 50, 0));
150: }
151:
152: private class LocalButtonListener implements ActionListener {
153:
154: /**
155: * ActionListener implementation.
156: *
157: * @param event
158: * Event that triggered this listener.
159: *
160: */
161: public void actionPerformed(ActionEvent e) {
162: Object source = null;
163: ActionEvent event = null;
164:
165: source = e.getSource();
166: if (source == buttonBack) {
167: event = new ActionEvent(buttonBack, ButtonPanel.BACK,
168: buttonBack.getActionCommand());
169: } else if (source == buttonNext) {
170: event = new ActionEvent(buttonNext, ButtonPanel.NEXT,
171: buttonNext.getActionCommand());
172: } else if (source == buttonDeploy) {
173: event = new ActionEvent(buttonDeploy,
174: ButtonPanel.DEPLOY, buttonDeploy
175: .getActionCommand());
176: } else if (source == buttonClose) {
177: event = new ActionEvent(buttonClose, ButtonPanel.CLOSE,
178: buttonClose.getActionCommand());
179: } else if (source == buttonHelp) {
180: event = new ActionEvent(buttonHelp, ButtonPanel.HELP,
181: buttonHelp.getActionCommand());
182: } else if (source == buttonAbout) {
183: event = new ActionEvent(buttonAbout, ButtonPanel.ABOUT,
184: buttonAbout.getActionCommand());
185: }
186: if (event != null) {
187: notifyActionListeners(event);
188: }
189: }
190:
191: }
192: }
|