KickJava   Java API By Example, From Geeks To Geeks.

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


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.ProjectOptionSet;
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 ProjectOptionPanel3 extends CodeGenPanel {
52
53     // All swing controls are public to allow for easy modification in IDE
54
// implementations.
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
71     /**
72      * Create default option panel 3 for entering the
73      * following default options: make and script.
74      */

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

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

107     public void writeOptionSet() throws GeneratorException {
108         boolean bVal = false;
109         String JavaDoc sVal = new String JavaDoc();
110
111         // CLI
112
bVal = checkCLI.isSelected();
113         getOptionSet().lookup(ProjectOptionSet.NOCLI).setValue(!bVal);
114     }
115
116     /**
117      * Validate the make and script values
118      * in the swing controls.
119      *
120      * @exception ValidationException
121      * Thrown if swing control values are not valid for the
122      * current option set.
123      */

124     public void validateOptionSet() throws ValidationException {}
125
126     /**
127      * Get the title to use on the current page.
128      *
129      * @return
130      * A string to place at the top of a CodeGen wizard panel.
131      */

132     public String JavaDoc getPageTitle() {
133         return res.getString("Supplemental_Files");
134     }
135
136     /**
137      * Get the instructions for entering option values for the
138      * current page.
139      *
140      * @return
141      * A string to place below the page title.
142      */

143     public String JavaDoc getInstructions() {
144         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
145
146         buf.append(res.getString("InstructSub1"));
147         buf.append(res.getString("InstructSub2"));
148         buf.append(res.getString("InstructSub3"));
149         return buf.toString();
150     }
151
152     // /
153
// / PRIVATE METHODS
154
// /
155
private void jbInit() throws Exception JavaDoc {
156         panelCheck = (JPanel) Beans.instantiate(getClass().getClassLoader(),
157                                                 JPanel.class.getName());
158         layoutDest =
159             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
160                                               GridBagLayout.class.getName());
161         layoutMain =
162             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
163                                               GridBagLayout.class.getName());
164         panelFiller = (JPanel) Beans.instantiate(getClass().getClassLoader(),
165                                                  JPanel.class.getName());
166         checkCLI = (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
167                                                   JCheckBox.class.getName());
168         panelCheck.setLayout(layoutDest);
169         checkCLI.setSelected(true);
170         checkCLI.setText(res.getString("Create_CLI"));
171         panelCheck.add(checkCLI,
172                        new GridBagConstraints(0, 0, 1, 1, 0.1, 0.1,
173                                               GridBagConstraints.WEST,
174                                               GridBagConstraints.HORIZONTAL,
175                                               new Insets(5, 10, 2, 5), 0, 0));
176         this.setLayout(layoutMain);
177         this.add(panelCheck,
178                  new GridBagConstraints(0, 1, 2, 1, 0.1, 0.1,
179                                         GridBagConstraints.CENTER,
180                                         GridBagConstraints.BOTH,
181                                         new Insets(5, 5, 5, 5), 0, 0));
182         this.add(panelFiller,
183                  new GridBagConstraints(0, 2, 2, 1, 0.4, 0.4,
184                                         GridBagConstraints.CENTER,
185                                         GridBagConstraints.BOTH,
186                                         new Insets(0, 0, 0, 0), 0, 0));
187     }
188
189     private void pmInit() {
190         checkCLI.setSelected(true);
191     }
192
193 }
194
Popular Tags