KickJava   Java API By Example, From Geeks To Geeks.

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


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  * JavaMailSessionBeanDataNode.java
21  *
22  * Created on September 17, 2003, 3:09 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
44 /**
45  *
46  * @author nityad
47  */

48 public class JavaMailSessionBeanDataNode extends BaseResourceNode implements java.beans.PropertyChangeListener JavaDoc{
49     private JavaMailSessionBean resource = null;
50    
51     /** Creates a new instance of JavaMailSessionBeanDataNode */
52     public JavaMailSessionBeanDataNode(SunResourceDataObject obj, JavaMailSessionBean key) {
53         super(obj);
54         resource = key;
55         setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ide/resources/ResNodeNodeIcon.gif"); //NOI18N
56
setShortDescription (NbBundle.getMessage (JavaMailSessionBeanDataNode.class, "DSC_MailNode"));//NOI18N
57
key.addPropertyChangeListener(this);
58         
59         Class JavaDoc clazz = key.getClass ();
60         try{
61             createProperties(key, Utilities.getBeanInfo(clazz));
62         } catch (Exception JavaDoc e){
63             e.printStackTrace();
64         }
65     }
66     
67     protected JavaMailSessionBeanDataNode getJavaMailSessionBeanDataNode(){
68         return this;
69     }
70     
71     protected JavaMailSessionBean getJavaMailSessionBean(){
72         return resource;
73     }
74     
75     public void propertyChange(java.beans.PropertyChangeEvent JavaDoc evt) {
76         FileObject resFile = getJavaMailSessionBeanDataNode().getDataObject().getPrimaryFile();
77         ResourceUtils.saveNodeToXml(resFile, resource.getGraph());
78     }
79     
80     public Resources getBeanGraph(){
81         return resource.getGraph();
82     }
83     
84     public HelpCtx getHelpCtx() {
85         return null; // new HelpCtx("AS_Res_Mail");//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", JavaMailSessionBeanDataNode.class, //NOI18N
92
NbBundle.getMessage(JavaMailSessionBeanDataNode.class,"LBL_ExtParams"), //NOI18N
93
NbBundle.getMessage(JavaMailSessionBeanDataNode.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 // pset.setValue("helpID", "AS_Res_Mail_Props"); //NOI18N
114
sets.put(pset);
115     }
116         
117 }
118
Popular Tags