KickJava   Java API By Example, From Geeks To Geeks.

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


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.HashSet JavaDoc;
23 import java.util.Iterator JavaDoc;
24 import java.util.List JavaDoc;
25 import java.util.Set JavaDoc;
26
27 import java.awt.Color JavaDoc;
28 import java.awt.event.ItemEvent JavaDoc;
29 import java.awt.event.ItemListener JavaDoc;
30
31 import javax.swing.JCheckBox JavaDoc;
32 import javax.swing.JPanel JavaDoc;
33 import javax.swing.DefaultListModel JavaDoc;
34 import javax.swing.event.DocumentEvent JavaDoc;
35 import javax.swing.event.DocumentListener JavaDoc;
36 import javax.swing.text.Document JavaDoc;
37 import javax.swing.text.BadLocationException JavaDoc;
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 /**
46  *
47  * @author Peter Williams
48  */

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

73     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
74
private void initComponents() {
75         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
76
77         jPnlServices = new javax.swing.JPanel JavaDoc();
78         jLblServices = new javax.swing.JLabel JavaDoc();
79         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
80         jLstServices = new javax.swing.JList JavaDoc();
81         jPnlFeatures = new javax.swing.JPanel JavaDoc();
82         jLblPanelDescription = new javax.swing.JLabel JavaDoc();
83         jPnlFeatureCheckboxes = new javax.swing.JPanel JavaDoc();
84         jChkFeatureA = new javax.swing.JCheckBox JavaDoc();
85         jChkFeatureB = new javax.swing.JCheckBox JavaDoc();
86         jChkFeatureC = new javax.swing.JCheckBox JavaDoc();
87         jChkFeatureD = new javax.swing.JCheckBox JavaDoc();
88         jChkFeatureE = new javax.swing.JCheckBox JavaDoc();
89         jChkFeatureF = new javax.swing.JCheckBox JavaDoc();
90         jChkFeatureG = new javax.swing.JCheckBox JavaDoc();
91         jChkFeatureH = new javax.swing.JCheckBox JavaDoc();
92         jChkFeatureI = new javax.swing.JCheckBox JavaDoc();
93         jChkFeatureJ = new javax.swing.JCheckBox JavaDoc();
94         jChkFeatureK = new javax.swing.JCheckBox JavaDoc();
95         jChkFeatureL = new javax.swing.JCheckBox JavaDoc();
96         jLblEnabledFeatures = new javax.swing.JLabel JavaDoc();
97         jScrollPane2 = new javax.swing.JScrollPane JavaDoc();
98         jTxtEnabledFeatures = new javax.swing.JTextArea JavaDoc();
99         jLblError = new javax.swing.JLabel JavaDoc();
100         jPnlOptions = new javax.swing.JPanel JavaDoc();
101         jLblOptions = new javax.swing.JLabel JavaDoc();
102         jPanel1 = new javax.swing.JPanel JavaDoc();
103         cbVerbose = new javax.swing.JCheckBox JavaDoc();
104         cbDebug = new javax.swing.JCheckBox JavaDoc();
105         cbPrintStackTrace = new javax.swing.JCheckBox JavaDoc();
106         cbSerializable = new javax.swing.JCheckBox JavaDoc();
107         cbOptimize = new javax.swing.JCheckBox JavaDoc();
108
109         setLayout(new java.awt.GridBagLayout JavaDoc());
110
111         jPnlServices.setLayout(new java.awt.GridBagLayout JavaDoc());
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 JavaDoc();
117         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
118         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
119         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc() {
124             public void valueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {
125                 jLstServicesValueChanged(evt);
126             }
127         });
128
129         jScrollPane1.setViewportView(jLstServices);
130
131         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
132         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
133         gridBagConstraints.weightx = 1.0;
134         gridBagConstraints.weighty = 1.0;
135         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 0);
136         jPnlServices.add(jScrollPane1, gridBagConstraints);
137
138         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc());
148
149         org.openide.awt.Mnemonics.setLocalizedText(jLblPanelDescription, NbBundle.getMessage(CustomizerWsCompileClient.class, "LBL_PanelDescriptionService"));
150         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
151         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
152         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
153         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 11, 11);
154         jPnlFeatures.add(jLblPanelDescription, gridBagConstraints);
155
156         jPnlFeatureCheckboxes.setLayout(new java.awt.GridBagLayout JavaDoc());
157
158         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureA, "Feature A");
159         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
160         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
161         gridBagConstraints.weightx = 0.33;
162         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc();
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         jPnlFeatureCheckboxes.add(jChkFeatureB, gridBagConstraints);
171
172         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureC, "Feature C");
173         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
182         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
183         gridBagConstraints.weightx = 0.33;
184         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc();
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         jPnlFeatureCheckboxes.add(jChkFeatureE, gridBagConstraints);
193
194         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureF, "Feature F");
195         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
204         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
205         gridBagConstraints.weightx = 0.33;
206         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc();
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         jPnlFeatureCheckboxes.add(jChkFeatureH, gridBagConstraints);
215
216         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureI, "Feature I");
217         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc();
226         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
227         gridBagConstraints.weightx = 0.33;
228         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc();
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         jPnlFeatureCheckboxes.add(jChkFeatureK, gridBagConstraints);
237
238         org.openide.awt.Mnemonics.setLocalizedText(jChkFeatureL, "Feature L");
239         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(0, 0, 11, 11);
244         jPnlFeatureCheckboxes.add(jChkFeatureL, gridBagConstraints);
245
246         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc();
256         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
257         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
258         gridBagConstraints.insets = new java.awt.Insets JavaDoc(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 JavaDoc();
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 JavaDoc(0, 0, 11, 0);
273         jPnlFeatures.add(jScrollPane2, gridBagConstraints);
274
275         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(0, 11, 0, 0);
283         add(jPnlFeatures, gridBagConstraints);
284
285         org.openide.awt.Mnemonics.setLocalizedText(jLblError, " ");
286         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(0, 0, 6, 0);
293         add(jLblError, gridBagConstraints);
294
295         jPnlOptions.setLayout(new java.awt.GridBagLayout JavaDoc());
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 JavaDoc();
301         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
302         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
303         gridBagConstraints.insets = new java.awt.Insets JavaDoc(11, 0, 10, 0);
304         jPnlOptions.add(jLblOptions, gridBagConstraints);
305
306         jPanel1.setLayout(new java.awt.GridBagLayout JavaDoc());
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 JavaDoc(0, 0, 0, 0));
311         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc(0, 0, 0, 0));
322         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc(0, 0, 0, 0));
333         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc(0, 0, 0, 0));
344         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(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 JavaDoc(0, 0, 0, 0));
355         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(0, 0, 11, 11);
361         jPanel1.add(cbOptimize, gridBagConstraints);
362
363         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
364         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
365         gridBagConstraints.weightx = 1.0;
366         jPnlOptions.add(jPanel1, gridBagConstraints);
367
368         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
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 JavaDoc(0, 11, 0, 0);
376         add(jPnlOptions, gridBagConstraints);
377
378     }// </editor-fold>//GEN-END:initComponents
379

