KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > websvc > wsdl > config > WsCompileConfigDataNode


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.wsdl.config;
21
22 import java.io.IOException JavaDoc;
23 import java.lang.reflect.InvocationTargetException JavaDoc;
24
25 import java.beans.PropertyChangeListener JavaDoc;
26 import java.beans.PropertyChangeEvent JavaDoc;
27
28 import org.openide.nodes.Node;
29 import org.openide.nodes.Children;
30 import org.openide.nodes.PropertySupport;
31 import org.openide.nodes.Sheet;
32 import org.openide.loaders.DataObject;
33 import org.openide.loaders.DataNode;
34 import org.openide.util.NbBundle;
35
36 import org.netbeans.modules.websvc.wsdl.xmlutils.XMLJ2eeDataObject;
37
38 /** Node for WsCompile configuration files in the explorer views.
39  *
40  * @author Peter Williams
41  */

42 public class WsCompileConfigDataNode extends DataNode {
43
44     private WsCompileConfigDataObject dataObject;
45     private PropertyChangeListener JavaDoc ddListener;
46
47     public WsCompileConfigDataNode(WsCompileConfigDataObject obj) {
48         super(obj, Children.LEAF);
49
50         this.dataObject = obj;
51         setIconBase(dataObject.getIconBaseForValidDocument());
52         setShortDescription(null);
53         addListeners();
54     }
55
56     public void destroy() throws IOException JavaDoc {
57         super.destroy();
58         removeListeners();
59     }
60
61 // public String getShortDescription() {
62
// // !PW FIXME This logic shouldn't be encoded like this, but it for now, it is.
63
// // getStringForInvalidDocument() will return null if there is no error
64
// // which implies the document is parsable (and thus valid).
65
// //
66
// String description = dataObject.getStringForInvalidDocument();
67
// if(description == null) {
68
// description = dataObject.getStringForValidDocument();
69
// }
70
//
71
// return description;
72
// }
73

74     private void addListeners() {
75         ddListener = new PropertyChangeListener JavaDoc() {
76             public void propertyChange (PropertyChangeEvent JavaDoc evt) {
77 // if (WsCompileConfigDataObject.PROP_DOCUMENT_DTD.equals (evt.getPropertyName ())) {
78
// firePropertyChange (PROPERTY_DOCUMENT_TYPE, evt.getOldValue (), evt.getNewValue ());
79
// }
80
if (DataObject.PROP_VALID.equals (evt.getPropertyName ())
81                     && Boolean.TRUE.equals (evt.getNewValue ())) {
82                     removePropertyChangeListener (WsCompileConfigDataNode.this.ddListener);
83                 }
84                 if (WsCompileConfigDataObject.PROP_DOC_VALID.equals (evt.getPropertyName ())) {
85                     if (Boolean.TRUE.equals (evt.getNewValue ())) {
86                         setIconBase (dataObject.getIconBaseForValidDocument ());
87                     } else {
88                         setIconBase (dataObject.getIconBaseForInvalidDocument ());
89                     }
90                 }
91                 if (Node.PROP_PROPERTY_SETS.equals (evt.getPropertyName ())) {
92                     firePropertySetsChange(null,null);
93                 }
94             }
95         };
96
97         dataObject.addPropertyChangeListener(ddListener);
98     }
99
100     private void removeListeners() {
101         dataObject.removePropertyChangeListener(ddListener);
102     }
103
104     protected org.openide.nodes.Sheet createSheet() {
105         Sheet sheet = super.createSheet();
106         Sheet.Set ss = new Sheet.Set();
107
108         ss.setName("service"); // NOI18N
109
ss.setDisplayName(NbBundle.getBundle(WsCompileConfigDataNode.class).getString("LBL_WsConfigPropertiesName")); // NOI18N
110
ss.setShortDescription(NbBundle.getBundle(WsCompileConfigDataNode.class).getString("LBL_WsConfigPropertiesDescription")); // NOI18N
111
ss.put(new PackageProperty());
112
113         sheet.put(ss);
114         return sheet;
115     }
116
117     /** Web Service Client files are generated into a particular java package
118      * that is specified in the WsCompile configuration file. This class
119      * represents that package as a property on the config file node.
120      */

121     private final class PackageProperty extends PropertySupport.ReadWrite {
122
123         public PackageProperty() {
124             super("Package" /*NOI18N*/, String JavaDoc.class,
125                 NbBundle.getBundle(WsCompileConfigDataNode.class).getString("LBL_WsConfigPackagePropertyName"), // NOI18N
126
NbBundle.getBundle(WsCompileConfigDataNode.class).getString("LBL_WsConfigPackagePropertyDescription")); // NOI18N
127
}
128
129         public Object JavaDoc getValue() throws IllegalAccessException JavaDoc, InvocationTargetException JavaDoc {
130             return dataObject.getServicePackageName();
131         }
132
133         public void setValue(Object JavaDoc val) throws IllegalAccessException JavaDoc, IllegalArgumentException JavaDoc, InvocationTargetException JavaDoc {
134             if(val instanceof String JavaDoc) {
135                 dataObject.setServicePackageName((String JavaDoc) val);
136             } else {
137                 throw new IllegalArgumentException JavaDoc();
138             }
139         }
140     }
141 }
142
Popular Tags