KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > project > ui > customizer > CustomizerRun


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.web.project.ui.customizer;
21
22
23 import javax.swing.*;
24
25 import org.openide.util.HelpCtx;
26 import org.openide.util.NbBundle;
27
28 import org.netbeans.modules.web.api.webmodule.WebModule;
29 import org.netbeans.modules.web.project.ProjectWebModule;
30
31 public class CustomizerRun extends JPanel implements HelpCtx.Provider {
32     
33     /** Creates new form CustomizerRun */
34     public CustomizerRun(WebProjectProperties uiProperties) {
35         initComponents();
36         
37         this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerRun.class, "ACS_CustomizeRun_A11YDesc")); //NOI18N
38

39         // disable editing context path if deployment descriptor does not exist
40
ProjectWebModule wm = (ProjectWebModule) uiProperties.getProject().getLookup().lookup(ProjectWebModule.class);
41         jTextFieldContextPath.setEnabled(wm.getDeploymentDescriptor() != null);
42
43         jTextFieldJ2EE.setDocument( uiProperties.J2EE_PLATFORM_MODEL );
44         jTextFieldJ2EE.setVisible(false);
45         jTextFieldContextPath.setDocument( uiProperties.CONTEXT_PATH_MODEL );
46         jTextFieldRelativeURL.setDocument( uiProperties.LAUNCH_URL_RELATIVE_MODEL );
47         uiProperties.DISPLAY_BROWSER_MODEL.setMnemonic( jCheckBoxDisplayBrowser.getMnemonic() );
48         jCheckBoxDisplayBrowser.setModel( uiProperties.DISPLAY_BROWSER_MODEL );
49         jComboBoxServer.setModel( uiProperties.J2EE_SERVER_INSTANCE_MODEL );
50         
51         String JavaDoc j2eeVersion = jTextFieldJ2EE.getText().trim();
52         if (j2eeVersion.equalsIgnoreCase(WebModule.J2EE_13_LEVEL))
53             jTextFieldJ2EE_Display.setText(NbBundle.getMessage(CustomizerRun.class, "J2EESpecLevel_13")); //NOI18N;
54
else if (j2eeVersion.equalsIgnoreCase(WebModule.J2EE_14_LEVEL))
55             jTextFieldJ2EE_Display.setText(NbBundle.getMessage(CustomizerRun.class, "J2EESpecLevel_14")); //NOI18N;
56
else if (j2eeVersion.equalsIgnoreCase(WebModule.JAVA_EE_5_LEVEL))
57             jTextFieldJ2EE_Display.setText(NbBundle.getMessage(CustomizerRun.class, "JavaEESpecLevel_50")); //NOI18N;
58
}
59
60     /** This method is called from within the constructor to
61      * initialize the form.
62      * WARNING: Do NOT modify this code. The content of this method is
63      * always regenerated by the Form Editor.
64      */

