1 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 34 public CustomizerRun(WebProjectProperties uiProperties) { 35 initComponents(); 36 37 this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerRun.class, "ACS_CustomizeRun_A11YDesc")); 39 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 j2eeVersion = jTextFieldJ2EE.getText().trim(); 52 if (j2eeVersion.equalsIgnoreCase(WebModule.J2EE_13_LEVEL)) 53 jTextFieldJ2EE_Display.setText(NbBundle.getMessage(CustomizerRun.class, "J2EESpecLevel_13")); else if (j2eeVersion.equalsIgnoreCase(WebModule.J2EE_14_LEVEL)) 55 jTextFieldJ2EE_Display.setText(NbBundle.getMessage(CustomizerRun.class, "J2EESpecLevel_14")); else if (j2eeVersion.equalsIgnoreCase(WebModule.JAVA_EE_5_LEVEL)) 57 jTextFieldJ2EE_Display.setText(NbBundle.getMessage(CustomizerRun.class, "JavaEESpecLevel_50")); } 59 60 65 private void initComponents() { 67 java.awt.GridBagConstraints gridBagConstraints; 68 69 jLabelServer = new javax.swing.JLabel (); 70 jComboBoxServer = new javax.swing.JComboBox (); 71 jLabelJ2EE = new javax.swing.JLabel (); 72 jTextFieldJ2EE = new javax.swing.JTextField (); 73 jTextFieldJ2EE_Display = new javax.swing.JTextField (); 74 jLabelContextPath = new javax.swing.JLabel (); 75 jTextFieldContextPath = new javax.swing.JTextField (); 76 jCheckBoxDisplayBrowser = new javax.swing.JCheckBox (); 77 jLabelContextPathDesc = new javax.swing.JLabel (); 78 jLabelRelativeURL = new javax.swing.JLabel (); 79 jTextFieldRelativeURL = new javax.swing.JTextField (); 80 jLabelURLExample = new javax.swing.JLabel (); 81 errorLabel = new javax.swing.JLabel (); 82 83 setLayout(new java.awt.GridBagLayout ()); 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 (); 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 (0, 0, 5, 0); 94 add(jLabelServer, gridBagConstraints); 95 96 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 108 gridBagConstraints.gridx = 0; 109 gridBagConstraints.gridy = 1; 110 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 111 gridBagConstraints.insets = new java.awt.Insets (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 (); 117 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 118 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 119 gridBagConstraints.insets = new java.awt.Insets (0, 12, 5, 0); 120 add(jTextFieldJ2EE, gridBagConstraints); 121 122 jTextFieldJ2EE_Display.setEditable(false); 123 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (0, 0, 11, 0); 140 add(jLabelContextPath, gridBagConstraints); 141 142 jTextFieldContextPath.addKeyListener(new java.awt.event.KeyAdapter () { 143 public void keyReleased(java.awt.event.KeyEvent evt) { 144 jTextFieldContextPathKeyReleased(evt); 145 } 146 }); 147 148 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 () { 161 public void actionPerformed(java.awt.event.ActionEvent evt) { 162 jCheckBoxDisplayBrowserActionPerformed(evt); 163 } 164 }); 165 166 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (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 (); 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 (0, 12, 5, 0); 194 add(jLabelRelativeURL, gridBagConstraints); 195 196 gridBagConstraints = new java.awt.GridBagConstraints (); 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 (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 (); 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 (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 (); 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 } 229 private void jTextFieldContextPathKeyReleased(java.awt.event.KeyEvent evt) { checkContextPath(); 231 } 233 private void jCheckBoxDisplayBrowserActionPerformed(java.awt.event.ActionEvent evt) { boolean editable = jCheckBoxDisplayBrowser.isSelected(); 235 236 jLabelContextPathDesc.setEnabled(editable); 237 jLabelRelativeURL.setEnabled(editable); 238 jTextFieldRelativeURL.setEditable(editable); 239 } 241 private javax.swing.JLabel errorLabel; 243 private javax.swing.JCheckBox jCheckBoxDisplayBrowser; 244 private javax.swing.JComboBox jComboBoxServer; 245 private javax.swing.JLabel jLabelContextPath; 246 private javax.swing.JLabel jLabelContextPathDesc; 247 private javax.swing.JLabel jLabelJ2EE; 248 private javax.swing.JLabel jLabelRelativeURL; 249 private javax.swing.JLabel jLabelServer; 250 private javax.swing.JLabel jLabelURLExample; 251 private javax.swing.JTextField jTextFieldContextPath; 252 private javax.swing.JTextField jTextFieldJ2EE; 253 private javax.swing.JTextField jTextFieldJ2EE_Display; 254 private javax.swing.JTextField jTextFieldRelativeURL; 255 257 260 public HelpCtx getHelpCtx() { 261 return new HelpCtx(CustomizerRun.class); 262 } 263 264 private boolean checkContextPath() { 265 String message = contextPathValidation(); 266 errorLabel.setText(message); 267 return message != null; 268 } 269 270 private String contextPathValidation() { 271 String contextPath = jTextFieldContextPath.getText(); 272 String 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"); } else if (contextPath.indexOf("//") >= 0) { 277 message = NbBundle.getMessage (CustomizerRun.class, "MSG_INVALID_CP_CONTAINS_DOUBLE_SLASH"); } else if (contextPath.endsWith("/")) { 279 message = NbBundle.getMessage (CustomizerRun.class, "MSG_INVALID_CP_ENDS_WITH_SLASH"); } 281 } 282 return message; 283 } 284 } 285 | Popular Tags |