KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > web > project > ui > customizer > CustomizerWSClientHost


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.web.project.ui.customizer;
21
22 import java.util.List JavaDoc;
23
24 import java.beans.PropertyChangeEvent JavaDoc;
25 import java.beans.PropertyChangeListener JavaDoc;
26
27 import javax.swing.JPanel JavaDoc;
28 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport;
29
30 import org.openide.util.HelpCtx;
31 import org.openide.util.Lookup;
32
33 /** Host for WsCompile features editor for editing the features enabled for
34  * running WsCompile on a web service or a web service client.
35  *
36  * property format: 'webservice.client.[servicename].features=xxx,yyy,zzz
37  *
38  * @author Peter Williams
39  */

40 public class CustomizerWSClientHost extends javax.swing.JPanel JavaDoc implements PropertyChangeListener JavaDoc, HelpCtx.Provider {
41     
42     private WebProjectProperties webProperties;
43     private WsCompileClientEditorSupport.Panel wsCompileEditor;
44
45     private List JavaDoc serviceSettings;
46     
47     public CustomizerWSClientHost(WebProjectProperties webProperties, List JavaDoc serviceSettings) {
48 // System.out.println("WSClientCustomizer: constructor");
49
assert serviceSettings != null;
50         initComponents();
51
52         this.webProperties = webProperties;
53         this.wsCompileEditor = null;
54         this.serviceSettings = serviceSettings;
55
56         if (serviceSettings.size() > 0)
57             initValues();
58     }
59     
60     /** This method is called from within the constructor to
61      * initialize the form.
62      * WARNING: Do NOT modify this code. The content of this method is
63      * always regenerated by the Form Editor.
64      */

65     private void initComponents() {//GEN-BEGIN:initComponents
66

67         setLayout(new java.awt.BorderLayout JavaDoc());
68
69     }//GEN-END:initComponents
70

71     
72     // Variables declaration - do not modify//GEN-BEGIN:variables
73
// End of variables declaration//GEN-END:variables
74

75     public void addNotify() {
76         super.addNotify();
77         
78 // System.out.println("WSClientCustomizer: addNotify (" + this.getComponentCount() + " subcomponents)");
79
JPanel JavaDoc component = wsCompileEditor.getComponent();
80
81         removeAll(); // !PW is this necessary?
82
add(component);
83         
84         component.addPropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this);
85         component.addPropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this);
86         
87     }
88     
89     public void removeNotify() {
90         super.removeNotify();
91         
92 // System.out.println("WSClientCustomizer: removeNotify");
93
JPanel JavaDoc component = wsCompileEditor.getComponent();
94         component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this);
95         component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this);
96     }
97    
98     private void initValues() {
99 // System.out.println("WSClientCustomizer: initValues");
100
if(wsCompileEditor == null) {
101             WsCompileClientEditorSupport editorSupport = (WsCompileClientEditorSupport) Lookup.getDefault().lookup(WsCompileClientEditorSupport.class);
102             wsCompileEditor = editorSupport.getWsCompileSupport();
103         }
104         
105         wsCompileEditor.initValues(serviceSettings);
106     }
107     
108 // public void validatePanel() throws WizardValidationException {
109
// System.out.println("WSClientCustomizer: validatePanel ");
110
// if(wsCompileEditor != null) {
111
// wsCompileEditor.validatePanel();
112
// }
113
// }
114

115     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
116 // System.out.println("WSClientCustomizer: propertyChange - " + evt.getPropertyName());
117
String JavaDoc prop = evt.getPropertyName();
118         if (WsCompileClientEditorSupport.PROP_FEATURES_CHANGED.equals(prop)) {
119             WsCompileClientEditorSupport.FeatureDescriptor newFeatureDesc = (WsCompileClientEditorSupport.FeatureDescriptor) evt.getNewValue();
120             String JavaDoc propertyName = "wscompile.client." + newFeatureDesc.getServiceName() + ".features";
121             webProperties.putAdditionalProperty(propertyName, newFeatureDesc.getFeatures());
122         } else if (WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED.equals(prop)) {
123             WsCompileClientEditorSupport.OptionDescriptor oldOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getOldValue();
124             WsCompileClientEditorSupport.OptionDescriptor newOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getNewValue();
125             boolean[] oldOptions = oldOptionDesc.getOptions();
126             boolean[] newOptions = newOptionDesc.getOptions();
127             String JavaDoc serviceName = newOptionDesc.getServiceName();
128             String JavaDoc[] propertyNames=new String JavaDoc[]{"verbose","debug","xPrintStackTrace","xSerializable","optimize"}; //NOI18N
129
for (int i=0;i<newOptions.length;i++) {
130                 if (oldOptions[i]!=newOptions[i])
131                     webProperties.putAdditionalProperty("wscompile.client."+serviceName+"."+propertyNames[i], //NOI18N
132
newOptions[i]?"true":"false"); //NOI18N
133
}
134         }
135     }
136     
137     public HelpCtx getHelpCtx() {
138         return new HelpCtx(CustomizerWSClientHost.class);
139     }
140     
141 }
142
Popular Tags