65     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
66
private void initComponents() {
67         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
68
69         jLabelServer = new javax.swing.JLabel JavaDoc();
70         jComboBoxServer = new javax.swing.JComboBox JavaDoc();
71         jLabelJ2EE = new javax.swing.JLabel JavaDoc();
72         jTextFieldJ2EE = new javax.swing.JTextField JavaDoc();
73         jTextFieldJ2EE_Display = new javax.swing.JTextField JavaDoc();
74         jLabelContextPath = new javax.swing.JLabel JavaDoc();
75         jTextFieldContextPath = new javax.swing.JTextField JavaDoc();
76         jCheckBoxDisplayBrowser = new javax.swing.JCheckBox JavaDoc();
77         jLabelContextPathDesc = new javax.swing.JLabel JavaDoc();
78         jLabelRelativeURL = new javax.swing.JLabel JavaDoc();
79         jTextFieldRelativeURL = new javax.swing.JTextField JavaDoc();
80         jLabelURLExample = new javax.swing.JLabel JavaDoc();
81         errorLabel = new javax.swing.JLabel JavaDoc();
82
83         setLayout(new java.awt.GridBagLayout JavaDoc());
84
85         jLabelServer.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/project/ui/customizer/Bundle").getString("LBL_CustomizeRun_Server_LabelMnemonic").charAt(0));
86         jLabelServer.setLabelFor(jComboBoxServer);
87         jLabelServer.setText(NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_Server_JLabel"));
88         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
89         gridBagConstraints.gridx = 0;
90         gridBagConstraints.gridy = 0;
91         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
92         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
93         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 5, 0);
94         add(jLabelServer, gridBagConstraints);
95
96         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
97         gridBagConstraints.gridx = 1;
98         gridBagConstraints.gridy = 0;
99         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
100         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
101         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 5, 0);
102         add(jComboBoxServer, gridBagConstraints);
103         jComboBoxServer.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/project/ui/customizer/Bundle").getString("ACS_CustomizeRun_Server_A11YDesc"));
104
105         jLabelJ2EE.setLabelFor(jTextFieldJ2EE);
106         jLabelJ2EE.setText(org.openide.util.NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_J2EE_JLabel"));
107         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
108         gridBagConstraints.gridx = 0;
109         gridBagConstraints.gridy = 1;
110         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
111         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 5, 0);
112         add(jLabelJ2EE, gridBagConstraints);
113         jLabelJ2EE.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CustomizerRun.class, "ACSD_CustomizerRun_jLabelJ2EE"));
114
115         jTextFieldJ2EE.setEditable(false);
116         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
117         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
118         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
119         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 5, 0);
120         add(jTextFieldJ2EE, gridBagConstraints);
121
122         jTextFieldJ2EE_Display.setEditable(false);
123         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
124         gridBagConstraints.gridx = 1;
125         gridBagConstraints.gridy = 1;
126         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
127         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
128         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 5, 0);
129         add(jTextFieldJ2EE_Display, gridBagConstraints);
130
131         jLabelContextPath.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/project/ui/customizer/Bundle").getString("LBL_CustomizeRun_ContextPath_LabelMnemonic").charAt(0));
132         jLabelContextPath.setLabelFor(jTextFieldContextPath);
133         jLabelContextPath.setText(NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_ContextPath_JLabel"));
134         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
135         gridBagConstraints.gridx = 0;
136         gridBagConstraints.gridy = 2;
137         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
138         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
139         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 0);
140         add(jLabelContextPath, gridBagConstraints);
141
142         jTextFieldContextPath.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
143             public void keyReleased(java.awt.event.KeyEvent JavaDoc evt) {
144                 jTextFieldContextPathKeyReleased(evt);
145             }
146         });
147
148         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
149         gridBagConstraints.gridx = 1;
150         gridBagConstraints.gridy = 2;
151         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
152         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
153         gridBagConstraints.weightx = 1.0;
154         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 11, 0);
155         add(jTextFieldContextPath, gridBagConstraints);
156         jTextFieldContextPath.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/project/ui/customizer/Bundle").getString("ACS_CustomizeRun_ContextPath_A11YDesc"));
157
158         jCheckBoxDisplayBrowser.setSelected(true);
159         org.openide.awt.Mnemonics.setLocalizedText(jCheckBoxDisplayBrowser, NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_DisplayBrowser_JCheckBox"));
160         jCheckBoxDisplayBrowser.addActionListener(new java.awt.event.ActionListener JavaDoc() {
161             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
162                 jCheckBoxDisplayBrowserActionPerformed(evt);
163             }
164         });
165
166         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
167         gridBagConstraints.gridx = 0;
168         gridBagConstraints.gridy = 3;
169         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
170         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
171         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 0);
172         add(jCheckBoxDisplayBrowser, gridBagConstraints);
173         jCheckBoxDisplayBrowser.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/project/ui/customizer/Bundle").getString("ACS_CustomizeRun_DisplayBrowser_A11YDesc"));
174
175         jLabelContextPathDesc.setText(NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_ContextPathDesc_JLabel"));
176         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
177         gridBagConstraints.gridx = 0;
178         gridBagConstraints.gridy = 4;
179         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
180         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
181         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
182         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 5, 0);
183         add(jLabelContextPathDesc, gridBagConstraints);
184
185         jLabelRelativeURL.setDisplayedMnemonic(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/project/ui/customizer/Bundle").getString("LBL_CustomizeRun_RelativeURL_LabelMnemonic").charAt(0));
186         jLabelRelativeURL.setLabelFor(jTextFieldRelativeURL);
187         jLabelRelativeURL.setText(NbBundle.getMessage(CustomizerRun.class, "LBL_CustomizeRun_RelativeURL_JLabel"));
188         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
189         gridBagConstraints.gridx = 0;
190         gridBagConstraints.gridy = 5;
191         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
192         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
193         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 12, 5, 0);
194         add(jLabelRelativeURL, gridBagConstraints);
195
196         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
197         gridBagConstraints.gridx = 1;
198         gridBagConstraints.gridy = 5;
199         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
200         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
201         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
202         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 5, 0);
203         add(jTextFieldRelativeURL, gridBagConstraints);
204         jTextFieldRelativeURL.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/web/project/ui/customizer/Bundle").getString("ACS_CustomizeRun_RelativeURL_A11YDesc"));
205
206         jLabelURLExample.setText(NbBundle.getMessage(CustomizerRun.class, "LBL_RelativeURLExample"));
207         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
208         gridBagConstraints.gridx = 1;
209         gridBagConstraints.gridy = 6;
210         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
211         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
212         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
213         gridBagConstraints.weighty = 1.0;
214         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 11, 0);
215         add(jLabelURLExample, gridBagConstraints);
216         jLabelURLExample.getAccessibleContext().setAccessibleName(NbBundle.getMessage(CustomizerRun.class, "ACS_CustomizeRun_RelativeURLExample_A11YDesc"));
217
218         org.openide.awt.Mnemonics.setLocalizedText(errorLabel, " ");
219         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
220         gridBagConstraints.gridx = 0;
221         gridBagConstraints.gridy = 7;
222         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
223         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
224         gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
225         add(errorLabel, gridBagConstraints);
226
227     }// </editor-fold>//GEN-END:initComponents
228

