KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
39  *
40  * @author nityad
41  */

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