KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > jaxrpc > project > CustomizerWsCompile


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.websvc.jaxrpc.project;
21
22 import java.util.Arrays JavaDoc;
23 import java.util.HashSet JavaDoc;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Set JavaDoc;
27
28 import java.awt.Color JavaDoc;
29 import java.awt.event.ItemEvent JavaDoc;
30 import java.awt.event.ItemListener JavaDoc;
31 import java.util.HashMap JavaDoc;
32 import java.util.Map JavaDoc;
33
34 import javax.swing.JCheckBox JavaDoc;
35 import javax.swing.JPanel JavaDoc;
36 import javax.swing.DefaultListModel JavaDoc;
37 import javax.swing.event.DocumentEvent JavaDoc;
38 import javax.swing.event.DocumentListener JavaDoc;
39 import javax.swing.text.Document JavaDoc;
40 import javax.swing.text.BadLocationException JavaDoc;
41 import org.netbeans.modules.websvc.api.webservices.WsCompileEditorSupport;
42 import org.openide.ErrorManager;
43 import org.openide.WizardValidationException;
44 import org.openide.util.HelpCtx;
45 import org.openide.util.NbBundle;
46
47 /**
48  *
49  * @author Peter Williams
50  */

51 public class CustomizerWsCompile extends javax.swing.JPanel JavaDoc implements WsCompileEditorSupport.Panel, HelpCtx.Provider {
52     
53     public static final Color JavaDoc ErrorTextForegroundColor = new Color JavaDoc(89, 79, 191);
54     
55     private static final int MAX_IMPORTANT_FEATURES = 12;
56     
57     private DefaultListModel JavaDoc servicesModel;
58     private JCheckBox JavaDoc [] featureCheckboxes;
59     
60     private int serviceType;
61     private String JavaDoc features;
62     private boolean updatingDisplay;
63     private boolean processingCheckBox;
64     private boolean processingFeatureString;
65     
66     public CustomizerWsCompile() {
67         initComponents();
68         initUserComponents();
69     }
70     
71     /** This method is called from within the constructor to
72      * initialize the form.
73      * WARNING: Do NOT modify this code. The content of this method is
74      * always regenerated by the Form Editor.
75      */

76     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
77
private void initComponents() {
78         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
79
80         jPnlServices = new javax.swing.JPanel JavaDoc();
81         jLblServices = new javax.swing.JLabel JavaDoc();
82         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
83         jLstServices = new javax.swing.JList JavaDoc();
84         jPnlFeatures = new javax.swing.JPanel JavaDoc();
85         jLblPanelDescription = new javax.swing.JLabel JavaDoc();
86         jPnlOptions = new javax.swing.JPanel JavaDoc();
87         jChkFeatureA = new javax.swing.JCheckBox JavaDoc();
88         jChkFeatureB = new javax.swing.JCheckBox JavaDoc();
89         jChkFeatureC = new javax.swing.JCheckBox JavaDoc();
90         jChkFeatureD = new javax.swing.JCheckBox JavaDoc();
91         jChkFeatureE = new javax.swing.JCheckBox JavaDoc();
92         jChkFeatureF = new javax.swing.JCheckBox JavaDoc();
93         jChkFeatureG = new javax.swing.JCheckBox JavaDoc();
94         jChkFeatureH = new javax.swing.JCheckBox JavaDoc();
95         jChkFeatureI = new javax.swing.JCheckBox JavaDoc();
96         jChkFeatureJ = new javax.swing.JCheckBox JavaDoc();
97         jChkFeatureK = new javax.swing.JCheckBox JavaDoc();
98         jChkFeatureL = new javax.swing.JCheckBox JavaDoc();
99         jLblEnabledFeatures = new javax.swing.JLabel JavaDoc();
100         jScrollPane2 = new javax.swing.JScrollPane JavaDoc();
101         jTxtEnabledFeatures = new javax.swing.JTextArea JavaDoc();
102         jLblError = new javax.swing.JLabel JavaDoc();
103
104         setLayout(new java.awt.GridBagLayout JavaDoc());
105
106         jPnlServices.setLayout(new java.awt.GridBagLayout JavaDoc());
107
108         jLblServices.setDisplayedMnemonic(org.openide.util.NbBundle.getMessage(CustomizerWsCompile.class, "LBL_WebServicesMnemonic").charAt(0));
109         jLblServices.setLabelFor(jLstServices);
110         jLblServices.setText(org.openide.util.NbBundle.getMessage(CustomizerWsCompile.class, "LBL_WebServices"));
111         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
112         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
113         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
114         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 2, 0);
115         jPnlServices.add(jLblServices, gridBagConstraints);
116
117         jLstServices.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
118         jLstServices.addListSelectionListener(new javax.swing.event.ListSelectionListener JavaDoc() {
119             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {
120                 jLstServicesValueChanged(evt);
121             }
122         });
123
124         jScrollPane1.setViewportView(jLstServices);
125
126         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
127         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
128         gridBagConstraints.weightx = 1.0;
129         gridBagConstraints.weighty = 1.0;
130         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 0);
131         jPnlServices.add(jScrollPane1, gridBagConstraints);
132
133         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
134         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
135         gridBagConstraints.weightx = 0.5;
136         gridBagConstraints.weighty = 1.0;
137         add(jPnlServices, gridBagConstraints);
138
139         jPnlFeatures.setLayout(new java.awt.GridBagLayout JavaDoc());
140
141         org.openide.awt.Mnemonics.setLocalizedText(jLblPanelDescription, NbBundle.getMessage(CustomizerWsCompile.class, "LBL_PanelDescriptionService"));
142         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
143         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
144         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
145         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
146         jPnlFeatures.add(jLblPanelDescription, gridBagConstraints);
147
148         jPnlOptions.setLayout(new java.awt.GridBagLayout JavaDoc());
149
150         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureA, "Feature A");
151         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
152         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
153         gridBagConstraints.weightx = 0.33;
154         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
155         jPnlOptions.add(jChkFeatureA, gridBagConstraints);
156
157         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureB, "Feature B");
158         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
159         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
160         gridBagConstraints.weightx = 0.33;
161         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
162         jPnlOptions.add(jChkFeatureB, gridBagConstraints);
163
164         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureC, "Feature C");
165         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
166         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
167         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
168         gridBagConstraints.weightx = 0.33;
169         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
170         jPnlOptions.add(jChkFeatureC, gridBagConstraints);
171
172         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureD, "Feature D");
173         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
174         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
175         gridBagConstraints.weightx = 0.33;
176         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
177         jPnlOptions.add(jChkFeatureD, gridBagConstraints);
178
179         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureE, "Feature E");
180         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
181         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
182         gridBagConstraints.weightx = 0.33;
183         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
184         jPnlOptions.add(jChkFeatureE, gridBagConstraints);
185
186         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureF, "Feature F");
187         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
188         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
189         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
190         gridBagConstraints.weightx = 0.33;
191         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
192         jPnlOptions.add(jChkFeatureF, gridBagConstraints);
193
194         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureG, "Feature G");
195         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
196         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
197         gridBagConstraints.weightx = 0.33;
198         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
199         jPnlOptions.add(jChkFeatureG, gridBagConstraints);
200
201         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureH, "Feature H");
202         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
203         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
204         gridBagConstraints.weightx = 0.33;
205         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
206         jPnlOptions.add(jChkFeatureH, gridBagConstraints);
207
208         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureI, "Feature I");
209         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
210         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
211         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
212         gridBagConstraints.weightx = 0.33;
213         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
214         jPnlOptions.add(jChkFeatureI, gridBagConstraints);
215
216         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureJ, "Feature J");
217         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
218         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
219         gridBagConstraints.weightx = 0.33;
220         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
221         jPnlOptions.add(jChkFeatureJ, gridBagConstraints);
222
223         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureK, "Feature K");
224         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
225         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
226         gridBagConstraints.weightx = 0.33;
227         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
228         jPnlOptions.add(jChkFeatureK, gridBagConstraints);
229
230         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureL, "Feature L");
231         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(0, 0, 11, 11);
236         jPnlOptions.add(jChkFeatureL, gridBagConstraints);
237
238         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
239         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
240         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
241         gridBagConstraints.weightx = 1.0;
242         jPnlFeatures.add(jPnlOptions, gridBagConstraints);
243
244         jLblEnabledFeatures.setLabelFor(jTxtEnabledFeatures);
245         org.openide.awt.Mnemonics.setLocalizedText(jLblEnabledFeatures, org.openide.util.NbBundle.getMessage(CustomizerWsCompile.class, "LBL_EnabledFeatures"));
246         jLblEnabledFeatures.setOpaque(true);
247         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
248         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
249         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
250         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 2, 11);
251         jPnlFeatures.add(jLblEnabledFeatures, gridBagConstraints);
252
253         jTxtEnabledFeatures.setLineWrap(true);
254         jTxtEnabledFeatures.setRows(3);
255         jTxtEnabledFeatures.setWrapStyleWord(true);
256         jScrollPane2.setViewportView(jTxtEnabledFeatures);
257
258         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
259         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
260         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
261         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH;
262         gridBagConstraints.weightx = 1.0;
263         gridBagConstraints.weighty = 1.0;
264         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 0);
265         jPnlFeatures.add(jScrollPane2, gridBagConstraints);
266
267         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
268         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
269         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
270         gridBagConstraints.weightx = 0.5;
271         gridBagConstraints.weighty = 1.0;
272         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 11, 0, 0);
273         add(jPnlFeatures, gridBagConstraints);
274
275         org.openide.awt.Mnemonics.setLocalizedText(jLblError, " ");
276         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
277         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
278         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
279         gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
280         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 6, 0);
281         add(jLblError, gridBagConstraints);
282
283     }// </editor-fold>//GEN-END:initComponents
284

