KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > ide > sunresources > beans > ConnPoolBeanDataNode


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 package org.netbeans.modules.j2ee.sun.ide.sunresources.beans;
20
21 import java.beans.PropertyEditor JavaDoc;
22
23 import org.openide.util.Utilities;
24 import org.openide.util.HelpCtx;
25 import org.openide.util.NbBundle;
26
27 import org.openide.nodes.Node;
28 import org.openide.nodes.Sheet;
29 import org.openide.nodes.BeanNode;
30 import org.openide.nodes.PropertySupport;
31
32 import org.openide.filesystems.FileObject;
33
34 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePairsPropertyEditor;
35 import org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject;
36 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.Resources;
37
38 /** A node to represent this object.
39  *
40  * @author nityad
41  */

42 public class ConnPoolBeanDataNode extends BaseResourceNode implements java.beans.PropertyChangeListener JavaDoc{
43     ConnPoolBean resource = null;
44     
45     public ConnPoolBeanDataNode(SunResourceDataObject obj, ConnPoolBean key) {
46         super(obj);
47         setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ide/resources/ResNodeNodeIcon.gif"); //NOI18N
48
setShortDescription (NbBundle.getMessage (ConnPoolBeanDataNode.class, "DSC_ConnPoolNode"));//NOI18N
49

50         resource = key;
51         key.addPropertyChangeListener(this);
52         
53         Class JavaDoc clazz = key.getClass();
54         try{
55             createProperties(key, Utilities.getBeanInfo(clazz));
56         } catch (Exception JavaDoc e){
57             e.printStackTrace();
58         }
59         
60     }
61     
62    protected ConnPoolBeanDataNode getConnPoolBeanDataNode(){
63         return this;
64     }
65     
66     protected ConnPoolBean getConnPoolBean(){
67         return resource;
68     }
69     
70     public HelpCtx getHelpCtx() {
71         return null; // new HelpCtx ("AS_Res_ConnectionPool");//NOI18N
72
}
73     
74     public void propertyChange(java.beans.PropertyChangeEvent JavaDoc evt) {
75         FileObject resFile = getConnPoolBeanDataNode().getDataObject().getPrimaryFile();
76         ResourceUtils.saveNodeToXml(resFile, resource.getGraph());
77     }
78     
79     public Resources getBeanGraph(){
80         return resource.getGraph();
81     }
82     
83     protected void createProperties(Object JavaDoc bean, java.beans.BeanInfo JavaDoc info) {
84         BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
85         Node.Property p = new PropertySupport.ReadWrite(
86         "extraParams", ConnPoolBeanDataNode.class, //NOI18N
87
NbBundle.getMessage(ConnPoolBeanDataNode.class,"LBL_ExtParams"), //NOI18N
88
NbBundle.getMessage(ConnPoolBeanDataNode.class,"DSC_ExtParams") //NOI18N
89
) {
90             public Object JavaDoc getValue() {
91                 return resource.getExtraParams();
92             }
93             
94             public void setValue(Object JavaDoc val){
95                 if (val instanceof Object JavaDoc[])
96                     resource.setExtraParams((Object JavaDoc[])val);
97             }
98             
99             public PropertyEditor JavaDoc getPropertyEditor(){
100                 return new NameValuePairsPropertyEditor(resource.getExtraParams());
101             }
102         };
103         
104         Sheet sets = getSheet();
105         Sheet.Set pset = Sheet.createPropertiesSet();
106         pset.put(d.property);
107         pset.put(p);
108 // pset.setValue("helpID", "AS_Res_ConnectionPool_Props"); //NOI18N
109
sets.put(pset);
110      }
111     
112     
113     /* Example of adding Executor / Debugger / Arguments to node:
114     protected Sheet createSheet() {
115         Sheet sheet = super.createSheet();
116         Sheet.Set set = sheet.get(ExecSupport.PROP_EXECUTION);
117         if (set == null) {
118             set = new Sheet.Set();
119             set.setName(ExecSupport.PROP_EXECUTION);
120             set.setDisplayName(NbBundle.getMessage(SunResourceDataNode.class, "LBL_DataNode_exec_sheet"));
121             set.setShortDescription(NbBundle.getMessage(SunResourceDataNode.class, "HINT_DataNode_exec_sheet"));
122         }
123         ((ExecSupport)getCookie(ExecSupport.class)).addProperties(set);
124         // Maybe:
125         ((CompilerSupport)getCookie(CompilerSupport.class)).addProperties(set);
126         sheet.put(set);
127         return sheet;
128     }
129      */

130     
131     // Don't use getDefaultAction(); just make that first in the data loader's getActions list
132

133 }
134
Popular Tags