380     private void jLstServicesValueChanged(javax.swing.event.ListSelectionEvent JavaDoc evt) {//GEN-FIRST:event_jLstServicesValueChanged
381
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     }//GEN-LAST:event_jLstServicesValueChanged
390

391     // Variables declaration - do not modify//GEN-BEGIN:variables
392
private javax.swing.JCheckBox JavaDoc cbDebug;
393     private javax.swing.JCheckBox JavaDoc cbOptimize;
394     private javax.swing.JCheckBox JavaDoc cbPrintStackTrace;
395     private javax.swing.JCheckBox JavaDoc cbSerializable;
396     private javax.swing.JCheckBox JavaDoc cbVerbose;
397     private javax.swing.JCheckBox JavaDoc jChkFeatureA;
398     private javax.swing.JCheckBox JavaDoc jChkFeatureB;
399     private javax.swing.JCheckBox JavaDoc jChkFeatureC;
400     private javax.swing.JCheckBox JavaDoc jChkFeatureD;
401     private javax.swing.JCheckBox JavaDoc jChkFeatureE;
402     private javax.swing.JCheckBox JavaDoc jChkFeatureF;
403     private javax.swing.JCheckBox JavaDoc jChkFeatureG;
404     private javax.swing.JCheckBox JavaDoc jChkFeatureH;
405     private javax.swing.JCheckBox JavaDoc jChkFeatureI;
406     private javax.swing.JCheckBox JavaDoc jChkFeatureJ;
407     private javax.swing.JCheckBox JavaDoc jChkFeatureK;
408     private javax.swing.JCheckBox JavaDoc jChkFeatureL;
409     private javax.swing.JLabel JavaDoc jLblEnabledFeatures;
410     private javax.swing.JLabel JavaDoc jLblError;
411     private javax.swing.JLabel JavaDoc jLblOptions;
412     private javax.swing.JLabel JavaDoc jLblPanelDescription;
413     private javax.swing.JLabel JavaDoc jLblServices;
414     private javax.swing.JList JavaDoc jLstServices;
415     private javax.swing.JPanel JavaDoc jPanel1;
416     private javax.swing.JPanel JavaDoc jPnlFeatureCheckboxes;
417     private javax.swing.JPanel JavaDoc jPnlFeatures;
418     private javax.swing.JPanel JavaDoc jPnlOptions;
419     private javax.swing.JPanel JavaDoc jPnlServices;
420     private javax.swing.JScrollPane JavaDoc jScrollPane1;
421     private javax.swing.JScrollPane JavaDoc jScrollPane2;
422     private javax.swing.JTextArea JavaDoc jTxtEnabledFeatures;
423     // End of variables declaration//GEN-END:variables
424

