KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > tool > codegen > wizard > ServiceOptionPanel3


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

24 package org.enhydra.tool.codegen.wizard;
25
26 // ToolBox imports
27
import org.enhydra.tool.ToolBoxInfo;
28 import org.enhydra.tool.codegen.CodeGen;
29 import org.enhydra.tool.codegen.internal.ServiceOptionSet;
30 import org.enhydra.tool.codegen.GeneratorOption;
31 import org.enhydra.tool.codegen.GeneratorException;
32 import org.enhydra.tool.codegen.ValidationException;
33
34 // Standard imports
35
import javax.swing.*;
36 import javax.swing.border.*;
37 import javax.swing.event.*;
38 import java.awt.*;
39 import java.awt.event.ActionEvent JavaDoc;
40 import java.awt.event.ActionListener JavaDoc;
41 import java.beans.*;
42 import java.io.File JavaDoc;
43 import java.io.FileFilter JavaDoc;
44 import java.util.ResourceBundle JavaDoc;
45
46 /**
47  * Panel for entering the default options: make and script.
48  *
49  * @author Lutris Technologies
50  */

51 public class ServiceOptionPanel3 extends CodeGenPanel {
52
53     // Some controls are public to ease modification in IDE
54
// Addins.
55

56     /**
57      * Panel for checkbox controls.
58      */

59     transient public JPanel panelCheck;
60
61     /**
62      * Checkbox for script
63      */

64     transient public JCheckBox checkCLI;
65
66     //
67
transient private GridBagLayout layoutMain;
68     transient private GridBagLayout layoutDest;
69     transient private JPanel panelFiller;
70     transient private JCheckBox checkMBean;
71
72     /**
73      * Create service option panel 3 for selecting the
74      * CLI and MBean support
75      */

76     public ServiceOptionPanel3() {
77         try {
78             jbInit();
79             pmInit();
80         } catch (Exception JavaDoc ex) {
81             ex.printStackTrace();
82         }
83     }
84
85     /**
86      * Read make and script from the
87      * option set into the swing controls.
88      *
89      * @exception GeneratorException
90      * Thrown if unable to update Swing controls with option set values.
91      */

92     public void readOptionSet() throws GeneratorException {
93         GeneratorOption option = null;
94
95         // nocli
96
option = getOptionSet().lookup(ServiceOptionSet.NOCLI);
97         checkCLI.setSelected(!option.isValue());
98
99         // MBean type
100
option = getOptionSet().lookup(ServiceOptionSet.MBEAN);
101         checkMBean.setSelected(option.isValue());
102
103
104     }
105
106     /**
107      * Write make and script values from the
108      * swing controls into the option set.
109      *
110      * @exception GeneratorException
111      * Thrown if unable to update option set from Swing control values.
112      */

113     public void writeOptionSet() throws GeneratorException {
114         boolean bool = false;
115
116         // CLI
117
bool = checkCLI.isSelected();
118         getOptionSet().lookup(ServiceOptionSet.NOCLI).setValue(!bool);
119
120         // MBean
121
bool = checkMBean.isSelected();
122         getOptionSet().lookup(ServiceOptionSet.MBEAN).setValue(bool);
123
124
125     }
126
127     /**
128      * Validate the make and script values
129      * in the swing controls.
130      *
131      * @exception ValidationException
132      * Thrown if swing control values are not valid for the
133      * current option set.
134      */

135     public void validateOptionSet() throws ValidationException {}
136
137     /**
138      * Get the title to use on the current page.
139      *
140      * @return
141      * A string to place at the top of a CodeGen wizard panel.
142      */

143     public String JavaDoc getPageTitle() {
144         return res.getString("Supplemental_Files");
145     }
146
147     /**
148      * Get the instructions for entering option values for the
149      * current page.
150      *
151      * @return
152      * A string to place below the page title.
153      */

154     public String JavaDoc getInstructions() {
155         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
156
157         buf.append("The build.xml lets you compile the service source files ");
158         buf.append("and build an archive with the ");
159         buf.append("<eas_root>/bin/ant script. ");
160         buf.append("Select MBeans support to provide you service with ");
161         buf.append("qualifiers for the Lutris EAS management infrastructure.");
162         return buf.toString();
163     }
164
165     // /
166
// / PRIVATE METHODS
167
// /
168
private void jbInit() throws Exception JavaDoc {
169         panelCheck = (JPanel) Beans.instantiate(getClass().getClassLoader(),
170                                                 JPanel.class.getName());
171         layoutDest =
172             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
173                                               GridBagLayout.class.getName());
174         layoutMain =
175             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
176                                               GridBagLayout.class.getName());
177         panelFiller = (JPanel) Beans.instantiate(getClass().getClassLoader(),
178                                                  JPanel.class.getName());
179         checkCLI = (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
180                                                   JCheckBox.class.getName());
181         checkMBean =
182             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
183                                           JCheckBox.class.getName());
184
185         panelCheck.setLayout(layoutDest);
186         checkCLI.setSelected(true);
187         checkCLI.setText("Generate build.xml to compile with ant");
188         checkMBean.setSelected(true);
189         checkMBean.setText("Generate MBean support classes");
190
191         panelCheck.add(checkCLI,
192                        new GridBagConstraints(0, 0, 1, 1, 0.1, 0.1,
193                                               GridBagConstraints.WEST,
194                                               GridBagConstraints.HORIZONTAL,
195                                               new Insets(5, 10, 2, 5), 0, 0));
196         panelCheck.add(checkMBean, new GridBagConstraints(0, 1, 1, 1, 0.1, 0.1
197             ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 10, 2, 5), 0, 0));
198
199         this.setLayout(layoutMain);
200         this.add(panelCheck,
201                  new GridBagConstraints(0, 1, 2, 1, 0.1, 0.1,
202                                         GridBagConstraints.CENTER,
203                                         GridBagConstraints.BOTH,
204                                         new Insets(5, 5, 5, 5), 0, 0));
205         this.add(panelFiller,
206                  new GridBagConstraints(0, 2, 2, 1, 0.4, 0.4,
207                                         GridBagConstraints.CENTER,
208                                         GridBagConstraints.BOTH,
209                                         new Insets(0, 0, 0, 0), 0, 0));
210     }
211
212     private void pmInit() {
213         checkCLI.setSelected(true);
214         checkMBean.setSelected(true);
215     }
216
217 }
218
Popular Tags