1 19 package org.netbeans.modules.j2ee.sun.ide.sunresources.beans; 20 21 import java.beans.PropertyEditor ; 22 23 import org.openide.util.Utilities; 24 import org.openide.util.HelpCtx; 25 import org.openide.util.NbBundle; 26 27 import org.openide.nodes.Node; 28 import org.openide.nodes.Sheet; 29 import org.openide.nodes.BeanNode; 30 import org.openide.nodes.PropertySupport; 31 32 import org.openide.filesystems.FileObject; 33 34 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePairsPropertyEditor; 35 import org.netbeans.modules.j2ee.sun.ide.sunresources.resourcesloader.SunResourceDataObject; 36 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.Resources; 37 38 42 public class ConnPoolBeanDataNode extends BaseResourceNode implements java.beans.PropertyChangeListener { 43 ConnPoolBean resource = null; 44 45 public ConnPoolBeanDataNode(SunResourceDataObject obj, ConnPoolBean key) { 46 super(obj); 47 setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ide/resources/ResNodeNodeIcon.gif"); setShortDescription (NbBundle.getMessage (ConnPoolBeanDataNode.class, "DSC_ConnPoolNode")); 50 resource = key; 51 key.addPropertyChangeListener(this); 52 53 Class clazz = key.getClass(); 54 try{ 55 createProperties(key, Utilities.getBeanInfo(clazz)); 56 } catch (Exception e){ 57 e.printStackTrace(); 58 } 59 60 } 61 62 protected ConnPoolBeanDataNode getConnPoolBeanDataNode(){ 63 return this; 64 } 65 66 protected ConnPoolBean getConnPoolBean(){ 67 return resource; 68 } 69 70 public HelpCtx getHelpCtx() { 71 return null; } 73 74 public void propertyChange(java.beans.PropertyChangeEvent evt) { 75 FileObject resFile = getConnPoolBeanDataNode().getDataObject().getPrimaryFile(); 76 ResourceUtils.saveNodeToXml(resFile, resource.getGraph()); 77 } 78 79 public Resources getBeanGraph(){ 80 return resource.getGraph(); 81 } 82 83 protected void createProperties(Object bean, java.beans.BeanInfo info) { 84 BeanNode.Descriptor d = BeanNode.computeProperties(bean, info); 85 Node.Property p = new PropertySupport.ReadWrite( 86 "extraParams", ConnPoolBeanDataNode.class, NbBundle.getMessage(ConnPoolBeanDataNode.class,"LBL_ExtParams"), NbBundle.getMessage(ConnPoolBeanDataNode.class,"DSC_ExtParams") ) { 90 public Object getValue() { 91 return resource.getExtraParams(); 92 } 93 94 public void setValue(Object val){ 95 if (val instanceof Object []) 96 resource.setExtraParams((Object [])val); 97 } 98 99 public PropertyEditor getPropertyEditor(){ 100 return new NameValuePairsPropertyEditor(resource.getExtraParams()); 101 } 102 }; 103 104 Sheet sets = getSheet(); 105 Sheet.Set pset = Sheet.createPropertiesSet(); 106 pset.put(d.property); 107 pset.put(p); 108 sets.put(pset); 110 } 111 112 113 130 131 133 } 134 | Popular Tags |