1 19 20 package org.netbeans.modules.websvc.jaxrpc.project; 21 22 import java.util.HashSet ; 23 import java.util.Iterator ; 24 import java.util.List ; 25 import java.util.Set ; 26 27 import java.awt.Color ; 28 import java.awt.event.ItemEvent ; 29 import java.awt.event.ItemListener ; 30 31 import javax.swing.JCheckBox ; 32 import javax.swing.JPanel ; 33 import javax.swing.DefaultListModel ; 34 import javax.swing.event.DocumentEvent ; 35 import javax.swing.event.DocumentListener ; 36 import javax.swing.text.Document ; 37 import javax.swing.text.BadLocationException ; 38 import org.openide.ErrorManager; 39 import org.openide.WizardValidationException; 40 import org.openide.util.HelpCtx; 41 import org.openide.util.NbBundle; 42 43 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport; 44 45 49 public class CustomizerWsCompileClient extends javax.swing.JPanel implements WsCompileClientEditorSupport.Panel, HelpCtx.Provider { 50 51 public static final Color ErrorTextForegroundColor = new Color (89, 79, 191); 52 53 private static final int MAX_IMPORTANT_FEATURES = 12; 54 55 private DefaultListModel servicesModel; 56 private JCheckBox [] featureCheckboxes; 57 58 private String features; 59 private boolean updatingDisplay; 60 private boolean processingCheckBox; 61 private boolean processingFeatureString; 62 63 public CustomizerWsCompileClient() { 64 initComponents(); 65 initUserComponents(); 66 } 67 68 73 private void initComponents() { 75 java.awt.GridBagConstraints gridBagConstraints; 76 77 jPnlServices = new javax.swing.JPanel (); 78 jLblServices = new javax.swing.JLabel (); 79 jScrollPane1 = new javax.swing.JScrollPane (); 80 jLstServices = new javax.swing.JList (); 81 jPnlFeatures = new javax.swing.JPanel (); 82 jLblPanelDescription = new javax.swing.JLabel (); 83 jPnlFeatureCheckboxes = new javax.swing.JPanel (); 84 jChkFeatureA = new javax.swing.JCheckBox (); 85 jChkFeatureB = new javax.swing.JCheckBox (); 86 jChkFeatureC = new javax.swing.JCheckBox (); 87 jChkFeatureD = new javax.swing.JCheckBox (); 88 jChkFeatureE = new javax.swing.JCheckBox (); 89 jChkFeatureF = new javax.swing.JCheckBox (); 90 jChkFeatureG = new javax.swing.JCheckBox (); 91 jChkFeatureH = new javax.swing.JCheckBox (); 92 jChkFeatureI = new javax.swing.JCheckBox (); 93 jChkFeatureJ = new javax.swing.JCheckBox (); 94 jChkFeatureK = new javax.swing.JCheckBox (); 95 jChkFeatureL = new javax.swing.JCheckBox (); 96 jLblEnabledFeatures = new javax.swing.JLabel (); 97 jScrollPane2 = new javax.swing.JScrollPane (); 98 jTxtEnabledFeatures = new javax.swing.JTextArea (); 99 jLblError = new javax.swing.JLabel (); 100 jPnlOptions = new javax.swing.JPanel (); 101 jLblOptions = new javax.swing.JLabel (); 102 jPanel1 = new javax.swing.JPanel (); 103 cbVerbose = new javax.swing.JCheckBox (); 104 cbDebug = new javax.swing.JCheckBox (); 105 cbPrintStackTrace = new javax.swing.JCheckBox (); 106 cbSerializable = new javax.swing.JCheckBox (); 107 cbOptimize = new javax.swing.JCheckBox (); 108 109 setLayout(new java.awt.GridBagLayout ()); 110 111 jPnlServices.setLayout(new java.awt.GridBagLayout ()); 112 113 jLblServices.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_WebServicesMnemonic").charAt(0)); 114 jLblServices.setLabelFor(jLstServices); 115 jLblServices.setText(org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_WebServices")); 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, 0, 2, 0); 120 jPnlServices.add(jLblServices, gridBagConstraints); 121 122 jLstServices.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); 123 jLstServices.addListSelectionListener(new javax.swing.event.ListSelectionListener () { 124 public void valueChanged(javax.swing.event.ListSelectionEvent evt) { 125 jLstServicesValueChanged(evt); 126 } 127 }); 128 129 jScrollPane1.setViewportView(jLstServices); 130 131 gridBagConstraints = new java.awt.GridBagConstraints (); 132 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 133 gridBagConstraints.weightx = 1.0; 134 gridBagConstraints.weighty = 1.0; 135 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 136 jPnlServices.add(jScrollPane1, gridBagConstraints); 137 138 gridBagConstraints = new java.awt.GridBagConstraints (); 139 gridBagConstraints.gridx = 0; 140 gridBagConstraints.gridy = 0; 141 gridBagConstraints.gridheight = 2; 142 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 143 gridBagConstraints.weightx = 0.5; 144 gridBagConstraints.weighty = 1.0; 145 add(jPnlServices, gridBagConstraints); 146 147 jPnlFeatures.setLayout(new java.awt.GridBagLayout ()); 148 149 org.openide.awt.Mnemonics.setLocalizedText(jLblPanelDescription, NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_PanelDescriptionService")); 150 gridBagConstraints = new java.awt.GridBagConstraints (); 151 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 152 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 153 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 154 jPnlFeatures.add(jLblPanelDescription, gridBagConstraints); 155 156 jPnlFeatureCheckboxes.setLayout(new java.awt.GridBagLayout ()); 157 158 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureA, "Feature A"); 159 gridBagConstraints = new java.awt.GridBagConstraints (); 160 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 161 gridBagConstraints.weightx = 0.33; 162 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 163 jPnlFeatureCheckboxes.add(jChkFeatureA, gridBagConstraints); 164 165 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureB, "Feature B"); 166 gridBagConstraints = new java.awt.GridBagConstraints (); 167 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 168 gridBagConstraints.weightx = 0.33; 169 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 170 jPnlFeatureCheckboxes.add(jChkFeatureB, gridBagConstraints); 171 172 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureC, "Feature C"); 173 gridBagConstraints = new java.awt.GridBagConstraints (); 174 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 175 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 176 gridBagConstraints.weightx = 0.33; 177 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 178 jPnlFeatureCheckboxes.add(jChkFeatureC, gridBagConstraints); 179 180 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureD, "Feature D"); 181 gridBagConstraints = new java.awt.GridBagConstraints (); 182 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 183 gridBagConstraints.weightx = 0.33; 184 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 185 jPnlFeatureCheckboxes.add(jChkFeatureD, gridBagConstraints); 186 187 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureE, "Feature E"); 188 gridBagConstraints = new java.awt.GridBagConstraints (); 189 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 190 gridBagConstraints.weightx = 0.33; 191 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 192 jPnlFeatureCheckboxes.add(jChkFeatureE, gridBagConstraints); 193 194 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureF, "Feature F"); 195 gridBagConstraints = new java.awt.GridBagConstraints (); 196 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 197 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 198 gridBagConstraints.weightx = 0.33; 199 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 200 jPnlFeatureCheckboxes.add(jChkFeatureF, gridBagConstraints); 201 202 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureG, "Feature G"); 203 gridBagConstraints = new java.awt.GridBagConstraints (); 204 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 205 gridBagConstraints.weightx = 0.33; 206 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 207 jPnlFeatureCheckboxes.add(jChkFeatureG, gridBagConstraints); 208 209 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureH, "Feature H"); 210 gridBagConstraints = new java.awt.GridBagConstraints (); 211 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 212 gridBagConstraints.weightx = 0.33; 213 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 214 jPnlFeatureCheckboxes.add(jChkFeatureH, gridBagConstraints); 215 216 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureI, "Feature I"); 217 gridBagConstraints = new java.awt.GridBagConstraints (); 218 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 219 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 220 gridBagConstraints.weightx = 0.33; 221 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 222 jPnlFeatureCheckboxes.add(jChkFeatureI, gridBagConstraints); 223 224 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureJ, "Feature J"); 225 gridBagConstraints = new java.awt.GridBagConstraints (); 226 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 227 gridBagConstraints.weightx = 0.33; 228 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 229 jPnlFeatureCheckboxes.add(jChkFeatureJ, gridBagConstraints); 230 231 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureK, "Feature K"); 232 gridBagConstraints = new java.awt.GridBagConstraints (); 233 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 234 gridBagConstraints.weightx = 0.33; 235 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 236 jPnlFeatureCheckboxes.add(jChkFeatureK, gridBagConstraints); 237 238 org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureL, "Feature L"); 239 gridBagConstraints = new java.awt.GridBagConstraints (); 240 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 241 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 242 gridBagConstraints.weightx = 0.33; 243 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 244 jPnlFeatureCheckboxes.add(jChkFeatureL, gridBagConstraints); 245 246 gridBagConstraints = new java.awt.GridBagConstraints (); 247 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 248 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 249 gridBagConstraints.weightx = 1.0; 250 jPnlFeatures.add(jPnlFeatureCheckboxes, gridBagConstraints); 251 252 jLblEnabledFeatures.setLabelFor(jTxtEnabledFeatures); 253 org.openide.awt.Mnemonics.setLocalizedText(jLblEnabledFeatures, org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_EnabledFeatures")); 254 jLblEnabledFeatures.setOpaque(true); 255 gridBagConstraints = new java.awt.GridBagConstraints (); 256 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 257 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 258 gridBagConstraints.insets = new java.awt.Insets (0, 0, 2, 11); 259 jPnlFeatures.add(jLblEnabledFeatures, gridBagConstraints); 260 261 jTxtEnabledFeatures.setLineWrap(true); 262 jTxtEnabledFeatures.setRows(2); 263 jTxtEnabledFeatures.setWrapStyleWord(true); 264 jScrollPane2.setViewportView(jTxtEnabledFeatures); 265 266 gridBagConstraints = new java.awt.GridBagConstraints (); 267 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 268 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 269 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; 270 gridBagConstraints.weightx = 1.0; 271 gridBagConstraints.weighty = 1.0; 272 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 0); 273 jPnlFeatures.add(jScrollPane2, gridBagConstraints); 274 275 gridBagConstraints = new java.awt.GridBagConstraints (); 276 gridBagConstraints.gridx = 1; 277 gridBagConstraints.gridy = 0; 278 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 279 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 280 gridBagConstraints.weightx = 0.5; 281 gridBagConstraints.weighty = 0.5; 282 gridBagConstraints.insets = new java.awt.Insets (0, 11, 0, 0); 283 add(jPnlFeatures, gridBagConstraints); 284 285 org.openide.awt.Mnemonics.setLocalizedText(jLblError, " "); 286 gridBagConstraints = new java.awt.GridBagConstraints (); 287 gridBagConstraints.gridx = 0; 288 gridBagConstraints.gridy = 2; 289 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 290 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 291 gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST; 292 gridBagConstraints.insets = new java.awt.Insets (0, 0, 6, 0); 293 add(jLblError, gridBagConstraints); 294 295 jPnlOptions.setLayout(new java.awt.GridBagLayout ()); 296 297 jLblOptions.setLabelFor(jTxtEnabledFeatures); 298 org.openide.awt.Mnemonics.setLocalizedText(jLblOptions, org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_AdditionalOptions")); 299 jLblOptions.setOpaque(true); 300 gridBagConstraints = new java.awt.GridBagConstraints (); 301 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 302 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 303 gridBagConstraints.insets = new java.awt.Insets (11, 0, 10, 0); 304 jPnlOptions.add(jLblOptions, gridBagConstraints); 305 306 jPanel1.setLayout(new java.awt.GridBagLayout ()); 307 308 org.openide.awt.Mnemonics.setLocalizedText(cbVerbose, org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_verbose")); 309 cbVerbose.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 310 cbVerbose.setMargin(new java.awt.Insets (0, 0, 0, 0)); 311 gridBagConstraints = new java.awt.GridBagConstraints (); 312 gridBagConstraints.gridx = 0; 313 gridBagConstraints.gridy = 0; 314 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 315 gridBagConstraints.weightx = 0.33; 316 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 317 jPanel1.add(cbVerbose, gridBagConstraints); 318 319 org.openide.awt.Mnemonics.setLocalizedText(cbDebug, org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_debug")); 320 cbDebug.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 321 cbDebug.setMargin(new java.awt.Insets (0, 0, 0, 0)); 322 gridBagConstraints = new java.awt.GridBagConstraints (); 323 gridBagConstraints.gridx = 1; 324 gridBagConstraints.gridy = 0; 325 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 326 gridBagConstraints.weightx = 0.33; 327 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 328 jPanel1.add(cbDebug, gridBagConstraints); 329 330 org.openide.awt.Mnemonics.setLocalizedText(cbPrintStackTrace, org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_xPrintStackTrace")); 331 cbPrintStackTrace.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 332 cbPrintStackTrace.setMargin(new java.awt.Insets (0, 0, 0, 0)); 333 gridBagConstraints = new java.awt.GridBagConstraints (); 334 gridBagConstraints.gridx = 2; 335 gridBagConstraints.gridy = 0; 336 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 337 gridBagConstraints.weightx = 0.33; 338 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 339 jPanel1.add(cbPrintStackTrace, gridBagConstraints); 340 341 org.openide.awt.Mnemonics.setLocalizedText(cbSerializable, org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_xSerializable")); 342 cbSerializable.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 343 cbSerializable.setMargin(new java.awt.Insets (0, 0, 0, 0)); 344 gridBagConstraints = new java.awt.GridBagConstraints (); 345 gridBagConstraints.gridx = 0; 346 gridBagConstraints.gridy = 1; 347 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 348 gridBagConstraints.weightx = 0.33; 349 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 350 jPanel1.add(cbSerializable, gridBagConstraints); 351 352 org.openide.awt.Mnemonics.setLocalizedText(cbOptimize, org.openide.util.NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_optimize")); 353 cbOptimize.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0)); 354 cbOptimize.setMargin(new java.awt.Insets (0, 0, 0, 0)); 355 gridBagConstraints = new java.awt.GridBagConstraints (); 356 gridBagConstraints.gridx = 1; 357 gridBagConstraints.gridy = 1; 358 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 359 gridBagConstraints.weightx = 0.33; 360 gridBagConstraints.insets = new java.awt.Insets (0, 0, 11, 11); 361 jPanel1.add(cbOptimize, gridBagConstraints); 362 363 gridBagConstraints = new java.awt.GridBagConstraints (); 364 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 365 gridBagConstraints.weightx = 1.0; 366 jPnlOptions.add(jPanel1, gridBagConstraints); 367 368 gridBagConstraints = new java.awt.GridBagConstraints (); 369 gridBagConstraints.gridx = 1; 370 gridBagConstraints.gridy = 1; 371 gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; 372 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 373 gridBagConstraints.weightx = 0.5; 374 gridBagConstraints.weighty = 0.5; 375 gridBagConstraints.insets = new java.awt.Insets (0, 11, 0, 0); 376 add(jPnlOptions, gridBagConstraints); 377 378 } 380 private void jLstServicesValueChanged(javax.swing.event.ListSelectionEvent evt) { if(!evt.getValueIsAdjusting()) { 382 WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices.getSelectedValue(); 383 if(entry != null) { 384 updateServiceFeatures(entry); 385 } else { 386 disableServiceFeatures(); 387 } 388 } 389 } 391 private javax.swing.JCheckBox cbDebug; 393 private javax.swing.JCheckBox cbOptimize; 394 private javax.swing.JCheckBox cbPrintStackTrace; 395 private javax.swing.JCheckBox cbSerializable; 396 private javax.swing.JCheckBox cbVerbose; 397 private javax.swing.JCheckBox jChkFeatureA; 398 private javax.swing.JCheckBox jChkFeatureB; 399 private javax.swing.JCheckBox jChkFeatureC; 400 private javax.swing.JCheckBox jChkFeatureD; 401 private javax.swing.JCheckBox jChkFeatureE; 402 private javax.swing.JCheckBox jChkFeatureF; 403 private javax.swing.JCheckBox jChkFeatureG; 404 private javax.swing.JCheckBox jChkFeatureH; 405 private javax.swing.JCheckBox jChkFeatureI; 406 private javax.swing.JCheckBox jChkFeatureJ; 407 private javax.swing.JCheckBox jChkFeatureK; 408 private javax.swing.JCheckBox jChkFeatureL; 409 private javax.swing.JLabel jLblEnabledFeatures; 410 private javax.swing.JLabel jLblError; 411 private javax.swing.JLabel jLblOptions; 412 private javax.swing.JLabel jLblPanelDescription; 413 private javax.swing.JLabel jLblServices; 414 private javax.swing.JList jLstServices; 415 private javax.swing.JPanel jPanel1; 416 private javax.swing.JPanel jPnlFeatureCheckboxes; 417 private javax.swing.JPanel jPnlFeatures; 418 private javax.swing.JPanel jPnlOptions; 419 private javax.swing.JPanel jPnlServices; 420 private javax.swing.JScrollPane jScrollPane1; 421 private javax.swing.JScrollPane jScrollPane2; 422 private javax.swing.JTextArea jTxtEnabledFeatures; 423 425 private void initUserComponents() { 426 updatingDisplay = false; 427 processingCheckBox = false; 428 processingFeatureString = false; 429 430 jLblError.setForeground(ErrorTextForegroundColor); 431 servicesModel = new DefaultListModel (); 432 433 featureCheckboxes = new JCheckBox [MAX_IMPORTANT_FEATURES]; 442 featureCheckboxes[0] = jChkFeatureA; 443 featureCheckboxes[1] = jChkFeatureB; 444 featureCheckboxes[2] = jChkFeatureC; 445 featureCheckboxes[3] = jChkFeatureD; 446 featureCheckboxes[4] = jChkFeatureE; 447 featureCheckboxes[5] = jChkFeatureF; 448 featureCheckboxes[6] = jChkFeatureG; 449 featureCheckboxes[7] = jChkFeatureH; 450 featureCheckboxes[8] = jChkFeatureI; 451 featureCheckboxes[9] = jChkFeatureJ; 452 featureCheckboxes[10] = jChkFeatureK; 453 featureCheckboxes[11] = jChkFeatureL; 454 455 ItemListener checkBoxListener = new ItemListener () { 456 public void itemStateChanged(ItemEvent evt) { 457 if(!processingFeatureString) { 458 JCheckBox source = (JCheckBox ) evt.getSource(); 459 String feature = source.getText(); 460 enableFeature(feature, evt.getStateChange() == ItemEvent.SELECTED); 461 } 462 } 463 }; 464 465 for(int i = 0; i < MAX_IMPORTANT_FEATURES; i++) { 466 featureCheckboxes[i].addItemListener(checkBoxListener); 467 } 468 469 ItemListener optionsListener = new ItemListener () { 470 public void itemStateChanged(ItemEvent evt) { 471 if (!updatingDisplay) { 472 JCheckBox source = (JCheckBox ) evt.getSource(); 473 WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices.getSelectedValue(); 474 boolean[] oldOptions = entry.getOptions(); 475 boolean[] newOptions = new boolean[] { 476 cbVerbose.isSelected(), 477 cbDebug.isSelected(), 478 cbPrintStackTrace.isSelected(), 479 cbSerializable.isSelected(), 480 cbOptimize.isSelected() 481 }; 482 entry.setOptions(newOptions); 483 WsCompileClientEditorSupport.OptionDescriptor oldO = new WsCompileClientEditorSupport.OptionDescriptor(entry.getServiceName(), oldOptions); 484 WsCompileClientEditorSupport.OptionDescriptor newO = new WsCompileClientEditorSupport.OptionDescriptor(entry.getServiceName(), newOptions); 485 firePropertyChange(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED,oldO,newO); 486 } 487 } 488 }; 489 490 cbVerbose.addItemListener(optionsListener); 491 cbDebug.addItemListener(optionsListener); 492 cbPrintStackTrace.addItemListener(optionsListener); 493 cbSerializable.addItemListener(optionsListener); 494 cbOptimize.addItemListener(optionsListener); 495 496 cbVerbose.setToolTipText(NbBundle.getMessage(CustomizerWsCompileClient.class, 497 "DESC_VERBOSE")); 498 cbDebug.setToolTipText(NbBundle.getMessage(CustomizerWsCompileClient.class, 499 "DESC_DEBUGMODEL")); 500 cbPrintStackTrace.setToolTipText(NbBundle.getMessage(CustomizerWsCompileClient.class, 501 "DESC_PRINTSTACKTRACE")); 502 cbSerializable.setToolTipText(NbBundle.getMessage(CustomizerWsCompileClient.class, 503 "DESC_SERIALIZEABLE")); 504 cbOptimize.setToolTipText(NbBundle.getMessage(CustomizerWsCompileClient.class, 505 "DESC_OPTIMIZE")); 506 507 jTxtEnabledFeatures.getDocument().addDocumentListener(new DocumentListener () { 508 public void changedUpdate(DocumentEvent e) { 509 if(!updatingDisplay) { 510 updateFeatureList(e); 511 } 512 } 513 public void insertUpdate(DocumentEvent e) { 514 if(!updatingDisplay) { 515 updateFeatureList(e); 516 } 517 } 518 public void removeUpdate(DocumentEvent e) { 519 if(!updatingDisplay) { 520 updateFeatureList(e); 521 } 522 } 523 }); 524 } 525 526 private void enableFeature(String feature, boolean enable) { 527 boolean modified = false; 528 Set featureSet = featuresAsSet(features); 529 if(enable && !featureSet.contains(feature)) { 530 featureSet.add(feature); 532 modified = true; 533 } else if(!enable && featureSet.contains(feature)) { 534 featureSet.remove(feature); 536 modified = true; 537 } 538 539 if(modified) { 540 try { 541 processingCheckBox = true; 542 String newFeatures = featuresAsString(featureSet); 543 jTxtEnabledFeatures.setText(newFeatures); 544 } finally { 545 processingCheckBox = false; 546 } 547 } 548 } 549 550 private Set featuresAsSet(String featureString) { 551 HashSet set = new HashSet (10); 552 String [] featureList = featureString.split(","); 553 for(int i = 0; i < featureList.length; i++) { 554 String feature = featureList[i].trim(); 555 if(feature != null && feature.length() > 0) { 556 set.add(feature); 557 } 558 } 559 return set; 560 } 561 562 private String featuresAsString(Set featureSet) { 563 StringBuffer featureString = new StringBuffer (featureSet.size()*16); 564 for(Iterator iter = featureSet.iterator(); iter.hasNext(); ) { 565 String feature = (String ) iter.next(); 566 featureString.append(feature); 567 if(iter.hasNext()) { 568 featureString.append(", "); 569 } 570 } 571 return featureString.toString(); 572 } 573 574 private void updateFeatureList(DocumentEvent e) { 575 Document doc = e.getDocument(); 576 String oldFeatures = features; 577 578 try { 579 features = doc.getText(0, doc.getLength()); 580 } catch(BadLocationException ex) { 581 ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, ex); 582 } 583 584 if(!features.equals(oldFeatures)) { 585 WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices.getSelectedValue(); 586 entry.setNewFeatures(features); 587 checkSettings(entry); 588 589 if(!processingCheckBox) { 590 updateCheckBoxes(features); 591 } 592 593 WsCompileClientEditorSupport.FeatureDescriptor oldF = new WsCompileClientEditorSupport.FeatureDescriptor(entry.getServiceName(), oldFeatures); 594 WsCompileClientEditorSupport.FeatureDescriptor newF = new WsCompileClientEditorSupport.FeatureDescriptor(entry.getServiceName(), features); 595 firePropertyChange(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, oldF, newF); 597 } 598 } 599 600 private void updateCheckBoxes(String features) { 601 try { 602 processingFeatureString = true; 603 Set featureSet = featuresAsSet(features); 604 for(int i = 0; i < MAX_IMPORTANT_FEATURES; i++) { 605 String feature = featureCheckboxes[i].getText(); 606 featureCheckboxes[i].setSelected(featureSet.contains(feature)); 607 } 608 } finally { 609 processingFeatureString = false; 610 } 611 } 612 613 private boolean checkSettings(WsCompileClientEditorSupport.ServiceSettings settings) { 614 String message = validateSettings(settings); 615 if(message != null) { 616 jLblError.setText(message); 617 } else { 618 jLblError.setText(" "); 619 } 620 return message != null; 621 } 622 623 private String validateSettings(WsCompileClientEditorSupport.ServiceSettings settings) { 624 String message = null; 626 List availableFeatures = settings.getAvailableFeatures(); 627 String [] featuresList = settings.getNewFeatures().split(","); 628 for(int i = 0; i < featuresList.length; i++) { 629 featuresList[i] = featuresList[i].trim(); 630 if(featuresList[i] != null && featuresList[i].length() > 0 && !availableFeatures.contains(featuresList[i])) { 631 if(masterWsCompileFeatures.contains(featuresList[i])) { 633 message = NbBundle.getMessage(CustomizerWsCompile.class, "ERR_FeatureNotSupported", featuresList[i]); 634 } else { 635 message = NbBundle.getMessage(CustomizerWsCompile.class, "ERR_InvalidFeature", featuresList[i]); 636 } 637 break; 638 } 639 } 640 return message; 641 } 642 643 private void updateServiceFeatures(WsCompileClientEditorSupport.ServiceSettings entry) { 644 try { 645 updatingDisplay = true; 646 enableServiceFeatures(); 647 648 int index = 0; 649 for(Iterator iter = entry.getImportantFeatures().iterator(); iter.hasNext() && index < MAX_IMPORTANT_FEATURES; index++) { 650 String feature = (String ) iter.next(); 651 featureCheckboxes[index].setVisible(true); 652 featureCheckboxes[index].setText(feature); 653 featureCheckboxes[index].setToolTipText(WsCompileFeatures.getFeaturesMap().get(feature)); 654 } 655 656 while(index < MAX_IMPORTANT_FEATURES) { 657 featureCheckboxes[index++].setVisible(false); 658 } 659 660 features = entry.getNewFeatures(); 661 updateCheckBoxes(features); 662 jTxtEnabledFeatures.setText(features); 663 664 checkSettings(entry); 666 667 setOptions(entry); 668 669 } finally { 670 updatingDisplay = false; 671 } 672 } 673 674 private void enableServiceFeatures() { 675 676 } 677 678 private void disableServiceFeatures() { 679 680 } 681 682 private void setOptions(WsCompileClientEditorSupport.ServiceSettings entry) { 683 boolean[] options = entry.getOptions(); 684 cbVerbose.setSelected(options[0]); 685 cbDebug.setSelected(options[1]); 686 cbPrintStackTrace.setSelected(options[2]); 687 cbSerializable.setSelected(options[3]); 688 cbOptimize.setSelected(options[4]); 689 } 690 691 public void addNotify() { 692 super.addNotify(); 693 694 jLstServices.setModel(servicesModel); 695 jLstServices.setSelectedIndex(0); 696 } 697 698 public void removeNotify() { 699 super.removeNotify(); 700 } 701 702 706 public void initValues(List settings) { 707 assert settings.size() > 0; 708 709 jLblServices.setText(NbBundle.getMessage(CustomizerWsCompile.class, "LBL_WebServiceClients")); 711 jLblPanelDescription.setText(NbBundle.getMessage(CustomizerWsCompile.class, "LBL_PanelDescriptionClient")); 712 713 servicesModel.clear(); 715 for(Iterator iter = settings.iterator(); iter.hasNext(); ) { 716 WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) iter.next(); 717 servicesModel.addElement(entry); 718 } 719 } 720 721 public JPanel getComponent() { 722 return this; 723 } 724 725 public void validatePanel() throws org.openide.WizardValidationException { 726 WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices.getSelectedValue(); 728 if(entry != null) { 729 final String message = validateSettings(entry); 730 if(message != null) { 731 throw new WizardValidationException(jTxtEnabledFeatures, message, message); 732 } 733 } 734 } 735 736 public HelpCtx getHelpCtx() { 737 return HelpCtx.DEFAULT_HELP; 738 } 739 740 741 private static final HashSet masterWsCompileFeatures = new HashSet (WsCompileFeatures.getFeaturesMap().keySet()); 742 743 } 744 | Popular Tags |