001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: /*
042: * JavaMailSessionBeanDataNode.java
043: *
044: * Created on September 17, 2003, 3:09 PM
045: */
046:
047: package org.netbeans.modules.j2ee.sun.ide.sunresources.beans;
048:
049: import java.beans.PropertyEditor;
050:
051: import org.openide.util.Utilities;
052: import org.openide.util.HelpCtx;
053: import org.openide.util.NbBundle;
054:
055: import org.openide.nodes.Node;
056: import org.openide.nodes.Sheet;
057: import org.openide.nodes.BeanNode;
058: import org.openide.nodes.PropertySupport;
059:
060: import org.openide.filesystems.FileObject;
061:
062: import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePairsPropertyEditor;
063: import org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject;
064: import org.netbeans.modules.j2ee.sun.dd.api.serverresources.Resources;
065:
066: /**
067: *
068: * @author nityad
069: */
070: public class JavaMailSessionBeanDataNode extends BaseResourceNode
071: implements java.beans.PropertyChangeListener {
072: private JavaMailSessionBean resource = null;
073:
074: /** Creates a new instance of JavaMailSessionBeanDataNode */
075: public JavaMailSessionBeanDataNode(SunResourceDataObject obj,
076: JavaMailSessionBean key) {
077: super (obj);
078: resource = key;
079: setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ide/resources/ResNodeNodeIcon.gif"); //NOI18N
080: setShortDescription(NbBundle.getMessage(
081: JavaMailSessionBeanDataNode.class, "DSC_MailNode"));//NOI18N
082: key.addPropertyChangeListener(this );
083:
084: Class clazz = key.getClass();
085: try {
086: createProperties(key, Utilities.getBeanInfo(clazz));
087: } catch (Exception e) {
088: e.printStackTrace();
089: }
090: }
091:
092: protected JavaMailSessionBeanDataNode getJavaMailSessionBeanDataNode() {
093: return this ;
094: }
095:
096: protected JavaMailSessionBean getJavaMailSessionBean() {
097: return resource;
098: }
099:
100: public void propertyChange(java.beans.PropertyChangeEvent evt) {
101: FileObject resFile = getJavaMailSessionBeanDataNode()
102: .getDataObject().getPrimaryFile();
103: ResourceUtils.saveNodeToXml(resFile, resource.getGraph());
104: }
105:
106: public Resources getBeanGraph() {
107: return resource.getGraph();
108: }
109:
110: public HelpCtx getHelpCtx() {
111: return null; // new HelpCtx("AS_Res_Mail");//NOI18N
112: }
113:
114: protected void createProperties(Object bean,
115: java.beans.BeanInfo info) {
116: BeanNode.Descriptor d = BeanNode.computeProperties(bean, info);
117: Node.Property p = new PropertySupport.ReadWrite("extraParams",
118: JavaMailSessionBeanDataNode.class, //NOI18N
119: NbBundle.getMessage(JavaMailSessionBeanDataNode.class,
120: "LBL_ExtParams"), //NOI18N
121: NbBundle.getMessage(JavaMailSessionBeanDataNode.class,
122: "DSC_ExtParams") //NOI18N
123: ) {
124: public Object getValue() {
125: return resource.getExtraParams();
126: }
127:
128: public void setValue(Object val) {
129: if (val instanceof Object[])
130: resource.setExtraParams((Object[]) val);
131: }
132:
133: public PropertyEditor getPropertyEditor() {
134: return new NameValuePairsPropertyEditor(resource
135: .getExtraParams());
136: }
137: };
138:
139: Sheet sets = getSheet();
140: Sheet.Set pset = Sheet.createPropertiesSet();
141: pset.put(d.property);
142: pset.put(p);
143: // pset.setValue("helpID", "AS_Res_Mail_Props"); //NOI18N
144: sets.put(pset);
145: }
146:
147: }
|