001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.websvc.jaxrpc.project;
043:
044: import java.util.HashSet;
045: import java.util.Iterator;
046: import java.util.List;
047: import java.util.Set;
048:
049: import java.awt.Color;
050: import java.awt.event.ItemEvent;
051: import java.awt.event.ItemListener;
052:
053: import javax.swing.JCheckBox;
054: import javax.swing.JPanel;
055: import javax.swing.DefaultListModel;
056: import javax.swing.event.DocumentEvent;
057: import javax.swing.event.DocumentListener;
058: import javax.swing.text.Document;
059: import javax.swing.text.BadLocationException;
060: import org.openide.ErrorManager;
061: import org.openide.WizardValidationException;
062: import org.openide.util.HelpCtx;
063: import org.openide.util.NbBundle;
064:
065: import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport;
066:
067: /**
068: *
069: * @author Peter Williams
070: */
071: public class CustomizerWsCompileClient extends javax.swing.JPanel
072: implements WsCompileClientEditorSupport.Panel, HelpCtx.Provider {
073:
074: public static final Color ErrorTextForegroundColor = new Color(89,
075: 79, 191);
076:
077: private static final int MAX_IMPORTANT_FEATURES = 12;
078:
079: private DefaultListModel servicesModel;
080: private JCheckBox[] featureCheckboxes;
081:
082: private String features;
083: private boolean updatingDisplay;
084: private boolean processingCheckBox;
085: private boolean processingFeatureString;
086:
087: public CustomizerWsCompileClient() {
088: initComponents();
089: initUserComponents();
090: }
091:
092: /** This method is called from within the constructor to
093: * initialize the form.
094: * WARNING: Do NOT modify this code. The content of this method is
095: * always regenerated by the Form Editor.
096: */
097: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
098: private void initComponents() {
099: java.awt.GridBagConstraints gridBagConstraints;
100:
101: jPnlServices = new javax.swing.JPanel();
102: jLblServices = new javax.swing.JLabel();
103: jScrollPane1 = new javax.swing.JScrollPane();
104: jLstServices = new javax.swing.JList();
105: jPnlFeatures = new javax.swing.JPanel();
106: jLblPanelDescription = new javax.swing.JLabel();
107: jPnlFeatureCheckboxes = new javax.swing.JPanel();
108: jChkFeatureA = new javax.swing.JCheckBox();
109: jChkFeatureB = new javax.swing.JCheckBox();
110: jChkFeatureC = new javax.swing.JCheckBox();
111: jChkFeatureD = new javax.swing.JCheckBox();
112: jChkFeatureE = new javax.swing.JCheckBox();
113: jChkFeatureF = new javax.swing.JCheckBox();
114: jChkFeatureG = new javax.swing.JCheckBox();
115: jChkFeatureH = new javax.swing.JCheckBox();
116: jChkFeatureI = new javax.swing.JCheckBox();
117: jChkFeatureJ = new javax.swing.JCheckBox();
118: jChkFeatureK = new javax.swing.JCheckBox();
119: jChkFeatureL = new javax.swing.JCheckBox();
120: jLblEnabledFeatures = new javax.swing.JLabel();
121: jScrollPane2 = new javax.swing.JScrollPane();
122: jTxtEnabledFeatures = new javax.swing.JTextArea();
123: jLblError = new javax.swing.JLabel();
124: jPnlOptions = new javax.swing.JPanel();
125: jLblOptions = new javax.swing.JLabel();
126: jPanel1 = new javax.swing.JPanel();
127: cbVerbose = new javax.swing.JCheckBox();
128: cbDebug = new javax.swing.JCheckBox();
129: cbPrintStackTrace = new javax.swing.JCheckBox();
130: cbSerializable = new javax.swing.JCheckBox();
131: cbOptimize = new javax.swing.JCheckBox();
132:
133: setLayout(new java.awt.GridBagLayout());
134:
135: jPnlServices.setLayout(new java.awt.GridBagLayout());
136:
137: jLblServices.setLabelFor(jLstServices);
138: jLblServices.setText(org.openide.util.NbBundle.getMessage(
139: CustomizerWsCompileClient.class,
140: "LBL_WebServiceClients")); // NOI18N
141: gridBagConstraints = new java.awt.GridBagConstraints();
142: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
143: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
144: gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0);
145: jPnlServices.add(jLblServices, gridBagConstraints);
146:
147: jLstServices
148: .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
149: jLstServices
150: .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
151: public void valueChanged(
152: javax.swing.event.ListSelectionEvent evt) {
153: jLstServicesValueChanged(evt);
154: }
155: });
156: jScrollPane1.setViewportView(jLstServices);
157:
158: gridBagConstraints = new java.awt.GridBagConstraints();
159: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
160: gridBagConstraints.weightx = 1.0;
161: gridBagConstraints.weighty = 1.0;
162: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
163: jPnlServices.add(jScrollPane1, gridBagConstraints);
164:
165: gridBagConstraints = new java.awt.GridBagConstraints();
166: gridBagConstraints.gridx = 0;
167: gridBagConstraints.gridy = 0;
168: gridBagConstraints.gridheight = 2;
169: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
170: gridBagConstraints.weightx = 0.5;
171: gridBagConstraints.weighty = 1.0;
172: add(jPnlServices, gridBagConstraints);
173:
174: jPnlFeatures.setLayout(new java.awt.GridBagLayout());
175:
176: org.openide.awt.Mnemonics.setLocalizedText(
177: jLblPanelDescription, NbBundle.getMessage(
178: CustomizerWsCompileClient.class,
179: "LBL_PanelDescriptionService")); // NOI18N
180: gridBagConstraints = new java.awt.GridBagConstraints();
181: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
182: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
183: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
184: jPnlFeatures.add(jLblPanelDescription, gridBagConstraints);
185:
186: jPnlFeatureCheckboxes.setLayout(new java.awt.GridBagLayout());
187:
188: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureA,
189: "Feature A");
190: gridBagConstraints = new java.awt.GridBagConstraints();
191: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
192: gridBagConstraints.weightx = 0.33;
193: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
194: jPnlFeatureCheckboxes.add(jChkFeatureA, gridBagConstraints);
195:
196: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureB,
197: "Feature B");
198: gridBagConstraints = new java.awt.GridBagConstraints();
199: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
200: gridBagConstraints.weightx = 0.33;
201: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
202: jPnlFeatureCheckboxes.add(jChkFeatureB, gridBagConstraints);
203:
204: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureC,
205: "Feature C");
206: gridBagConstraints = new java.awt.GridBagConstraints();
207: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
208: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
209: gridBagConstraints.weightx = 0.33;
210: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
211: jPnlFeatureCheckboxes.add(jChkFeatureC, gridBagConstraints);
212:
213: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureD,
214: "Feature D");
215: gridBagConstraints = new java.awt.GridBagConstraints();
216: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
217: gridBagConstraints.weightx = 0.33;
218: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
219: jPnlFeatureCheckboxes.add(jChkFeatureD, gridBagConstraints);
220:
221: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureE,
222: "Feature E");
223: gridBagConstraints = new java.awt.GridBagConstraints();
224: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
225: gridBagConstraints.weightx = 0.33;
226: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
227: jPnlFeatureCheckboxes.add(jChkFeatureE, gridBagConstraints);
228:
229: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureF,
230: "Feature F");
231: gridBagConstraints = new java.awt.GridBagConstraints();
232: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
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(jChkFeatureF, gridBagConstraints);
237:
238: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureG,
239: "Feature G");
240: gridBagConstraints = new java.awt.GridBagConstraints();
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(jChkFeatureG, gridBagConstraints);
245:
246: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureH,
247: "Feature H");
248: gridBagConstraints = new java.awt.GridBagConstraints();
249: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
250: gridBagConstraints.weightx = 0.33;
251: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
252: jPnlFeatureCheckboxes.add(jChkFeatureH, gridBagConstraints);
253:
254: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureI,
255: "Feature I");
256: gridBagConstraints = new java.awt.GridBagConstraints();
257: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
258: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
259: gridBagConstraints.weightx = 0.33;
260: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
261: jPnlFeatureCheckboxes.add(jChkFeatureI, gridBagConstraints);
262:
263: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureJ,
264: "Feature J");
265: gridBagConstraints = new java.awt.GridBagConstraints();
266: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
267: gridBagConstraints.weightx = 0.33;
268: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
269: jPnlFeatureCheckboxes.add(jChkFeatureJ, gridBagConstraints);
270:
271: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureK,
272: "Feature K");
273: gridBagConstraints = new java.awt.GridBagConstraints();
274: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
275: gridBagConstraints.weightx = 0.33;
276: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
277: jPnlFeatureCheckboxes.add(jChkFeatureK, gridBagConstraints);
278:
279: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureL,
280: "Feature L");
281: gridBagConstraints = new java.awt.GridBagConstraints();
282: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
283: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
284: gridBagConstraints.weightx = 0.33;
285: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
286: jPnlFeatureCheckboxes.add(jChkFeatureL, gridBagConstraints);
287:
288: gridBagConstraints = new java.awt.GridBagConstraints();
289: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
290: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
291: gridBagConstraints.weightx = 1.0;
292: jPnlFeatures.add(jPnlFeatureCheckboxes, gridBagConstraints);
293:
294: jLblEnabledFeatures.setLabelFor(jTxtEnabledFeatures);
295: org.openide.awt.Mnemonics.setLocalizedText(jLblEnabledFeatures,
296: org.openide.util.NbBundle.getMessage(
297: CustomizerWsCompileClient.class,
298: "LBL_EnabledFeatures")); // NOI18N
299: jLblEnabledFeatures.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(0, 0, 2, 11);
304: jPnlFeatures.add(jLblEnabledFeatures, gridBagConstraints);
305:
306: jTxtEnabledFeatures.setLineWrap(true);
307: jTxtEnabledFeatures.setRows(2);
308: jTxtEnabledFeatures.setWrapStyleWord(true);
309: jScrollPane2.setViewportView(jTxtEnabledFeatures);
310:
311: gridBagConstraints = new java.awt.GridBagConstraints();
312: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
313: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
314: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
315: gridBagConstraints.weightx = 1.0;
316: gridBagConstraints.weighty = 1.0;
317: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
318: jPnlFeatures.add(jScrollPane2, gridBagConstraints);
319:
320: gridBagConstraints = new java.awt.GridBagConstraints();
321: gridBagConstraints.gridx = 1;
322: gridBagConstraints.gridy = 0;
323: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
324: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
325: gridBagConstraints.weightx = 0.5;
326: gridBagConstraints.weighty = 0.5;
327: gridBagConstraints.insets = new java.awt.Insets(0, 11, 0, 0);
328: add(jPnlFeatures, gridBagConstraints);
329:
330: org.openide.awt.Mnemonics.setLocalizedText(jLblError, " ");
331: gridBagConstraints = new java.awt.GridBagConstraints();
332: gridBagConstraints.gridx = 0;
333: gridBagConstraints.gridy = 2;
334: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
335: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
336: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
337: gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
338: add(jLblError, gridBagConstraints);
339:
340: jPnlOptions.setLayout(new java.awt.GridBagLayout());
341:
342: jLblOptions.setLabelFor(jTxtEnabledFeatures);
343: org.openide.awt.Mnemonics.setLocalizedText(jLblOptions,
344: org.openide.util.NbBundle.getMessage(
345: CustomizerWsCompileClient.class,
346: "LBL_AdditionalOptions")); // NOI18N
347: jLblOptions.setOpaque(true);
348: gridBagConstraints = new java.awt.GridBagConstraints();
349: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
350: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
351: gridBagConstraints.insets = new java.awt.Insets(11, 0, 10, 0);
352: jPnlOptions.add(jLblOptions, gridBagConstraints);
353:
354: jPanel1.setLayout(new java.awt.GridBagLayout());
355:
356: org.openide.awt.Mnemonics
357: .setLocalizedText(cbVerbose, org.openide.util.NbBundle
358: .getMessage(CustomizerWsCompileClient.class,
359: "LBL_verbose")); // NOI18N
360: cbVerbose.setBorder(javax.swing.BorderFactory
361: .createEmptyBorder(0, 0, 0, 0));
362: cbVerbose.setMargin(new java.awt.Insets(0, 0, 0, 0));
363: gridBagConstraints = new java.awt.GridBagConstraints();
364: gridBagConstraints.gridx = 0;
365: gridBagConstraints.gridy = 0;
366: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
367: gridBagConstraints.weightx = 0.33;
368: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
369: jPanel1.add(cbVerbose, gridBagConstraints);
370:
371: org.openide.awt.Mnemonics.setLocalizedText(cbDebug,
372: org.openide.util.NbBundle.getMessage(
373: CustomizerWsCompileClient.class, "LBL_debug")); // NOI18N
374: cbDebug.setBorder(javax.swing.BorderFactory.createEmptyBorder(
375: 0, 0, 0, 0));
376: cbDebug.setMargin(new java.awt.Insets(0, 0, 0, 0));
377: gridBagConstraints = new java.awt.GridBagConstraints();
378: gridBagConstraints.gridx = 1;
379: gridBagConstraints.gridy = 0;
380: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
381: gridBagConstraints.weightx = 0.33;
382: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
383: jPanel1.add(cbDebug, gridBagConstraints);
384:
385: org.openide.awt.Mnemonics.setLocalizedText(cbPrintStackTrace,
386: org.openide.util.NbBundle.getMessage(
387: CustomizerWsCompileClient.class,
388: "LBL_xPrintStackTrace")); // NOI18N
389: cbPrintStackTrace.setBorder(javax.swing.BorderFactory
390: .createEmptyBorder(0, 0, 0, 0));
391: cbPrintStackTrace.setMargin(new java.awt.Insets(0, 0, 0, 0));
392: gridBagConstraints = new java.awt.GridBagConstraints();
393: gridBagConstraints.gridx = 2;
394: gridBagConstraints.gridy = 0;
395: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
396: gridBagConstraints.weightx = 0.33;
397: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
398: jPanel1.add(cbPrintStackTrace, gridBagConstraints);
399:
400: org.openide.awt.Mnemonics.setLocalizedText(cbSerializable,
401: org.openide.util.NbBundle.getMessage(
402: CustomizerWsCompileClient.class,
403: "LBL_xSerializable")); // NOI18N
404: cbSerializable.setBorder(javax.swing.BorderFactory
405: .createEmptyBorder(0, 0, 0, 0));
406: cbSerializable.setMargin(new java.awt.Insets(0, 0, 0, 0));
407: gridBagConstraints = new java.awt.GridBagConstraints();
408: gridBagConstraints.gridx = 0;
409: gridBagConstraints.gridy = 1;
410: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
411: gridBagConstraints.weightx = 0.33;
412: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
413: jPanel1.add(cbSerializable, gridBagConstraints);
414:
415: org.openide.awt.Mnemonics.setLocalizedText(cbOptimize,
416: org.openide.util.NbBundle
417: .getMessage(CustomizerWsCompileClient.class,
418: "LBL_optimize")); // NOI18N
419: cbOptimize.setBorder(javax.swing.BorderFactory
420: .createEmptyBorder(0, 0, 0, 0));
421: cbOptimize.setMargin(new java.awt.Insets(0, 0, 0, 0));
422: gridBagConstraints = new java.awt.GridBagConstraints();
423: gridBagConstraints.gridx = 1;
424: gridBagConstraints.gridy = 1;
425: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
426: gridBagConstraints.weightx = 0.33;
427: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
428: jPanel1.add(cbOptimize, gridBagConstraints);
429:
430: gridBagConstraints = new java.awt.GridBagConstraints();
431: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
432: gridBagConstraints.weightx = 1.0;
433: jPnlOptions.add(jPanel1, gridBagConstraints);
434:
435: gridBagConstraints = new java.awt.GridBagConstraints();
436: gridBagConstraints.gridx = 1;
437: gridBagConstraints.gridy = 1;
438: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
439: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
440: gridBagConstraints.weightx = 0.5;
441: gridBagConstraints.weighty = 0.5;
442: gridBagConstraints.insets = new java.awt.Insets(0, 11, 0, 0);
443: add(jPnlOptions, gridBagConstraints);
444: }// </editor-fold>//GEN-END:initComponents
445:
446: private void jLstServicesValueChanged(
447: javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jLstServicesValueChanged
448: if (!evt.getValueIsAdjusting()) {
449: WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices
450: .getSelectedValue();
451: if (entry != null) {
452: updateServiceFeatures(entry);
453: } else {
454: disableServiceFeatures();
455: }
456: }
457: }//GEN-LAST:event_jLstServicesValueChanged
458:
459: // Variables declaration - do not modify//GEN-BEGIN:variables
460: private javax.swing.JCheckBox cbDebug;
461: private javax.swing.JCheckBox cbOptimize;
462: private javax.swing.JCheckBox cbPrintStackTrace;
463: private javax.swing.JCheckBox cbSerializable;
464: private javax.swing.JCheckBox cbVerbose;
465: private javax.swing.JCheckBox jChkFeatureA;
466: private javax.swing.JCheckBox jChkFeatureB;
467: private javax.swing.JCheckBox jChkFeatureC;
468: private javax.swing.JCheckBox jChkFeatureD;
469: private javax.swing.JCheckBox jChkFeatureE;
470: private javax.swing.JCheckBox jChkFeatureF;
471: private javax.swing.JCheckBox jChkFeatureG;
472: private javax.swing.JCheckBox jChkFeatureH;
473: private javax.swing.JCheckBox jChkFeatureI;
474: private javax.swing.JCheckBox jChkFeatureJ;
475: private javax.swing.JCheckBox jChkFeatureK;
476: private javax.swing.JCheckBox jChkFeatureL;
477: private javax.swing.JLabel jLblEnabledFeatures;
478: private javax.swing.JLabel jLblError;
479: private javax.swing.JLabel jLblOptions;
480: private javax.swing.JLabel jLblPanelDescription;
481: private javax.swing.JLabel jLblServices;
482: private javax.swing.JList jLstServices;
483: private javax.swing.JPanel jPanel1;
484: private javax.swing.JPanel jPnlFeatureCheckboxes;
485: private javax.swing.JPanel jPnlFeatures;
486: private javax.swing.JPanel jPnlOptions;
487: private javax.swing.JPanel jPnlServices;
488: private javax.swing.JScrollPane jScrollPane1;
489: private javax.swing.JScrollPane jScrollPane2;
490: private javax.swing.JTextArea jTxtEnabledFeatures;
491:
492: // End of variables declaration//GEN-END:variables
493:
494: private void initUserComponents() {
495: updatingDisplay = false;
496: processingCheckBox = false;
497: processingFeatureString = false;
498:
499: jLblError.setForeground(ErrorTextForegroundColor);
500: servicesModel = new DefaultListModel();
501:
502: // !PW Rework this entire pattern for 5.0, including better API for specifying
503: // radio buttons vs. checkboxes for competing options (e.g. rpcliteral
504: // vs. documentliteral, unwrap vs. donotunwrap, etc.
505: //
506: // Could provide nested panel for each supported "service/client" type,
507: // e.g. service from SEI, service from WSDL, and web service client.
508: // J2ME might also have preferences here.
509: //
510: featureCheckboxes = new JCheckBox[MAX_IMPORTANT_FEATURES];
511: featureCheckboxes[0] = jChkFeatureA;
512: featureCheckboxes[1] = jChkFeatureB;
513: featureCheckboxes[2] = jChkFeatureC;
514: featureCheckboxes[3] = jChkFeatureD;
515: featureCheckboxes[4] = jChkFeatureE;
516: featureCheckboxes[5] = jChkFeatureF;
517: featureCheckboxes[6] = jChkFeatureG;
518: featureCheckboxes[7] = jChkFeatureH;
519: featureCheckboxes[8] = jChkFeatureI;
520: featureCheckboxes[9] = jChkFeatureJ;
521: featureCheckboxes[10] = jChkFeatureK;
522: featureCheckboxes[11] = jChkFeatureL;
523:
524: ItemListener checkBoxListener = new ItemListener() {
525: public void itemStateChanged(ItemEvent evt) {
526: if (!processingFeatureString) {
527: JCheckBox source = (JCheckBox) evt.getSource();
528: String feature = source.getText();
529: enableFeature(feature,
530: evt.getStateChange() == ItemEvent.SELECTED);
531: }
532: }
533: };
534:
535: for (int i = 0; i < MAX_IMPORTANT_FEATURES; i++) {
536: featureCheckboxes[i].addItemListener(checkBoxListener);
537: }
538:
539: ItemListener optionsListener = new ItemListener() {
540: public void itemStateChanged(ItemEvent evt) {
541: if (!updatingDisplay) {
542: JCheckBox source = (JCheckBox) evt.getSource();
543: WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices
544: .getSelectedValue();
545: boolean[] oldOptions = entry.getOptions();
546: boolean[] newOptions = new boolean[] {
547: cbVerbose.isSelected(),
548: cbDebug.isSelected(),
549: cbPrintStackTrace.isSelected(),
550: cbSerializable.isSelected(),
551: cbOptimize.isSelected() };
552: entry.setOptions(newOptions);
553: WsCompileClientEditorSupport.OptionDescriptor oldO = new WsCompileClientEditorSupport.OptionDescriptor(
554: entry.getServiceName(), oldOptions);
555: WsCompileClientEditorSupport.OptionDescriptor newO = new WsCompileClientEditorSupport.OptionDescriptor(
556: entry.getServiceName(), newOptions);
557: firePropertyChange(
558: WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED,
559: oldO, newO);
560: }
561: }
562: };
563:
564: cbVerbose.addItemListener(optionsListener);
565: cbDebug.addItemListener(optionsListener);
566: cbPrintStackTrace.addItemListener(optionsListener);
567: cbSerializable.addItemListener(optionsListener);
568: cbOptimize.addItemListener(optionsListener);
569:
570: cbVerbose.setToolTipText(NbBundle.getMessage(
571: CustomizerWsCompileClient.class, "DESC_VERBOSE"));
572: cbDebug.setToolTipText(NbBundle.getMessage(
573: CustomizerWsCompileClient.class, "DESC_DEBUGMODEL"));
574: cbPrintStackTrace.setToolTipText(NbBundle
575: .getMessage(CustomizerWsCompileClient.class,
576: "DESC_PRINTSTACKTRACE"));
577: cbSerializable.setToolTipText(NbBundle.getMessage(
578: CustomizerWsCompileClient.class, "DESC_SERIALIZEABLE"));
579: cbOptimize.setToolTipText(NbBundle.getMessage(
580: CustomizerWsCompileClient.class, "DESC_OPTIMIZE"));
581:
582: jTxtEnabledFeatures.getDocument().addDocumentListener(
583: new DocumentListener() {
584: public void changedUpdate(DocumentEvent e) {
585: if (!updatingDisplay) {
586: updateFeatureList(e);
587: }
588: }
589:
590: public void insertUpdate(DocumentEvent e) {
591: if (!updatingDisplay) {
592: updateFeatureList(e);
593: }
594: }
595:
596: public void removeUpdate(DocumentEvent e) {
597: if (!updatingDisplay) {
598: updateFeatureList(e);
599: }
600: }
601: });
602: }
603:
604: private void enableFeature(String feature, boolean enable) {
605: boolean modified = false;
606: Set featureSet = featuresAsSet(features);
607: if (enable && !featureSet.contains(feature)) {
608: // System.out.println("adding feature '" + feature + "'");
609: featureSet.add(feature);
610: modified = true;
611: } else if (!enable && featureSet.contains(feature)) {
612: // System.out.println("removing feature '" + feature + "'");
613: featureSet.remove(feature);
614: modified = true;
615: }
616:
617: if (modified) {
618: try {
619: processingCheckBox = true;
620: String newFeatures = featuresAsString(featureSet);
621: jTxtEnabledFeatures.setText(newFeatures);
622: } finally {
623: processingCheckBox = false;
624: }
625: }
626: }
627:
628: private Set featuresAsSet(String featureString) {
629: HashSet set = new HashSet(10);
630: String[] featureList = featureString.split(",");
631: for (int i = 0; i < featureList.length; i++) {
632: String feature = featureList[i].trim();
633: if (feature != null && feature.length() > 0) {
634: set.add(feature);
635: }
636: }
637: return set;
638: }
639:
640: private String featuresAsString(Set featureSet) {
641: StringBuffer featureString = new StringBuffer(
642: featureSet.size() * 16);
643: for (Iterator iter = featureSet.iterator(); iter.hasNext();) {
644: String feature = (String) iter.next();
645: featureString.append(feature);
646: if (iter.hasNext()) {
647: featureString.append(", ");
648: }
649: }
650: return featureString.toString();
651: }
652:
653: private void updateFeatureList(DocumentEvent e) {
654: Document doc = e.getDocument();
655: String oldFeatures = features;
656:
657: try {
658: features = doc.getText(0, doc.getLength());
659: } catch (BadLocationException ex) {
660: ErrorManager.getDefault()
661: .notify(ErrorManager.EXCEPTION, ex);
662: }
663:
664: if (!features.equals(oldFeatures)) {
665: WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices
666: .getSelectedValue();
667: entry.setNewFeatures(features);
668: checkSettings(entry);
669:
670: if (!processingCheckBox) {
671: updateCheckBoxes(features);
672: }
673:
674: WsCompileClientEditorSupport.FeatureDescriptor oldF = new WsCompileClientEditorSupport.FeatureDescriptor(
675: entry.getServiceName(), oldFeatures);
676: WsCompileClientEditorSupport.FeatureDescriptor newF = new WsCompileClientEditorSupport.FeatureDescriptor(
677: entry.getServiceName(), features);
678: // System.out.println("feature list changed (" + newF.getServiceName() + ", [" + newF.getFeatures() + "])");
679: firePropertyChange(
680: WsCompileClientEditorSupport.PROP_FEATURES_CHANGED,
681: oldF, newF);
682: }
683: }
684:
685: private void updateCheckBoxes(String features) {
686: try {
687: processingFeatureString = true;
688: Set featureSet = featuresAsSet(features);
689: for (int i = 0; i < MAX_IMPORTANT_FEATURES; i++) {
690: String feature = featureCheckboxes[i].getText();
691: featureCheckboxes[i].setSelected(featureSet
692: .contains(feature));
693: }
694: } finally {
695: processingFeatureString = false;
696: }
697: }
698:
699: private boolean checkSettings(
700: WsCompileClientEditorSupport.ServiceSettings settings) {
701: String message = validateSettings(settings);
702: if (message != null) {
703: jLblError.setText(message);
704: } else {
705: jLblError.setText(" ");
706: }
707: return message != null;
708: }
709:
710: private String validateSettings(
711: WsCompileClientEditorSupport.ServiceSettings settings) {
712: // really just validate the feature string
713: String message = null;
714: List availableFeatures = settings.getAvailableFeatures();
715: String[] featuresList = settings.getNewFeatures().split(",");
716: for (int i = 0; i < featuresList.length; i++) {
717: featuresList[i] = featuresList[i].trim();
718: if (featuresList[i] != null && featuresList[i].length() > 0
719: && !availableFeatures.contains(featuresList[i])) {
720: // Feature not in available list - either invalid, or out of context, determine which:
721: if (masterWsCompileFeatures.contains(featuresList[i])) {
722: message = NbBundle.getMessage(
723: CustomizerWsCompile.class,
724: "ERR_FeatureNotSupported", featuresList[i]);
725: } else {
726: message = NbBundle.getMessage(
727: CustomizerWsCompile.class,
728: "ERR_InvalidFeature", featuresList[i]);
729: }
730: break;
731: }
732: }
733: return message;
734: }
735:
736: private void updateServiceFeatures(
737: WsCompileClientEditorSupport.ServiceSettings entry) {
738: try {
739: updatingDisplay = true;
740: enableServiceFeatures();
741:
742: int index = 0;
743: for (Iterator iter = entry.getImportantFeatures()
744: .iterator(); iter.hasNext()
745: && index < MAX_IMPORTANT_FEATURES; index++) {
746: String feature = (String) iter.next();
747: featureCheckboxes[index].setVisible(true);
748: featureCheckboxes[index].setText(feature);
749: featureCheckboxes[index]
750: .setToolTipText(WsCompileFeatures
751: .getFeaturesMap().get(feature));
752: }
753:
754: while (index < MAX_IMPORTANT_FEATURES) {
755: featureCheckboxes[index++].setVisible(false);
756: }
757:
758: features = entry.getNewFeatures();
759: updateCheckBoxes(features);
760: jTxtEnabledFeatures.setText(features);
761:
762: // If there is an existing error, proactively display it.
763: checkSettings(entry);
764:
765: setOptions(entry);
766:
767: } finally {
768: updatingDisplay = false;
769: }
770: }
771:
772: private void enableServiceFeatures() {
773:
774: }
775:
776: private void disableServiceFeatures() {
777:
778: }
779:
780: private void setOptions(
781: WsCompileClientEditorSupport.ServiceSettings entry) {
782: boolean[] options = entry.getOptions();
783: cbVerbose.setSelected(options[0]);
784: cbDebug.setSelected(options[1]);
785: cbPrintStackTrace.setSelected(options[2]);
786: cbSerializable.setSelected(options[3]);
787: cbOptimize.setSelected(options[4]);
788: }
789:
790: public void addNotify() {
791: super .addNotify();
792:
793: jLstServices.setModel(servicesModel);
794: jLstServices.setSelectedIndex(0);
795: }
796:
797: public void removeNotify() {
798: super .removeNotify();
799: }
800:
801: //
802: // WsCompileEditorSupport.Panel implementation
803: //
804:
805: public void initValues(List/*ServiceSettings*/settings) {
806: assert settings.size() > 0;
807:
808: // Set UI (or other fields) that are service or client specific.
809: jLblServices.setText(NbBundle.getMessage(
810: CustomizerWsCompile.class, "LBL_WebServiceClients"));
811: jLblPanelDescription.setText(NbBundle
812: .getMessage(CustomizerWsCompile.class,
813: "LBL_PanelDescriptionClient"));
814:
815: // Load list of services (or clients) that are being configured.
816: servicesModel.clear();
817: for (Iterator iter = settings.iterator(); iter.hasNext();) {
818: WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) iter
819: .next();
820: servicesModel.addElement(entry);
821: }
822: }
823:
824: public JPanel getComponent() {
825: return this ;
826: }
827:
828: public void validatePanel()
829: throws org.openide.WizardValidationException {
830: // !PW FIXME do we want to iterate all services and validate all of them here?
831: WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices
832: .getSelectedValue();
833: if (entry != null) {
834: final String message = validateSettings(entry);
835: if (message != null) {
836: throw new WizardValidationException(
837: jTxtEnabledFeatures, message, message);
838: }
839: }
840: }
841:
842: public HelpCtx getHelpCtx() {
843: return HelpCtx.DEFAULT_HELP;
844: }
845:
846: private static final HashSet masterWsCompileFeatures = new HashSet(
847: WsCompileFeatures.getFeaturesMap().keySet());
848:
849: }
|