KickJava   Java API By Example, From Geeks To Geeks.

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


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  * JMSBeanDataNode.java
21  *
22  * Created on November 13, 2003, 3:43 PM
23  */

24
25 package org.netbeans.modules.j2ee.sun.ide.sunresources.beans;
26
27 import java.beans.PropertyEditor JavaDoc;
28
29 import org.openide.util.Utilities;
30 import org.openide.util.HelpCtx;
31 import org.openide.util.NbBundle;
32
33 import org.openide.nodes.Node;
34 import org.openide.nodes.Sheet;
35 import org.openide.nodes.BeanNode;
36 import org.openide.nodes.PropertySupport;
37
38 import org.openide.filesystems.FileObject;
39
40 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePairsPropertyEditor;
41 import org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject;
42 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.Resources;
43 import org.netbeans.modules.j2ee.sun.sunresources.beans.WizardConstants;
44
45 /**
46  *
47  * @author nityad
48  */

49 public class JMSBeanDataNode extends BaseResourceNode implements java.beans.PropertyChangeListener JavaDoc{
50     private JMSBean resource = null;
51      
52     /** Creates a new instance of JMSBeanDataNode */
53     public JMSBeanDataNode(SunResourceDataObject obj, JMSBean key) {
54         super(obj);
55         resource = key;
56         setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ide/resources/ResNodeNodeIcon.gif"); //NOI18N
57
setShortDescription (NbBundle.getMessage (JMSBeanDataNode.class, "DSC_JmsNode"));//NOI18N
58

59         key.addPropertyChangeListener(this);
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     
68     protected JMSBeanDataNode getJMSBeanDataNode(){
69         return this;
70     }
71     
72     protected JMSBean getJMSBean(){
73         return resource;
74     }
75     
76     public void propertyChange(java.beans.PropertyChangeEvent JavaDoc evt) {
77         FileObject resFile = getJMSBeanDataNode().getDataObject().getPrimaryFile();
78         ResourceUtils.saveNodeToXml(resFile, getBeanGraph());
79     }
80     
81     public Resources getBeanGraph(){
82         String JavaDoc type = getJmsResType();
83         if(type.equals(WizardConstants.__QUEUE) || type.equals(WizardConstants.__TOPIC))
84             return resource.getAdminObjectGraph();
85         else
86             return resource.getConnectorGraph();
87     }
88     
89     public String JavaDoc getJmsResType(){
90         return resource.getResType();
91     }
92     
93     public HelpCtx getHelpCtx() {
94         return null; // new HelpCtx("AS_Res_JMS");//NOI18N
95
}
96     
97     protected void createProperties(Object JavaDoc bean, java.beans.BeanInfo JavaDoc info) {
98         BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
99         Node.Property p = new PropertySupport.ReadWrite(
100         "extraParams", JMSBeanDataNode.class, //NOI18N
101
NbBundle.getMessage(JMSBeanDataNode.class,"LBL_ExtParams"), //NOI18N
102
NbBundle.getMessage(JMSBeanDataNode.class,"DSC_ExtParams") //NOI18N
103
) {
104             public Object JavaDoc getValue() {
105                 return resource.getExtraParams();
106             }
107             
108             public void setValue(Object JavaDoc val){
109                 if (val instanceof Object JavaDoc[])
110                     resource.setExtraParams((Object JavaDoc[])val);
111             }
112             
113             public PropertyEditor JavaDoc getPropertyEditor(){
114                 return new NameValuePairsPropertyEditor(resource.getExtraParams());
115             }
116         };
117         
118         Sheet sets = getSheet();
119         Sheet.Set pset = Sheet.createPropertiesSet();
120         pset.put(d.property);
121         pset.put(p);
122 // pset.setValue("helpID", "AS_Res_JMS_Props"); //NOI18N
123
sets.put(pset);
124     }
125     
126 }
127
Popular Tags