1 19 20 23 24 package org.netbeans.modules.j2ee.sun.ws7.serverresources.beans; 25 import java.beans.PropertyEditor ; 26 27 import org.openide.util.Utilities; 28 import org.openide.util.HelpCtx; 29 import org.openide.util.NbBundle; 30 31 import org.openide.nodes.Node; 32 import org.openide.nodes.Sheet; 33 import org.openide.nodes.BeanNode; 34 import org.openide.nodes.PropertySupport; 35 36 import org.openide.filesystems.FileObject; 37 38 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePairsPropertyEditor; 39 import org.netbeans.modules.j2ee.sun.ws7.serverresources.loaders.SunWS70ResourceDataObject; 40 41 import org.netbeans.modules.j2ee.sun.ws7.serverresources.dd.WS70Resources; 42 43 47 public class WS70ExternalResourceBeanDataNode extends WS70BaseResourceNode implements java.beans.PropertyChangeListener { 48 private WS70ExternalResourceBean resource =null; 49 50 53 public WS70ExternalResourceBeanDataNode(SunWS70ResourceDataObject obj, WS70ExternalResourceBean key) { 54 super(obj); 55 resource = key; 56 setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ws7/resources/ResNodeNodeIcon.gif"); setShortDescription (NbBundle.getMessage (WS70ExternalResourceBeanDataNode.class, "DSC_ExternalJndiNode")); key.addPropertyChangeListener(this); 59 60 Class clazz = key.getClass (); 61 try{ 62 createProperties(key, Utilities.getBeanInfo(clazz)); 63 } catch (Exception e){ 64 e.printStackTrace(); 65 } 66 } 67 protected WS70ExternalResourceBeanDataNode getWS70ExternalJndiResourceBeanDataNode(){ 68 return this; 69 } 70 71 protected WS70ExternalResourceBean getWS70ExternalJndiResourceBean(){ 72 return resource; 73 } 74 75 public void propertyChange(java.beans.PropertyChangeEvent evt) { 76 FileObject resFile = getWS70ExternalJndiResourceBeanDataNode().getDataObject().getPrimaryFile(); 77 WS70ResourceUtils.saveNodeToXml(resFile, resource.getGraph()); 78 } 79 80 public WS70Resources 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", WS70ExternalResourceBeanDataNode.class, NbBundle.getMessage(WS70ExternalResourceBeanDataNode.class,"LBL_ExtParams"), NbBundle.getMessage(WS70ExternalResourceBeanDataNode.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); 114 } 115 } 116 | Popular Tags |