KickJava   Java API By Example, From Geeks To Geeks.

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


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  * WS70ExternalResourceBeanDataNode.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 WS70ExternalResourceBeanDataNode extends WS70BaseResourceNode implements java.beans.PropertyChangeListener JavaDoc{
48     private WS70ExternalResourceBean resource =null;
49     
50     /**
51      * Creates a new instance of WS70ExternalResourceBeanDataNode
52      */

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