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.Arrays;
045: import java.util.HashSet;
046: import java.util.Iterator;
047: import java.util.List;
048: import java.util.Set;
049:
050: import java.awt.Color;
051: import java.awt.event.ItemEvent;
052: import java.awt.event.ItemListener;
053: import java.util.HashMap;
054: import java.util.Map;
055:
056: import javax.swing.JCheckBox;
057: import javax.swing.JPanel;
058: import javax.swing.DefaultListModel;
059: import javax.swing.event.DocumentEvent;
060: import javax.swing.event.DocumentListener;
061: import javax.swing.text.Document;
062: import javax.swing.text.BadLocationException;
063: import org.netbeans.modules.websvc.api.webservices.WsCompileEditorSupport;
064: import org.openide.ErrorManager;
065: import org.openide.WizardValidationException;
066: import org.openide.util.HelpCtx;
067: import org.openide.util.NbBundle;
068:
069: /**
070: *
071: * @author Peter Williams
072: */
073: public class CustomizerWsCompile extends javax.swing.JPanel implements
074: WsCompileEditorSupport.Panel, HelpCtx.Provider {
075:
076: public static final Color ErrorTextForegroundColor = new Color(89,
077: 79, 191);
078:
079: private static final int MAX_IMPORTANT_FEATURES = 12;
080:
081: private DefaultListModel servicesModel;
082: private JCheckBox[] featureCheckboxes;
083:
084: private int serviceType;
085: private String features;
086: private boolean updatingDisplay;
087: private boolean processingCheckBox;
088: private boolean processingFeatureString;
089:
090: public CustomizerWsCompile() {
091: initComponents();
092: initUserComponents();
093: }
094:
095: /** This method is called from within the constructor to
096: * initialize the form.
097: * WARNING: Do NOT modify this code. The content of this method is
098: * always regenerated by the Form Editor.
099: */
100: // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
101: private void initComponents() {
102: java.awt.GridBagConstraints gridBagConstraints;
103:
104: jPnlServices = new javax.swing.JPanel();
105: jLblServices = new javax.swing.JLabel();
106: jScrollPane1 = new javax.swing.JScrollPane();
107: jLstServices = new javax.swing.JList();
108: jPnlFeatures = new javax.swing.JPanel();
109: jLblPanelDescription = new javax.swing.JLabel();
110: jPnlOptions = new javax.swing.JPanel();
111: jChkFeatureA = new javax.swing.JCheckBox();
112: jChkFeatureB = new javax.swing.JCheckBox();
113: jChkFeatureC = new javax.swing.JCheckBox();
114: jChkFeatureD = new javax.swing.JCheckBox();
115: jChkFeatureE = new javax.swing.JCheckBox();
116: jChkFeatureF = new javax.swing.JCheckBox();
117: jChkFeatureG = new javax.swing.JCheckBox();
118: jChkFeatureH = new javax.swing.JCheckBox();
119: jChkFeatureI = new javax.swing.JCheckBox();
120: jChkFeatureJ = new javax.swing.JCheckBox();
121: jChkFeatureK = new javax.swing.JCheckBox();
122: jChkFeatureL = new javax.swing.JCheckBox();
123: jLblEnabledFeatures = new javax.swing.JLabel();
124: jScrollPane2 = new javax.swing.JScrollPane();
125: jTxtEnabledFeatures = new javax.swing.JTextArea();
126: jLblError = new javax.swing.JLabel();
127:
128: setLayout(new java.awt.GridBagLayout());
129:
130: jPnlServices.setLayout(new java.awt.GridBagLayout());
131:
132: jLblServices.setLabelFor(jLstServices);
133: jLblServices.setText(org.openide.util.NbBundle.getMessage(
134: CustomizerWsCompile.class, "LBL_WebServices")); // NOI18N
135: gridBagConstraints = new java.awt.GridBagConstraints();
136: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
137: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
138: gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 0);
139: jPnlServices.add(jLblServices, gridBagConstraints);
140:
141: jLstServices
142: .setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
143: jLstServices
144: .addListSelectionListener(new javax.swing.event.ListSelectionListener() {
145: public void valueChanged(
146: javax.swing.event.ListSelectionEvent evt) {
147: jLstServicesValueChanged(evt);
148: }
149: });
150: jScrollPane1.setViewportView(jLstServices);
151:
152: gridBagConstraints = new java.awt.GridBagConstraints();
153: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
154: gridBagConstraints.weightx = 1.0;
155: gridBagConstraints.weighty = 1.0;
156: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
157: jPnlServices.add(jScrollPane1, gridBagConstraints);
158:
159: gridBagConstraints = new java.awt.GridBagConstraints();
160: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
161: gridBagConstraints.weightx = 0.5;
162: gridBagConstraints.weighty = 1.0;
163: add(jPnlServices, gridBagConstraints);
164:
165: jPnlFeatures.setLayout(new java.awt.GridBagLayout());
166:
167: org.openide.awt.Mnemonics.setLocalizedText(
168: jLblPanelDescription, NbBundle.getMessage(
169: CustomizerWsCompile.class,
170: "LBL_PanelDescriptionService")); // NOI18N
171: gridBagConstraints = new java.awt.GridBagConstraints();
172: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
173: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
174: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
175: jPnlFeatures.add(jLblPanelDescription, gridBagConstraints);
176:
177: jPnlOptions.setLayout(new java.awt.GridBagLayout());
178:
179: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureA,
180: "Feature A");
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: jPnlOptions.add(jChkFeatureA, gridBagConstraints);
186:
187: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureB,
188: "Feature B");
189: gridBagConstraints = new java.awt.GridBagConstraints();
190: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
191: gridBagConstraints.weightx = 0.33;
192: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
193: jPnlOptions.add(jChkFeatureB, gridBagConstraints);
194:
195: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureC,
196: "Feature C");
197: gridBagConstraints = new java.awt.GridBagConstraints();
198: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
199: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
200: gridBagConstraints.weightx = 0.33;
201: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
202: jPnlOptions.add(jChkFeatureC, gridBagConstraints);
203:
204: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureD,
205: "Feature D");
206: gridBagConstraints = new java.awt.GridBagConstraints();
207: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
208: gridBagConstraints.weightx = 0.33;
209: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
210: jPnlOptions.add(jChkFeatureD, gridBagConstraints);
211:
212: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureE,
213: "Feature E");
214: gridBagConstraints = new java.awt.GridBagConstraints();
215: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
216: gridBagConstraints.weightx = 0.33;
217: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
218: jPnlOptions.add(jChkFeatureE, gridBagConstraints);
219:
220: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureF,
221: "Feature F");
222: gridBagConstraints = new java.awt.GridBagConstraints();
223: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
224: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
225: gridBagConstraints.weightx = 0.33;
226: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
227: jPnlOptions.add(jChkFeatureF, gridBagConstraints);
228:
229: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureG,
230: "Feature G");
231: gridBagConstraints = new java.awt.GridBagConstraints();
232: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
233: gridBagConstraints.weightx = 0.33;
234: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
235: jPnlOptions.add(jChkFeatureG, gridBagConstraints);
236:
237: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureH,
238: "Feature H");
239: gridBagConstraints = new java.awt.GridBagConstraints();
240: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
241: gridBagConstraints.weightx = 0.33;
242: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
243: jPnlOptions.add(jChkFeatureH, gridBagConstraints);
244:
245: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureI,
246: "Feature I");
247: gridBagConstraints = new java.awt.GridBagConstraints();
248: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
249: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
250: gridBagConstraints.weightx = 0.33;
251: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
252: jPnlOptions.add(jChkFeatureI, gridBagConstraints);
253:
254: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureJ,
255: "Feature J");
256: gridBagConstraints = new java.awt.GridBagConstraints();
257: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
258: gridBagConstraints.weightx = 0.33;
259: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
260: jPnlOptions.add(jChkFeatureJ, gridBagConstraints);
261:
262: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureK,
263: "Feature K");
264: gridBagConstraints = new java.awt.GridBagConstraints();
265: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
266: gridBagConstraints.weightx = 0.33;
267: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
268: jPnlOptions.add(jChkFeatureK, gridBagConstraints);
269:
270: org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureL,
271: "Feature L");
272: gridBagConstraints = new java.awt.GridBagConstraints();
273: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
274: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
275: gridBagConstraints.weightx = 0.33;
276: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 11);
277: jPnlOptions.add(jChkFeatureL, gridBagConstraints);
278:
279: gridBagConstraints = new java.awt.GridBagConstraints();
280: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
281: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
282: gridBagConstraints.weightx = 1.0;
283: jPnlFeatures.add(jPnlOptions, gridBagConstraints);
284:
285: jLblEnabledFeatures.setLabelFor(jTxtEnabledFeatures);
286: org.openide.awt.Mnemonics.setLocalizedText(jLblEnabledFeatures,
287: org.openide.util.NbBundle.getMessage(
288: CustomizerWsCompile.class,
289: "LBL_EnabledFeatures")); // NOI18N
290: jLblEnabledFeatures.setOpaque(true);
291: gridBagConstraints = new java.awt.GridBagConstraints();
292: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
293: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
294: gridBagConstraints.insets = new java.awt.Insets(0, 0, 2, 11);
295: jPnlFeatures.add(jLblEnabledFeatures, gridBagConstraints);
296:
297: jTxtEnabledFeatures.setLineWrap(true);
298: jTxtEnabledFeatures.setRows(3);
299: jTxtEnabledFeatures.setWrapStyleWord(true);
300: jScrollPane2.setViewportView(jTxtEnabledFeatures);
301:
302: gridBagConstraints = new java.awt.GridBagConstraints();
303: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
304: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
305: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
306: gridBagConstraints.weightx = 1.0;
307: gridBagConstraints.weighty = 1.0;
308: gridBagConstraints.insets = new java.awt.Insets(0, 0, 11, 0);
309: jPnlFeatures.add(jScrollPane2, gridBagConstraints);
310:
311: gridBagConstraints = new java.awt.GridBagConstraints();
312: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
313: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
314: gridBagConstraints.weightx = 0.5;
315: gridBagConstraints.weighty = 1.0;
316: gridBagConstraints.insets = new java.awt.Insets(0, 11, 0, 0);
317: add(jPnlFeatures, gridBagConstraints);
318:
319: org.openide.awt.Mnemonics.setLocalizedText(jLblError, " ");
320: gridBagConstraints = new java.awt.GridBagConstraints();
321: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
322: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
323: gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
324: gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 0);
325: add(jLblError, gridBagConstraints);
326: }// </editor-fold>//GEN-END:initComponents
327:
328: private void jLstServicesValueChanged(
329: javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jLstServicesValueChanged
330: if (!evt.getValueIsAdjusting()) {
331: WsCompileEditorSupport.ServiceSettings entry = (WsCompileEditorSupport.ServiceSettings) jLstServices
332: .getSelectedValue();
333: if (entry != null) {
334: updateServiceFeatures(entry);
335: } else {
336: disableServiceFeatures();
337: }
338: }
339: }//GEN-LAST:event_jLstServicesValueChanged
340:
341: // Variables declaration - do not modify//GEN-BEGIN:variables
342: private javax.swing.JCheckBox jChkFeatureA;
343: private javax.swing.JCheckBox jChkFeatureB;
344: private javax.swing.JCheckBox jChkFeatureC;
345: private javax.swing.JCheckBox jChkFeatureD;
346: private javax.swing.JCheckBox jChkFeatureE;
347: private javax.swing.JCheckBox jChkFeatureF;
348: private javax.swing.JCheckBox jChkFeatureG;
349: private javax.swing.JCheckBox jChkFeatureH;
350: private javax.swing.JCheckBox jChkFeatureI;
351: private javax.swing.JCheckBox jChkFeatureJ;
352: private javax.swing.JCheckBox jChkFeatureK;
353: private javax.swing.JCheckBox jChkFeatureL;
354: private javax.swing.JLabel jLblEnabledFeatures;
355: private javax.swing.JLabel jLblError;
356: private javax.swing.JLabel jLblPanelDescription;
357: private javax.swing.JLabel jLblServices;
358: private javax.swing.JList jLstServices;
359: private javax.swing.JPanel jPnlFeatures;
360: private javax.swing.JPanel jPnlOptions;
361: private javax.swing.JPanel jPnlServices;
362: private javax.swing.JScrollPane jScrollPane1;
363: private javax.swing.JScrollPane jScrollPane2;
364: private javax.swing.JTextArea jTxtEnabledFeatures;
365:
366: // End of variables declaration//GEN-END:variables
367:
368: private void initUserComponents() {
369: updatingDisplay = false;
370: processingCheckBox = false;
371: processingFeatureString = false;
372:
373: jLblError.setForeground(ErrorTextForegroundColor);
374: servicesModel = new DefaultListModel();
375:
376: // !PW Rework this entire pattern for 5.0, including better API for specifying
377: // radio buttons vs. checkboxes for competing options (e.g. rpcliteral
378: // vs. documentliteral, unwrap vs. donotunwrap, etc.
379: //
380: // Could provide nested panel for each supported "service/client" type,
381: // e.g. service from SEI, service from WSDL, and web service client.
382: // J2ME might also have preferences here.
383: //
384: featureCheckboxes = new JCheckBox[MAX_IMPORTANT_FEATURES];
385: featureCheckboxes[0] = jChkFeatureA;
386: featureCheckboxes[1] = jChkFeatureB;
387: featureCheckboxes[2] = jChkFeatureC;
388: featureCheckboxes[3] = jChkFeatureD;
389: featureCheckboxes[4] = jChkFeatureE;
390: featureCheckboxes[5] = jChkFeatureF;
391: featureCheckboxes[6] = jChkFeatureG;
392: featureCheckboxes[7] = jChkFeatureH;
393: featureCheckboxes[8] = jChkFeatureI;
394: featureCheckboxes[9] = jChkFeatureJ;
395: featureCheckboxes[10] = jChkFeatureK;
396: featureCheckboxes[11] = jChkFeatureL;
397:
398: ItemListener checkBoxListener = new ItemListener() {
399: public void itemStateChanged(ItemEvent evt) {
400: if (!processingFeatureString) {
401: JCheckBox source = (JCheckBox) evt.getSource();
402: String feature = source.getText();
403: enableFeature(feature,
404: evt.getStateChange() == ItemEvent.SELECTED);
405: }
406: }
407: };
408:
409: for (int i = 0; i < MAX_IMPORTANT_FEATURES; i++) {
410: featureCheckboxes[i].addItemListener(checkBoxListener);
411: }
412:
413: jTxtEnabledFeatures.getDocument().addDocumentListener(
414: new DocumentListener() {
415: public void changedUpdate(DocumentEvent e) {
416: if (!updatingDisplay) {
417: updateFeatureList(e);
418: }
419: }
420:
421: public void insertUpdate(DocumentEvent e) {
422: if (!updatingDisplay) {
423: updateFeatureList(e);
424: }
425: }
426:
427: public void removeUpdate(DocumentEvent e) {
428: if (!updatingDisplay) {
429: updateFeatureList(e);
430: }
431: }
432: });
433: }
434:
435: private void enableFeature(String feature, boolean enable) {
436: boolean modified = false;
437: Set featureSet = featuresAsSet(features);
438: if (enable && !featureSet.contains(feature)) {
439: // System.out.println("adding feature '" + feature + "'");
440: featureSet.add(feature);
441: modified = true;
442: } else if (!enable && featureSet.contains(feature)) {
443: // System.out.println("removing feature '" + feature + "'");
444: featureSet.remove(feature);
445: modified = true;
446: }
447:
448: if (modified) {
449: try {
450: processingCheckBox = true;
451: String newFeatures = featuresAsString(featureSet);
452: jTxtEnabledFeatures.setText(newFeatures);
453: } finally {
454: processingCheckBox = false;
455: }
456: }
457: }
458:
459: private Set featuresAsSet(String featureString) {
460: HashSet set = new HashSet(10);
461: String[] featureList = featureString.split(",");
462: for (int i = 0; i < featureList.length; i++) {
463: String feature = featureList[i].trim();
464: if (feature != null && feature.length() > 0) {
465: set.add(feature);
466: }
467: }
468: return set;
469: }
470:
471: private String featuresAsString(Set featureSet) {
472: StringBuffer featureString = new StringBuffer(
473: featureSet.size() * 16);
474: for (Iterator iter = featureSet.iterator(); iter.hasNext();) {
475: String feature = (String) iter.next();
476: featureString.append(feature);
477: if (iter.hasNext()) {
478: featureString.append(", ");
479: }
480: }
481: return featureString.toString();
482: }
483:
484: private void updateFeatureList(DocumentEvent e) {
485: Document doc = e.getDocument();
486: String oldFeatures = features;
487:
488: try {
489: features = doc.getText(0, doc.getLength());
490: } catch (BadLocationException ex) {
491: ErrorManager.getDefault()
492: .notify(ErrorManager.EXCEPTION, ex);
493: }
494:
495: if (!features.equals(oldFeatures)) {
496: WsCompileEditorSupport.ServiceSettings entry = (WsCompileEditorSupport.ServiceSettings) jLstServices
497: .getSelectedValue();
498: entry.setNewFeatures(features);
499: checkSettings(entry);
500:
501: if (!processingCheckBox) {
502: updateCheckBoxes(features);
503: }
504:
505: WsCompileEditorSupport.FeatureDescriptor oldF = new WsCompileEditorSupport.FeatureDescriptor(
506: entry.getServiceName(), oldFeatures);
507: WsCompileEditorSupport.FeatureDescriptor newF = new WsCompileEditorSupport.FeatureDescriptor(
508: entry.getServiceName(), features);
509: // System.out.println("feature list changed (" + newF.getServiceName() + ", [" + newF.getFeatures() + "])");
510: firePropertyChange(
511: WsCompileEditorSupport.PROP_FEATURES_CHANGED, oldF,
512: newF);
513: }
514: }
515:
516: private void updateCheckBoxes(String features) {
517: try {
518: processingFeatureString = true;
519: Set featureSet = featuresAsSet(features);
520: for (int i = 0; i < MAX_IMPORTANT_FEATURES; i++) {
521: String feature = featureCheckboxes[i].getText();
522: featureCheckboxes[i].setSelected(featureSet
523: .contains(feature));
524: }
525: } finally {
526: processingFeatureString = false;
527: }
528: }
529:
530: private boolean checkSettings(
531: WsCompileEditorSupport.ServiceSettings settings) {
532: String message = validateSettings(settings);
533: if (message != null) {
534: jLblError.setText(message);
535: } else {
536: jLblError.setText(" ");
537: }
538: return message != null;
539: }
540:
541: private String validateSettings(
542: WsCompileEditorSupport.ServiceSettings settings) {
543: // really just validate the feature string
544: String message = null;
545: List availableFeatures = settings.getAvailableFeatures();
546: String[] featuresList = settings.getNewFeatures().split(",");
547: for (int i = 0; i < featuresList.length; i++) {
548: featuresList[i] = featuresList[i].trim();
549: if (featuresList[i] != null && featuresList[i].length() > 0
550: && !availableFeatures.contains(featuresList[i])) {
551: // Feature not in available list - either invalid, or out of context, determine which:
552: if (masterWsCompileFeatures.contains(featuresList[i])) {
553: message = NbBundle.getMessage(
554: CustomizerWsCompile.class,
555: "ERR_FeatureNotSupported", featuresList[i]);
556: } else {
557: message = NbBundle.getMessage(
558: CustomizerWsCompile.class,
559: "ERR_InvalidFeature", featuresList[i]);
560: }
561: break;
562: }
563: }
564:
565: // Special case to force error if rpcliteral and document literal are both checked
566: // -- at least until we can fix the UI to not allow this.
567: boolean usesRpcLiteral = false;
568: boolean usesDocumentLiteral = false;
569:
570: for (int i = 0; i < featuresList.length; i++) {
571: if ("rpcliteral".equals(featuresList[i])) {
572: usesRpcLiteral = true;
573: } else if ("documentliteral".equals(featuresList[i])) {
574: usesDocumentLiteral = true;
575: }
576: }
577:
578: if (usesRpcLiteral && usesDocumentLiteral) {
579: message = NbBundle.getMessage(CustomizerWsCompile.class,
580: "ERR_InvalidBinding");
581: }
582:
583: return message;
584: }
585:
586: private void updateServiceFeatures(
587: WsCompileEditorSupport.ServiceSettings entry) {
588: try {
589: updatingDisplay = true;
590: enableServiceFeatures();
591:
592: int index = 0;
593: for (Iterator iter = entry.getImportantFeatures()
594: .iterator(); iter.hasNext()
595: && index < MAX_IMPORTANT_FEATURES; index++) {
596: String feature = (String) iter.next();
597: featureCheckboxes[index].setVisible(true);
598: featureCheckboxes[index].setText(feature);
599: featureCheckboxes[index]
600: .setToolTipText(WsCompileFeatures
601: .getFeaturesMap().get(feature));
602: }
603:
604: while (index < MAX_IMPORTANT_FEATURES) {
605: featureCheckboxes[index++].setVisible(false);
606: }
607:
608: features = entry.getNewFeatures();
609: updateCheckBoxes(features);
610: jTxtEnabledFeatures.setText(features);
611:
612: // If there is an existing error, proactively display it.
613: checkSettings(entry);
614: } finally {
615: updatingDisplay = false;
616: }
617: }
618:
619: private void enableServiceFeatures() {
620:
621: }
622:
623: private void disableServiceFeatures() {
624:
625: }
626:
627: public void addNotify() {
628: super .addNotify();
629:
630: jLstServices.setModel(servicesModel);
631: jLstServices.setSelectedIndex(0);
632: }
633:
634: public void removeNotify() {
635: super .removeNotify();
636: }
637:
638: //
639: // WsCompileEditorSupport.Panel implementation
640: //
641:
642: public void initValues(List/*ServiceSettings*/settings) {
643: assert settings.size() > 0;
644:
645: jLblServices.setText(NbBundle.getMessage(
646: CustomizerWsCompile.class, "LBL_WebServices"));
647: jLblPanelDescription.setText(NbBundle.getMessage(
648: CustomizerWsCompile.class,
649: "LBL_PanelDescriptionService"));
650:
651: // Load list of services (or clients) that are being configured.
652: servicesModel.clear();
653: for (Iterator iter = settings.iterator(); iter.hasNext();) {
654: WsCompileEditorSupport.ServiceSettings entry = (WsCompileEditorSupport.ServiceSettings) iter
655: .next();
656: servicesModel.addElement(entry);
657: }
658: }
659:
660: public JPanel getComponent() {
661: return this ;
662: }
663:
664: public void validatePanel()
665: throws org.openide.WizardValidationException {
666: // !PW FIXME do we want to iterate all services and validate all of them here?
667: WsCompileEditorSupport.ServiceSettings entry = (WsCompileEditorSupport.ServiceSettings) jLstServices
668: .getSelectedValue();
669: if (entry != null) {
670: final String message = validateSettings(entry);
671: if (message != null) {
672: throw new WizardValidationException(
673: jTxtEnabledFeatures, message, message);
674: }
675: }
676: }
677:
678: public HelpCtx getHelpCtx() {
679: return HelpCtx.DEFAULT_HELP;
680: }
681:
682: private static final HashSet masterWsCompileFeatures = new HashSet(
683: WsCompileFeatures.getFeaturesMap().keySet());
684: }
|