KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ws7 > serverresources > beans > WS70CustomResourceBeanDataNode


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 /*
21  * WS70CustomResourceBeanDataNode.java
22  */

23
24 package org.netbeans.modules.j2ee.sun.ws7.serverresources.beans;
25 import java.beans.PropertyEditor JavaDoc;
26
27 import org.openide.util.Utilities;
28 import org.openide.util.HelpCtx;
29 import org.openide.util.NbBundle;
30
31 import org.openide.nodes.Node;
32 import org.openide.nodes.Sheet;
33 import org.openide.nodes.BeanNode;
34 import org.openide.nodes.PropertySupport;
35
36 import org.openide.filesystems.FileObject;
37
38 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePairsPropertyEditor;
39 import org.netbeans.modules.j2ee.sun.ws7.serverresources.loaders.SunWS70ResourceDataObject;
40
41 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.WS70Resources;
42
43 /**
44  *
45  * @author Administrator
46  */

47 public class WS70CustomResourceBeanDataNode extends WS70BaseResourceNode implements java.beans.PropertyChangeListener JavaDoc{
48     private WS70CustomResourceBean resource =null;
49     
50     /** Creates a new instance of WS70CustomResourceBeanDataNode */
51     public WS70CustomResourceBeanDataNode(SunWS70ResourceDataObject obj, WS70CustomResourceBean key) {
52         super(obj);
53         resource = key;
54         setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ws7/resources/ResNodeNodeIcon.gif"); //NOI18N
55
setShortDescription (NbBundle.getMessage (WS70CustomResourceBeanDataNode.class, "DSC_CustomNode"));//NOI18N
56
key.addPropertyChangeListener(this);
57         
58         Class JavaDoc clazz = key.getClass ();
59         try{
60             createProperties(key, Utilities.getBeanInfo(clazz));
61         } catch (Exception JavaDoc e){
62             e.printStackTrace();
63         }
64     }
65     protected WS70CustomResourceBeanDataNode getWS70CustomResourceBeanDataNode(){
66         return this;
67     }
68     
69     protected WS70CustomResourceBean getWS70CustomResourceBean(){
70         return resource;
71     }
72     
73     public void propertyChange(java.beans.PropertyChangeEvent JavaDoc evt) {
74         FileObject resFile = getWS70CustomResourceBeanDataNode().getDataObject().getPrimaryFile();
75         WS70ResourceUtils.saveNodeToXml(resFile, resource.getGraph());
76     }
77     
78     public WS70Resources getBeanGraph(){
79         return resource.getGraph();
80     }
81     
82     public HelpCtx getHelpCtx() {
83         return null; // new HelpCtx("AS_Res_External_Jndi");//NOI18N
84
}
85     
86     protected void createProperties(Object JavaDoc bean, java.beans.BeanInfo JavaDoc info) {
87         BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
88         Node.Property p = new PropertySupport.ReadWrite(
89         "extraParams", WS70CustomResourceBeanDataNode.class, //NOI18N
90
NbBundle.getMessage(WS70CustomResourceBeanDataNode.class,"LBL_ExtParams"), //NOI18N
91
NbBundle.getMessage(WS70CustomResourceBeanDataNode.class,"DSC_ExtParams") //NOI18N
92
) {
93             public Object JavaDoc getValue() {
94                 return resource.getExtraParams();
95             }
96             
97             public void setValue(Object JavaDoc val){
98                 if (val instanceof Object JavaDoc[])
99                     resource.setExtraParams((Object JavaDoc[])val);
100             }
101             
102             public PropertyEditor JavaDoc getPropertyEditor(){
103                 return new NameValuePairsPropertyEditor(resource.getExtraParams());
104             }
105         };
106         
107         Sheet sets = getSheet();
108         Sheet.Set pset = Sheet.createPropertiesSet();
109         pset.put(d.property);
110         pset.put(p);
111         sets.put(pset);
112     }
113 }
114
Popular Tags