KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbjarproject > 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.j2ee.ejbjarproject.ui.customizer;
21
22 import java.util.Collections JavaDoc;
23 import java.util.List JavaDoc;
24
25 import java.beans.PropertyChangeEvent JavaDoc;
26 import java.beans.PropertyChangeListener JavaDoc;
27
28 import javax.swing.JPanel JavaDoc;
29 import javax.swing.JLabel JavaDoc;
30 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport;
31
32 import org.w3c.dom.Document JavaDoc;
33 import org.w3c.dom.Element JavaDoc;
34 import org.w3c.dom.NodeList JavaDoc;
35
36 import org.openide.WizardValidationException;
37 import org.openide.util.HelpCtx;
38 import org.openide.util.Lookup;
39 import org.openide.filesystems.FileObject;
40
41 import org.netbeans.spi.project.support.ant.AntProjectHelper;
42 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProvider;
43 import org.netbeans.modules.j2ee.ejbjarproject.EjbJarProjectType;
44
45 import org.netbeans.modules.websvc.spi.webservices.WebServicesConstants;
46 import org.netbeans.modules.websvc.api.client.WsCompileClientEditorSupport;
47
48
49 /** Host for WsCompile features editor for editing the features enabled for
50  * running WsCompile on a web service or a web service client.
51  *
52  * property format: 'webservice.client.[servicename].features=xxx,yyy,zzz
53  *
54  * @author Peter Williams
55  */

56 public class CustomizerWSClientHost extends javax.swing.JPanel JavaDoc
57     implements PropertyChangeListener JavaDoc, HelpCtx.Provider { // WebCustomizer.Panel, WebCustomizer.ValidatingPanel
58

59     private EjbJarProjectProperties ejbJarProperties;
60     private WsCompileClientEditorSupport.Panel wsCompileEditor;
61
62     private List JavaDoc serviceSettings;
63     
64     public CustomizerWSClientHost(EjbJarProjectProperties ejbJarProperties, List JavaDoc serviceSettings) {
65         assert serviceSettings != null && serviceSettings.size() > 0;
66         initComponents();
67
68         this.ejbJarProperties = ejbJarProperties;
69         this.wsCompileEditor = null;
70         this.serviceSettings = serviceSettings;
71         
72         initValues();
73     }
74     
75     /** This method is called from within the constructor to
76      * initialize the form.
77      * WARNING: Do NOT modify this code. The content of this method is
78      * always regenerated by the Form Editor.
79      */

80     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
81
private void initComponents() {
82
83         setLayout(new java.awt.BorderLayout JavaDoc());
84
85     }
86     // </editor-fold>//GEN-END:initComponents
87

88     
89     // Variables declaration - do not modify//GEN-BEGIN:variables
90
// End of variables declaration//GEN-END:variables
91

92     public void addNotify() {
93         super.addNotify();
94
95         JPanel JavaDoc component = wsCompileEditor.getComponent();
96
97         removeAll(); // !PW is this necessary?
98
add(component);
99
100         component.addPropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this);
101         component.addPropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this);
102     }
103
104     public void removeNotify() {
105         super.removeNotify();
106
107         JPanel JavaDoc component = wsCompileEditor.getComponent();
108         component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_FEATURES_CHANGED, this);
109         component.removePropertyChangeListener(WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED, this);
110     }
111
112     public void initValues() {
113         if(wsCompileEditor == null) {
114             WsCompileClientEditorSupport editorSupport = (WsCompileClientEditorSupport) Lookup.getDefault().lookup(WsCompileClientEditorSupport.class);
115             wsCompileEditor = editorSupport.getWsCompileSupport();
116         }
117
118         wsCompileEditor.initValues(serviceSettings);
119     }
120
121     /*public void validatePanel() throws WizardValidationException {
122         if(wsCompileEditor != null) {
123             wsCompileEditor.validatePanel();
124         }
125     }*/

126
127     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
128         String JavaDoc prop = evt.getPropertyName();
129         if (WsCompileClientEditorSupport.PROP_FEATURES_CHANGED.equals(prop)) {
130             WsCompileClientEditorSupport.FeatureDescriptor newFeatureDesc = (WsCompileClientEditorSupport.FeatureDescriptor) evt.getNewValue();
131             String JavaDoc propertyName = "wscompile.client." + newFeatureDesc.getServiceName() + ".features";
132             ejbJarProperties.putAdditionalProperty(propertyName, newFeatureDesc.getFeatures());
133         } else if (WsCompileClientEditorSupport.PROP_OPTIONS_CHANGED.equals(prop)) {
134             WsCompileClientEditorSupport.OptionDescriptor oldOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getOldValue();
135             WsCompileClientEditorSupport.OptionDescriptor newOptionDesc = (WsCompileClientEditorSupport.OptionDescriptor) evt.getNewValue();
136             boolean[] oldOptions = oldOptionDesc.getOptions();
137             boolean[] newOptions = newOptionDesc.getOptions();
138             String JavaDoc serviceName = newOptionDesc.getServiceName();
139             String JavaDoc[] propertyNames=new String JavaDoc[]{"verbose","debug","xPrintStackTrace","xSerializable","optimize"}; //NOI18N
140
for (int i=0;i<newOptions.length;i++) {
141                 if (oldOptions[i]!=newOptions[i])
142                     ejbJarProperties.putAdditionalProperty("wscompile.client."+serviceName+"."+propertyNames[i], //NOI18N
143
newOptions[i]?"true":"false"); //NOI18N
144
}
145         }
146     }
147     
148     public HelpCtx getHelpCtx() {
149         return new HelpCtx(CustomizerWSClientHost.class);
150     }
151 }
152
Popular Tags