KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tomcat5 > customizer > CustomizerStartup


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tomcat5.customizer;
21 import java.awt.Font JavaDoc;
22 import java.io.File JavaDoc;
23 import javax.accessibility.AccessibleContext JavaDoc;
24 import javax.swing.JFileChooser JavaDoc;
25 import javax.swing.JSpinner JavaDoc;
26 import javax.swing.JTextField JavaDoc;
27 import org.openide.util.NbBundle;
28 import org.openide.util.Utilities;
29
30 /**
31  * Customizer Startup tab.
32  *
33  * @author sherold
34  */

35 public class CustomizerStartup extends javax.swing.JPanel JavaDoc {
36
37     private CustomizerDataSupport custData;
38
39     /** Creates new form CustomizerStartup */
40     public CustomizerStartup(CustomizerDataSupport custData) {
41         this.custData = custData;
42         initComponents();
43         if (Utilities.isWindows()) {
44             // force shutdown not supported on Windows
45
jCheckBox4.setEnabled(false);
46         } else {
47             // shared memory debugging transport supported only on Windows
48
jRadioButton1.setEnabled(false);
49             jTextField4.setEnabled(false);
50         }
51         
52         updateCustomScriptComponents();
53         
54         JTextField JavaDoc jSpinner1TextField = ((JSpinner.NumberEditor JavaDoc)jSpinner1.getEditor()).getTextField();
55         
56         AccessibleContext JavaDoc ac = jSpinner1TextField.getAccessibleContext();
57         ac.setAccessibleName(NbBundle.getMessage(CustomizerStartup.class, "ACSN_SocketPortNum"));
58         ac.setAccessibleDescription(NbBundle.getMessage(CustomizerStartup.class, "ACSD_SocketPortNum"));
59         
60         // work-around for jspinner incorrect fonts
61
Font JavaDoc font = jTextField1.getFont();
62         jSpinner1TextField.setFont(font);
63         
64         // mnemonics generated in the guarded block do not work
65
jCheckBox1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_CustomScript").charAt(0));
66         jCheckBox4.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_ForceShutdown").charAt(0));
67         jRadioButton1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_SharedMemName").charAt(0));
68         jRadioButton2.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_SocketPort").charAt(0));
69     }
70     
71     /** This method is called from within the constructor to
72      * initialize the form.
73      * WARNING: Do NOT modify this code. The content of this method is
74      * always regenerated by the Form Editor.
75      */

76     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
77
private void initComponents() {
78         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
79
80         buttonGroup1 = new javax.swing.ButtonGroup JavaDoc();
81         jLabel1 = new javax.swing.JLabel JavaDoc();
82         jTextField1 = new javax.swing.JTextField JavaDoc();
83         jCheckBox1 = new javax.swing.JCheckBox JavaDoc();
84         jLabel4 = new javax.swing.JLabel JavaDoc();
85         jCheckBox4 = new javax.swing.JCheckBox JavaDoc();
86         jRadioButton1 = new javax.swing.JRadioButton JavaDoc();
87         jRadioButton2 = new javax.swing.JRadioButton JavaDoc();
88         jTextField4 = new javax.swing.JTextField JavaDoc();
89         browseButton = new javax.swing.JButton JavaDoc();
90         jLabel2 = new javax.swing.JLabel JavaDoc();
91         jSpinner1 = new javax.swing.JSpinner JavaDoc();
92
93         setLayout(new java.awt.GridBagLayout JavaDoc());
94
95         jLabel1.setLabelFor(jTextField1);
96         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_StartupScript"));
97         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
98         gridBagConstraints.gridx = 0;
99         gridBagConstraints.gridy = 1;
100         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
101         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 17, 0, 0);
102         add(jLabel1, gridBagConstraints);
103         jLabel1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_CatalinaScript"));
104         jLabel1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_CatalinaScript"));
105
106         jTextField1.setColumns(20);
107         jTextField1.setDocument(custData.getScriptPathModel());
108         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
109         gridBagConstraints.gridx = 1;
110         gridBagConstraints.gridy = 1;
111         gridBagConstraints.gridwidth = 2;
112         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
113         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
114         gridBagConstraints.weightx = 1.0;
115         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 0);
116         add(jTextField1, gridBagConstraints);
117         jTextField1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_Script"));
118         jTextField1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_Script"));
119
120         jCheckBox1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_CustomScript").charAt(0));
121         jCheckBox1.setText(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_CustomScript"));
122         jCheckBox1.setModel(custData.getCustomScriptModel());
123         jCheckBox1.addChangeListener(new javax.swing.event.ChangeListener JavaDoc() {
124             public void stateChanged(javax.swing.event.ChangeEvent JavaDoc evt) {
125                 jCheckBox1StateChanged(evt);
126             }
127         });
128
129         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
130         gridBagConstraints.gridx = 0;
131         gridBagConstraints.gridy = 0;
132         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
133         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
134         gridBagConstraints.insets = new java.awt.Insets JavaDoc(12, 12, 0, 0);
135         add(jCheckBox1, gridBagConstraints);
136         jCheckBox1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_CustomScript"));
137         jCheckBox1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_CustomScript"));
138
139         org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_DebugTransport"));
140         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
141         gridBagConstraints.gridx = 0;
142         gridBagConstraints.gridy = 3;
143         gridBagConstraints.gridwidth = 2;
144         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
145         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 12, 0, 0);
146         add(jLabel4, gridBagConstraints);
147         jLabel4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSN_DebugTrans"));
148         jLabel4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSN_DebugTrans"));
149
150         jCheckBox4.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_ForceShutdown").charAt(0));
151         jCheckBox4.setText(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_ForceShutdown"));
152         jCheckBox4.setModel(custData.getForceStopModel());
153         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
154         gridBagConstraints.gridx = 0;
155         gridBagConstraints.gridy = 2;
156         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
157         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
158         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
159         add(jCheckBox4, gridBagConstraints);
160         jCheckBox4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_ForceStop"));
161         jCheckBox4.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_ForceStop"));
162
163         buttonGroup1.add(jRadioButton1);
164         jRadioButton1.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_SharedMemName").charAt(0));
165         jRadioButton1.setText(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_SharedMemName"));
166         jRadioButton1.setModel(custData.getSharedMemModel());
167         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
168         gridBagConstraints.gridx = 0;
169         gridBagConstraints.gridy = 4;
170         gridBagConstraints.gridwidth = 2;
171         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
172         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
173         add(jRadioButton1, gridBagConstraints);
174         jRadioButton1.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSN_SharedMem"));
175         jRadioButton1.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSD_SharedMem"));
176
177         buttonGroup1.add(jRadioButton2);
178         jRadioButton2.setMnemonic(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "MNE_SocketPort").charAt(0));
179         jRadioButton2.setText(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_SocketPort"));
180         jRadioButton2.setModel(custData.getSocketModel());
181         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
182         gridBagConstraints.gridx = 0;
183         gridBagConstraints.gridy = 5;
184         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
185         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 0, 0);
186         add(jRadioButton2, gridBagConstraints);
187         jRadioButton2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSN_SocketPort"));
188         jRadioButton2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSD_SocektPort"));
189
190         jTextField4.setColumns(15);
191         jTextField4.setDocument(custData.getSharedMemNameModel());
192         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
193         gridBagConstraints.gridx = 2;
194         gridBagConstraints.gridy = 4;
195         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
196         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
197         gridBagConstraints.weightx = 1.0;
198         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 0);
199         add(jTextField4, gridBagConstraints);
200         jTextField4.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ACSD_SharedMemName"));
201
202         org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_BrowseCatalinaScript"));
203         browseButton.setEnabled(false);
204         browseButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
205             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
206                 browseButtonActionPerformed(evt);
207             }
208         });
209
210         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
211         gridBagConstraints.gridx = 3;
212         gridBagConstraints.gridy = 1;
213         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
214         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 12);
215         add(browseButton, gridBagConstraints);
216         browseButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_Browse"));
217         browseButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_Browse"));
218
219         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "TXT_NoteChangesTakeAffect"));
220         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
221         gridBagConstraints.gridx = 0;
222         gridBagConstraints.gridy = 6;
223         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
224         gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
225         gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
226         gridBagConstraints.weighty = 1.0;
227         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 12, 12, 0);
228         add(jLabel2, gridBagConstraints);
229         jLabel2.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCN_Note"));
230         jLabel2.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerStartup.class, "ASCD_Note"));
231
232         jSpinner1.setFont(new java.awt.Font JavaDoc("Dialog", 0, 12));
233         jSpinner1.setModel(custData.getDebugPortModel());
234         jSpinner1.setEditor(new JSpinner.NumberEditor JavaDoc(jSpinner1, "#"));
235         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
236         gridBagConstraints.gridx = 2;
237         gridBagConstraints.gridy = 5;
238         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
239         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 5, 0, 0);
240         add(jSpinner1, gridBagConstraints);
241
242     }// </editor-fold>//GEN-END:initComponents
243