229     private void jTextFieldContextPathKeyReleased(java.awt.event.KeyEvent JavaDoc evt) {//GEN-FIRST:event_jTextFieldContextPathKeyReleased
230
checkContextPath();
231     }//GEN-LAST:event_jTextFieldContextPathKeyReleased
232

233     private void jCheckBoxDisplayBrowserActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_jCheckBoxDisplayBrowserActionPerformed
234
boolean editable = jCheckBoxDisplayBrowser.isSelected();
235         
236         jLabelContextPathDesc.setEnabled(editable);
237         jLabelRelativeURL.setEnabled(editable);
238         jTextFieldRelativeURL.setEditable(editable);
239     }//GEN-LAST:event_jCheckBoxDisplayBrowserActionPerformed
240

241     // Variables declaration - do not modify//GEN-BEGIN:variables
242
private javax.swing.JLabel JavaDoc errorLabel;
243     private javax.swing.JCheckBox JavaDoc jCheckBoxDisplayBrowser;
244     private javax.swing.JComboBox JavaDoc jComboBoxServer;
245     private javax.swing.JLabel JavaDoc jLabelContextPath;
246     private javax.swing.JLabel JavaDoc jLabelContextPathDesc;
247     private javax.swing.JLabel JavaDoc jLabelJ2EE;
248     private javax.swing.JLabel JavaDoc jLabelRelativeURL;
249     private javax.swing.JLabel JavaDoc jLabelServer;
250     private javax.swing.JLabel JavaDoc jLabelURLExample;
251     private javax.swing.JTextField JavaDoc jTextFieldContextPath;
252     private javax.swing.JTextField JavaDoc jTextFieldJ2EE;
253     private javax.swing.JTextField JavaDoc jTextFieldJ2EE_Display;
254     private javax.swing.JTextField JavaDoc jTextFieldRelativeURL;
255     // End of variables declaration//GEN-END:variables
256

257     /** Help context where to find more about the paste type action.
258      * @return the help context for this action
259      */

260     public HelpCtx getHelpCtx() {
261         return new HelpCtx(CustomizerRun.class);
262     }
263
264     private boolean checkContextPath() {
265         String JavaDoc message = contextPathValidation();
266         errorLabel.setText(message);
267         return message != null;
268     }
269
270     private String JavaDoc contextPathValidation() {
271         String JavaDoc contextPath = jTextFieldContextPath.getText();
272         String JavaDoc message = null;
273         if (contextPath.length() > 0) {
274             if (!contextPath.startsWith("/")) {
275                 message = NbBundle.getMessage (CustomizerRun.class, "MSG_INVALID_CP_DOES_NOT_START_WITH_SLASH"); //NOI18N
276
} else if (contextPath.indexOf("//") >= 0) {
277                 message = NbBundle.getMessage (CustomizerRun.class, "MSG_INVALID_CP_CONTAINS_DOUBLE_SLASH"); //NOI18N
278
} else if (contextPath.endsWith("/")) {
279                 message = NbBundle.getMessage (CustomizerRun.class, "MSG_INVALID_CP_ENDS_WITH_SLASH"); //NOI18N
280
}
281         }
282         return message;
283     }
284 }
285
Popular Tags