KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > clientproject > wsclient > 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.j2ee.clientproject.wsclient;
21 import java.util.List JavaDoc;
22
23 import java.beans.PropertyChangeEvent JavaDoc;
24 import java.beans.PropertyChangeListener JavaDoc;
25
26 import javax.swing.JPanel JavaDoc;
27 import org.netbeans.modules.j2ee.clientproject.ui.customizer.AppClientProjectProperties;
28 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport;
29 import org.openide.util.HelpCtx;
30 import org.openide.util.Lookup;
31
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 AppClientProjectProperties j2seProperties;
43     private WsCompileClientEditorSupport.Panel wsCompileEditor;
44
45     private List JavaDoc serviceSettings;
46     
47     public CustomizerWSClientHost(AppClientProjectProperties j2seProperties, List JavaDoc serviceSettings) {
48 // System.out.println("WSClientCustomizer: constructor");
49
assert serviceSettings != null;
50         initComponents();
51
52         this.j2seProperties = j2seProperties;
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     public void removeNotify() {
89         super.removeNotify();
90         
91 // System.out.println("WSClientCustomizer: removeNotify");
92
JPanel JavaDoc component = wsCompileEditor.getComponent();
93         component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this);
94         component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this);
95     }
96    
97     public void initValues() {
98 // System.out.println("WSClientCustomizer: initValues");
99
if (wsCompileEditor == null) {
100             WsCompileClientEditorSupport editorSupport = (WsCompileClientEditorSupport) Lookup.getDefault().lookup(WsCompileClientEditorSupport.class);
101             wsCompileEditor = editorSupport.getWsCompileSupport();
102         }
103         
104         wsCompileEditor.initValues(serviceSettings);
105     }
106     
107 // public void validatePanel() throws WizardValidationException {
108
// System.out.println("WSClientCustomizer: validatePanel ");
109
// if(wsCompileEditor != null) {
110
// wsCompileEditor.validatePanel();
111
// }
112
// }
113

114     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
115         System.out.println("WSClientCustomizer: propertyChange - " + evt.getPropertyName());
116         
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             j2seProperties.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                     j2seProperties.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