425     private void initUserComponents() {
426         updatingDisplay = false;
427         processingCheckBox = false;
428         processingFeatureString = false;
429         
430         jLblError.setForeground(ErrorTextForegroundColor);
431         servicesModel = new DefaultListModel JavaDoc();
432         
433         // !PW Rework this entire pattern for 5.0, including better API for specifying
434
// radio buttons vs. checkboxes for competing options (e.g. rpcliteral
435
// vs. documentliteral, unwrap vs. donotunwrap, etc.
436
//
437
// Could provide nested panel for each supported "service/client" type,
438
// e.g. service from SEI, service from WSDL, and web service client.
439
// J2ME might also have preferences here.
440
//
441
featureCheckboxes = new JCheckBox JavaDoc [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 JavaDoc checkBoxListener = new ItemListener JavaDoc() {
456             public void itemStateChanged(ItemEvent JavaDoc evt) {
457                 if(!processingFeatureString) {
458                     JCheckBox JavaDoc source = (JCheckBox JavaDoc) evt.getSource();
459                     String JavaDoc 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 JavaDoc optionsListener = new ItemListener JavaDoc() {
470             public void itemStateChanged(ItemEvent JavaDoc evt) {
471                 if (!updatingDisplay) {
472                     JCheckBox JavaDoc source = (JCheckBox JavaDoc) 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 JavaDoc() {
508             public void changedUpdate(DocumentEvent JavaDoc e) {
509                 if(!updatingDisplay) {
510                     updateFeatureList(e);
511                 }
512             }
513             public void insertUpdate(DocumentEvent JavaDoc e) {
514                 if(!updatingDisplay) {
515                     updateFeatureList(e);
516                 }
517             }
518             public void removeUpdate(DocumentEvent JavaDoc e) {
519                 if(!updatingDisplay) {
520                     updateFeatureList(e);
521                 }
522             }
523         });
524     }
525     
526     private void enableFeature(String JavaDoc feature, boolean enable) {
527         boolean modified = false;
528         Set JavaDoc featureSet = featuresAsSet(features);
529         if(enable && !featureSet.contains(feature)) {
530 // System.out.println("adding feature '" + feature + "'");
531
featureSet.add(feature);
532             modified = true;
533         } else if(!enable && featureSet.contains(feature)) {
534 // System.out.println("removing feature '" + feature + "'");
535
featureSet.remove(feature);
536             modified = true;
537         }
538         
539         if(modified) {
540             try {
541                 processingCheckBox = true;
542                 String JavaDoc newFeatures = featuresAsString(featureSet);
543                 jTxtEnabledFeatures.setText(newFeatures);
544             } finally {
545                 processingCheckBox = false;
546             }
547         }
548     }
549     
550     private Set JavaDoc featuresAsSet(String JavaDoc featureString) {
551         HashSet JavaDoc set = new HashSet JavaDoc(10);
552         String JavaDoc [] featureList = featureString.split(",");
553         for(int i = 0; i < featureList.length; i++) {
554             String JavaDoc 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 JavaDoc featuresAsString(Set JavaDoc featureSet) {
563         StringBuffer JavaDoc featureString = new StringBuffer JavaDoc(featureSet.size()*16);
564         for(Iterator JavaDoc iter = featureSet.iterator(); iter.hasNext(); ) {
565             String JavaDoc feature = (String JavaDoc) 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 JavaDoc e) {
575         Document JavaDoc doc = e.getDocument();
576         String JavaDoc oldFeatures = features;
577
578         try {
579             features = doc.getText(0, doc.getLength());
580         } catch(BadLocationException JavaDoc 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 // System.out.println("feature list changed (" + newF.getServiceName() + ", [" + newF.getFeatures() + "])");
596
firePropertyChange(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, oldF, newF);
597         }
598     }
599     
600     private void updateCheckBoxes(String JavaDoc features) {
601         try {
602             processingFeatureString = true;
603             Set JavaDoc featureSet = featuresAsSet(features);
604             for(int i = 0; i < MAX_IMPORTANT_FEATURES; i++) {
605                 String JavaDoc 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 JavaDoc 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 JavaDoc validateSettings(WsCompileClientEditorSupport.ServiceSettings settings) {
624         // really just validate the feature string
625
String JavaDoc message = null;
626         List JavaDoc availableFeatures = settings.getAvailableFeatures();
627         String JavaDoc [] 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                 // Feature not in available list - either invalid, or out of context, determine which:
632
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 JavaDoc iter = entry.getImportantFeatures().iterator(); iter.hasNext() && index < MAX_IMPORTANT_FEATURES; index++) {
650                 String JavaDoc feature = (String JavaDoc) 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             // If there is an existing error, proactively display it.
665
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     //
703
// WsCompileEditorSupport.Panel implementation
704
//
705

706     public void initValues(List JavaDoc/*ServiceSettings*/ settings) {
707         assert settings.size() > 0;
708
709         // Set UI (or other fields) that are service or client specific.
710
jLblServices.setText(NbBundle.getMessage(CustomizerWsCompile.class, "LBL_WebServiceClients"));
711         jLblPanelDescription.setText(NbBundle.getMessage(CustomizerWsCompile.class, "LBL_PanelDescriptionClient"));
712         
713         // Load list of services (or clients) that are being configured.
714
servicesModel.clear();
715         for(Iterator JavaDoc iter = settings.iterator(); iter.hasNext(); ) {
716             WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) iter.next();
717             servicesModel.addElement(entry);
718         }
719     }
720     
721     public JPanel JavaDoc getComponent() {
722         return this;
723     }
724     
725     public void validatePanel() throws org.openide.WizardValidationException {
726         // !PW FIXME do we want to iterate all services and validate all of them here?
727
WsCompileClientEditorSupport.ServiceSettings entry = (WsCompileClientEditorSupport.ServiceSettings) jLstServices.getSelectedValue();
728         if(entry != null) {
729             final String JavaDoc 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 JavaDoc masterWsCompileFeatures = new HashSet JavaDoc(WsCompileFeatures.getFeaturesMap().keySet());
742     
743 }
744
Popular Tags