244     private void browseButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_browseButtonActionPerformed
245
JFileChooser JavaDoc chooser;
246         File JavaDoc script = new File JavaDoc(jTextField1.getText().trim());
247         File JavaDoc currentFolder = script.isDirectory() ? script
248                                                   : script.getParentFile();
249         if (currentFolder != null && currentFolder.exists()) {
250             chooser = new JFileChooser JavaDoc(currentFolder);
251         } else {
252             chooser = new JFileChooser JavaDoc();
253         }
254         int returnVal = chooser.showOpenDialog(null);
255         if (returnVal == JFileChooser.APPROVE_OPTION) {
256             jTextField1.setText(chooser.getSelectedFile().getAbsolutePath());
257         }
258     }//GEN-LAST:event_browseButtonActionPerformed
259

260     private void jCheckBox1StateChanged(javax.swing.event.ChangeEvent JavaDoc evt) {//GEN-FIRST:event_jCheckBox1StateChanged
261
updateCustomScriptComponents();
262     }//GEN-LAST:event_jCheckBox1StateChanged
263

264     private void updateCustomScriptComponents() {
265         boolean enabled = jCheckBox1.isSelected();
266         jLabel1.setEnabled(enabled);
267         jTextField1.setEnabled(enabled);
268         browseButton.setEnabled(enabled);
269     }
270     
271     // Variables declaration - do not modify//GEN-BEGIN:variables
272
private javax.swing.JButton JavaDoc browseButton;
273     private javax.swing.ButtonGroup JavaDoc buttonGroup1;
274     private javax.swing.JCheckBox JavaDoc jCheckBox1;
275     private javax.swing.JCheckBox JavaDoc jCheckBox4;
276     private javax.swing.JLabel JavaDoc jLabel1;
277     private javax.swing.JLabel JavaDoc jLabel2;
278     private javax.swing.JLabel JavaDoc jLabel4;
279     private javax.swing.JRadioButton JavaDoc jRadioButton1;
280     private javax.swing.JRadioButton JavaDoc jRadioButton2;
281     private javax.swing.JSpinner JavaDoc jSpinner1;
282     private javax.swing.JTextField JavaDoc jTextField1;
283     private javax.swing.JTextField JavaDoc jTextField4;
284     // End of variables declaration//GEN-END:variables
285

286 }
287
Popular Tags