285     private void jLstServicesValueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {//GEN-FIRST:event_jLstServicesValueChanged
286
if(!evt.getValueIsAdjusting()) {
287             WsCompileEditorSupport.ServiceSettings entry = (WsCompileEditorSupport.ServiceSettings) jLstServices.getSelectedValue();
288             if(entry != null) {
289                 updateServiceFeatures(entry);
290             } else {
291                 disableServiceFeatures();
292             }
293         }
294     }//GEN-LAST:event_jLstServicesValueChanged
295

296     // Variables declaration - do not modify//GEN-BEGIN:variables
297
private javax.swing.JCheckBox JavaDoc jChkFeatureA;
298     private javax.swing.JCheckBox JavaDoc jChkFeatureB;
299     private javax.swing.JCheckBox JavaDoc jChkFeatureC;
300     private javax.swing.JCheckBox JavaDoc jChkFeatureD;
301     private javax.swing.JCheckBox JavaDoc jChkFeatureE;
302     private javax.swing.JCheckBox JavaDoc jChkFeatureF;
303     private javax.swing.JCheckBox JavaDoc jChkFeatureG;
304     private javax.swing.JCheckBox JavaDoc jChkFeatureH;
305     private javax.swing.JCheckBox JavaDoc jChkFeatureI;
306     private javax.swing.JCheckBox JavaDoc jChkFeatureJ;
307     private javax.swing.JCheckBox JavaDoc jChkFeatureK;
308     private javax.swing.JCheckBox JavaDoc jChkFeatureL;
309     private javax.swing.JLabel JavaDoc jLblEnabledFeatures;
310     private javax.swing.JLabel JavaDoc jLblError;
311     private javax.swing.JLabel JavaDoc jLblPanelDescription;
312     private javax.swing.JLabel JavaDoc jLblServices;
313     private javax.swing.JList JavaDoc jLstServices;
314     private javax.swing.JPanel JavaDoc jPnlFeatures;
315     private javax.swing.JPanel JavaDoc jPnlOptions;
316     private javax.swing.JPanel JavaDoc jPnlServices;
317     private javax.swing.JScrollPane JavaDoc jScrollPane1;
318     private javax.swing.JScrollPane JavaDoc jScrollPane2;
319     private javax.swing.JTextArea JavaDoc jTxtEnabledFeatures;
320     // End of variables declaration//GEN-END:variables
321

