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 PersistenceManagerBeanDataNode extends BaseResourceNode implements java.beans.PropertyChangeListener { 43 PersistenceManagerBean resource = null; 44 45 public PersistenceManagerBeanDataNode(SunResourceDataObject obj, PersistenceManagerBean key) { 46 super(obj); 47 setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ide/resources/ResNodeNodeIcon.gif"); setShortDescription (NbBundle.getMessage (PersistenceManagerBeanDataNode.class, "DSC_PersistenceManagerNode")); resource = key; 50 51 key.addPropertyChangeListener(this); 52 Class clazz = key.getClass (); 53 try{ 54 createProperties(key, Utilities.getBeanInfo(clazz)); 55 } catch (Exception e){ 56 e.printStackTrace(); 57 } 58 59 } 60 61 protected PersistenceManagerBeanDataNode getPersistenceManagerBeanDataNode(){ 62 return this; 63 } 64 65 protected PersistenceManagerBean getPersistenceManagerBean(){ 66 return resource; 67 } 68 69 public Resources getBeanGraph(){ 70 return resource.getGraph(); 71 } 72 73 public void propertyChange(java.beans.PropertyChangeEvent evt) { 74 FileObject resFile = getPersistenceManagerBeanDataNode().getDataObject().getPrimaryFile(); 75 ResourceUtils.saveNodeToXml(resFile, resource.getGraph()); 76 } 77 78 public HelpCtx getHelpCtx() { 79 return null; } 81 82 protected void createProperties(Object bean, java.beans.BeanInfo info) { 83 BeanNode.Descriptor d = BeanNode.computeProperties(bean, info); 84 Node.Property p = new PropertySupport.ReadWrite( 85 "extraParams", PersistenceManagerBeanDataNode.class, NbBundle.getMessage(PersistenceManagerBeanDataNode.class,"LBL_ExtParams"), NbBundle.getMessage(PersistenceManagerBeanDataNode.class,"DSC_ExtParams") ) { 89 public Object getValue() { 90 return resource.getExtraParams(); 91 } 92 93 public void setValue(Object val){ 94 if (val instanceof Object []) 95 resource.setExtraParams((Object [])val); 96 } 97 98 public PropertyEditor getPropertyEditor(){ 99 return new NameValuePairsPropertyEditor(resource.getExtraParams()); 100 } 101 }; 102 103 Sheet sets = getSheet(); 104 Sheet.Set pset = Sheet.createPropertiesSet(); 105 pset.put(d.property); 106 pset.put(p); 107 sets.put(pset); 109 } 110 111 } 112 | Popular Tags |