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 WS70CustomResourceBeanDataNode extends WS70BaseResourceNode implements java.beans.PropertyChangeListener { 48 private WS70CustomResourceBean resource =null; 49 50 51 public WS70CustomResourceBeanDataNode(SunWS70ResourceDataObject obj, WS70CustomResourceBean key) { 52 super(obj); 53 resource = key; 54 setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ws7/resources/ResNodeNodeIcon.gif"); setShortDescription (NbBundle.getMessage (WS70CustomResourceBeanDataNode.class, "DSC_CustomNode")); key.addPropertyChangeListener(this); 57 58 Class clazz = key.getClass (); 59 try{ 60 createProperties(key, Utilities.getBeanInfo(clazz)); 61 } catch (Exception e){ 62 e.printStackTrace(); 63 } 64 } 65 protected WS70CustomResourceBeanDataNode getWS70CustomResourceBeanDataNode(){ 66 return this; 67 } 68 69 protected WS70CustomResourceBean getWS70CustomResourceBean(){ 70 return resource; 71 } 72 73 public void propertyChange(java.beans.PropertyChangeEvent evt) { 74 FileObject resFile = getWS70CustomResourceBeanDataNode().getDataObject().getPrimaryFile(); 75 WS70ResourceUtils.saveNodeToXml(resFile, resource.getGraph()); 76 } 77 78 public WS70Resources getBeanGraph(){ 79 return resource.getGraph(); 80 } 81 82 public HelpCtx getHelpCtx() { 83 return null; } 85 86 protected void createProperties(Object bean, java.beans.BeanInfo info) { 87 BeanNode.Descriptor d = BeanNode.computeProperties(bean, info); 88 Node.Property p = new PropertySupport.ReadWrite( 89 "extraParams", WS70CustomResourceBeanDataNode.class, NbBundle.getMessage(WS70CustomResourceBeanDataNode.class,"LBL_ExtParams"), NbBundle.getMessage(WS70CustomResourceBeanDataNode.class,"DSC_ExtParams") ) { 93 public Object getValue() { 94 return resource.getExtraParams(); 95 } 96 97 public void setValue(Object val){ 98 if (val instanceof Object []) 99 resource.setExtraParams((Object [])val); 100 } 101 102 public PropertyEditor getPropertyEditor(){ 103 return new NameValuePairsPropertyEditor(resource.getExtraParams()); 104 } 105 }; 106 107 Sheet sets = getSheet(); 108 Sheet.Set pset = Sheet.createPropertiesSet(); 109 pset.put(d.property); 110 pset.put(p); 111 sets.put(pset); 112 } 113 } 114 | Popular Tags |