322     private void initUserComponents() {
323         updatingDisplay = false;
324         processingCheckBox = false;
325         processingFeatureString = false;
326         
327         jLblError.setForeground(ErrorTextForegroundColor);
328         servicesModel = new DefaultListModel JavaDoc();
329         
330         // !PW Rework this entire pattern for 5.0, including better API for specifying
331
// radio buttons vs. checkboxes for competing options (e.g. rpcliteral
332
// vs. documentliteral, unwrap vs. donotunwrap, etc.
333
//
334
// Could provide nested panel for each supported "service/client" type,
335
// e.g. service from SEI, service from WSDL, and web service client.
336
// J2ME might also have preferences here.
337
//
338
featureCheckboxes = new JCheckBox JavaDoc [MAX_IMPORTANT_FEATURES];
339         featureCheckboxes[0] = jChkFeatureA;
340         featureCheckboxes[1] = jChkFeatureB;
341         featureCheckboxes[2] = jChkFeatureC;
342         featureCheckboxes[3] = jChkFeatureD;
343         featureCheckboxes[4] = jChkFeatureE;
344         featureCheckboxes[5] = jChkFeatureF;
345         featureCheckboxes[6] = jChkFeatureG;
346         featureCheckboxes[7] = jChkFeatureH;
347         featureCheckboxes[8] = jChkFeatureI;
348         featureCheckboxes[9] = jChkFeatureJ;
349         featureCheckboxes[10] = jChkFeatureK;
350         featureCheckboxes[11] = jChkFeatureL;
351         
352         ItemListener JavaDoc checkBoxListener = new ItemListener JavaDoc() {
353             public void itemStateChanged(ItemEvent JavaDoc evt) {
354                 if(!processingFeatureString) {
355                     JCheckBox JavaDoc source = (JCheckBox JavaDoc) evt.getSource();
356                     String JavaDoc feature = source.getText();
357                     enableFeature(feature, evt.getStateChange() == ItemEvent.SELECTED);
358                 }
359             }
360         };
361         
362         for(int i = 0; i < MAX_IMPORTANT_FEATURES; i++) {
363             featureCheckboxes[i].addItemListener(checkBoxListener);
364         }
365         
366         jTxtEnabledFeatures.getDocument().addDocumentListener(new DocumentListener JavaDoc() {
367             public void changedUpdate(DocumentEvent JavaDoc e) {
368                 if(!updatingDisplay) {
369                     updateFeatureList(e);
370                 }
371             }
372             public void insertUpdate(DocumentEvent JavaDoc e) {
373                 if(!updatingDisplay) {
374                     updateFeatureList(e);
375                 }
376             }
377             public void removeUpdate(DocumentEvent JavaDoc e) {
378                 if(!updatingDisplay) {
379                     updateFeatureList(e);
380                 }
381             }
382         });
383     }
384     
385     private void enableFeature(String JavaDoc feature, boolean enable) {
386         boolean modified = false;
387         Set JavaDoc featureSet = featuresAsSet(features);
388         if(enable && !featureSet.contains(feature)) {
389 // System.out.println("adding feature '" + feature + "'");
390
featureSet.add(feature);
391             modified = true;
392         } else if(!enable && featureSet.contains(feature)) {
393 // System.out.println("removing feature '" + feature + "'");
394
featureSet.remove(feature);
395             modified = true;
396         }
397         
398         if(modified) {
399             try {
400                 processingCheckBox = true;
401                 String JavaDoc newFeatures = featuresAsString(featureSet);
402                 jTxtEnabledFeatures.setText(newFeatures);
403             } finally {
404                 processingCheckBox = false;
405             }
406         }
407     }
408     
409     private Set JavaDoc featuresAsSet(String JavaDoc featureString) {
410         HashSet JavaDoc set = new HashSet JavaDoc(10);
411         String JavaDoc [] featureList = featureString.split(",");
412         for(int i = 0; i < featureList.length; i++) {
413             String JavaDoc feature = featureList[i].trim();
414             if(feature != null && feature.length() > 0) {
415                 set.add(feature);
416             }
417         }
418         return set;
419     }
420     
421     private String JavaDoc featuresAsString(Set JavaDoc featureSet) {
422         StringBuffer JavaDoc featureString = new StringBuffer JavaDoc(featureSet.size()*16);
423         for(Iterator JavaDoc iter = featureSet.iterator(); iter.hasNext(); ) {
424             String JavaDoc feature = (String JavaDoc) iter.next();
425             featureString.append(feature);
426             if(iter.hasNext()) {
427                 featureString.append(", ");
428             }
429         }
430         return featureString.toString();
431     }
432     
433     private void updateFeatureList(DocumentEvent JavaDoc e) {
434         Document JavaDoc doc = e.getDocument();
435         String JavaDoc oldFeatures = features;
436         
437         try {
438             features = doc.getText(0, doc.getLength());
439         } catch(BadLocationException JavaDoc ex) {
440             ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, ex);
441         }
442         
443         if(!features.equals(oldFeatures)) {
444             WsCompileEditorSupport.ServiceSettings entry = (WsCompileEditorSupport.ServiceSettings) jLstServices.getSelectedValue();
445             entry.setNewFeatures(features);
446             checkSettings(entry);
447             
448             if(!processingCheckBox) {
449                 updateCheckBoxes(features);
450             }
451             
452             WsCompileEditorSupport.FeatureDescriptor oldF = new WsCompileEditorSupport.FeatureDescriptor(entry.getServiceName(), oldFeatures);
453             WsCompileEditorSupport.FeatureDescriptor newF = new WsCompileEditorSupport.FeatureDescriptor(entry.getServiceName(), features);
454 // System.out.println("feature list changed (" + newF.getServiceName() + ", [" + newF.getFeatures() + "])");
455
firePropertyChange(WsCompileEditorSupport.PROP_FEATURES_CHANGED, oldF, newF);
456         }
457     }
458     
459     private void updateCheckBoxes(String JavaDoc features) {
460         try {
461             processingFeatureString = true;
462             Set JavaDoc featureSet = featuresAsSet(features);
463             for(int i = 0; i < MAX_IMPORTANT_FEATURES; i++) {
464                 String JavaDoc feature = featureCheckboxes[i].getText();
465                 featureCheckboxes[i].setSelected(featureSet.contains(feature));
466             }
467         } finally {
468             processingFeatureString = false;
469         }
470     }
471     
472     private boolean checkSettings(WsCompileEditorSupport.ServiceSettings settings) {
473         String JavaDoc message = validateSettings(settings);
474         if(message != null) {
475             jLblError.setText(message);
476         } else {
477             jLblError.setText(" ");
478         }
479         return message != null;
480     }
481     
482     private String JavaDoc validateSettings(WsCompileEditorSupport.ServiceSettings settings) {
483         // really just validate the feature string
484
String JavaDoc message = null;
485         List JavaDoc availableFeatures = settings.getAvailableFeatures();
486         String JavaDoc [] featuresList = settings.getNewFeatures().split(",");
487         for(int i = 0; i < featuresList.length; i++) {
488             featuresList[i] = featuresList[i].trim();
489             if(featuresList[i] != null && featuresList[i].length() > 0 && !availableFeatures.contains(featuresList[i])) {
490                 // Feature not in available list - either invalid, or out of context, determine which:
491
if(masterWsCompileFeatures.contains(featuresList[i])) {
492                     message = NbBundle.getMessage(CustomizerWsCompile.class, "ERR_FeatureNotSupported", featuresList[i]);
493                 } else {
494                     message = NbBundle.getMessage(CustomizerWsCompile.class, "ERR_InvalidFeature", featuresList[i]);
495                 }
496                 break;
497             }
498         }
499         
500         // Special case to force error if rpcliteral and document literal are both checked
501
// -- at least until we can fix the UI to not allow this.
502
boolean usesRpcLiteral = false;
503         boolean usesDocumentLiteral = false;
504         
505         for(int i = 0; i < featuresList.length; i++) {
506             if("rpcliteral".equals(featuresList[i])) {
507                 usesRpcLiteral = true;
508             } else if("documentliteral".equals(featuresList[i])) {
509                 usesDocumentLiteral = true;
510             }
511         }
512         
513         if(usesRpcLiteral && usesDocumentLiteral) {
514             message = NbBundle.getMessage(CustomizerWsCompile.class, "ERR_InvalidBinding");
515         }
516         
517         return message;
518     }
519     
520     private void updateServiceFeatures(WsCompileEditorSupport.ServiceSettings entry) {
521         try {
522             updatingDisplay = true;
523             enableServiceFeatures();
524             
525             int index = 0;
526             for(Iterator JavaDoc iter = entry.getImportantFeatures().iterator(); iter.hasNext() && index < MAX_IMPORTANT_FEATURES; index++) {
527                 String JavaDoc feature = (String JavaDoc) iter.next();
528                 featureCheckboxes[index].setVisible(true);
529                 featureCheckboxes[index].setText(feature);
530                 featureCheckboxes[index].setToolTipText(WsCompileFeatures.getFeaturesMap().get(feature));
531             }
532             
533             while(index < MAX_IMPORTANT_FEATURES) {
534                 featureCheckboxes[index++].setVisible(false);
535             }
536             
537             features = entry.getNewFeatures();
538             updateCheckBoxes(features);
539             jTxtEnabledFeatures.setText(features);
540             
541             // If there is an existing error, proactively display it.
542
checkSettings(entry);
543         } finally {
544             updatingDisplay = false;
545         }
546     }
547     
548     private void enableServiceFeatures() {
549         
550     }
551     
552     private void disableServiceFeatures() {
553         
554     }
555     
556     public void addNotify() {
557         super.addNotify();
558         
559         jLstServices.setModel(servicesModel);
560         jLstServices.setSelectedIndex(0);
561     }
562     
563     public void removeNotify() {
564         super.removeNotify();
565     }
566     
567     //
568
// WsCompileEditorSupport.Panel implementation
569
//
570

