1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.sunresources.beans; 26 27 import java.beans.PropertyEditor ; 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 48 public class JavaMailSessionBeanDataNode extends BaseResourceNode implements java.beans.PropertyChangeListener { 49 private JavaMailSessionBean resource = null; 50 51 52 public JavaMailSessionBeanDataNode(SunResourceDataObject obj, JavaMailSessionBean key) { 53 super(obj); 54 resource = key; 55 setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ide/resources/ResNodeNodeIcon.gif"); setShortDescription (NbBundle.getMessage (JavaMailSessionBeanDataNode.class, "DSC_MailNode")); key.addPropertyChangeListener(this); 58 59 Class clazz = key.getClass (); 60 try{ 61 createProperties(key, Utilities.getBeanInfo(clazz)); 62 } catch (Exception 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 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; } 87 88 protected void createProperties(Object bean, java.beans.BeanInfo info) { 89 BeanNode.Descriptor d = BeanNode.computeProperties(bean, info); 90 Node.Property p = new PropertySupport.ReadWrite( 91 "extraParams", JavaMailSessionBeanDataNode.class, NbBundle.getMessage(JavaMailSessionBeanDataNode.class,"LBL_ExtParams"), NbBundle.getMessage(JavaMailSessionBeanDataNode.class,"DSC_ExtParams") ) { 95 public Object getValue() { 96 return resource.getExtraParams(); 97 } 98 99 public void setValue(Object val){ 100 if (val instanceof Object []) 101 resource.setExtraParams((Object [])val); 102 } 103 104 public PropertyEditor 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 sets.put(pset); 115 } 116 117 } 118 | Popular Tags |