571     public void initValues(List JavaDoc/*ServiceSettings*/ settings) {
572         assert settings.size() > 0;
573         
574         jLblServices.setText(NbBundle.getMessage(CustomizerWsCompile.class, "LBL_WebServices"));
575         jLblPanelDescription.setText(NbBundle.getMessage(CustomizerWsCompile.class, "LBL_PanelDescriptionService"));
576         
577         // Load list of services (or clients) that are being configured.
578
servicesModel.clear();
579         for(Iterator JavaDoc iter = settings.iterator(); iter.hasNext(); ) {
580             WsCompileEditorSupport.ServiceSettings entry = (WsCompileEditorSupport.ServiceSettings) iter.next();
581             servicesModel.addElement(entry);
582         }
583     }
584     
585     public JPanel JavaDoc getComponent() {
586         return this;
587     }
588     
589     public void validatePanel() throws org.openide.WizardValidationException {
590         // !PW FIXME do we want to iterate all services and validate all of them here?
591
WsCompileEditorSupport.ServiceSettings entry = (WsCompileEditorSupport.ServiceSettings) jLstServices.getSelectedValue();
592         if(entry != null) {
593             final String JavaDoc message = validateSettings(entry);
594             if(message != null) {
595                 throw new WizardValidationException(jTxtEnabledFeatures, message, message);
596             }
597         }
598     }
599     
600     public HelpCtx getHelpCtx() {
601         return HelpCtx.DEFAULT_HELP;
602     }
603     
604     
605     private static final HashSet JavaDoc masterWsCompileFeatures = new HashSet JavaDoc(WsCompileFeatures.getFeaturesMap().keySet());
606 }
Popular Tags