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 import org.netbeans.modules.j2ee.sun.sunresources.beans.WizardConstants; 44 45 49 public class JMSBeanDataNode extends BaseResourceNode implements java.beans.PropertyChangeListener { 50 private JMSBean resource = null; 51 52 53 public JMSBeanDataNode(SunResourceDataObject obj, JMSBean key) { 54 super(obj); 55 resource = key; 56 setIconBaseWithExtension("org/netbeans/modules/j2ee/sun/ide/resources/ResNodeNodeIcon.gif"); setShortDescription (NbBundle.getMessage (JMSBeanDataNode.class, "DSC_JmsNode")); 59 key.addPropertyChangeListener(this); 60 Class clazz = key.getClass (); 61 try{ 62 createProperties(key, Utilities.getBeanInfo(clazz)); 63 } catch (Exception e){ 64 e.printStackTrace(); 65 } 66 } 67 68 protected JMSBeanDataNode getJMSBeanDataNode(){ 69 return this; 70 } 71 72 protected JMSBean getJMSBean(){ 73 return resource; 74 } 75 76 public void propertyChange(java.beans.PropertyChangeEvent evt) { 77 FileObject resFile = getJMSBeanDataNode().getDataObject().getPrimaryFile(); 78 ResourceUtils.saveNodeToXml(resFile, getBeanGraph()); 79 } 80 81 public Resources getBeanGraph(){ 82 String type = getJmsResType(); 83 if(type.equals(WizardConstants.__QUEUE) || type.equals(WizardConstants.__TOPIC)) 84 return resource.getAdminObjectGraph(); 85 else 86 return resource.getConnectorGraph(); 87 } 88 89 public String getJmsResType(){ 90 return resource.getResType(); 91 } 92 93 public HelpCtx getHelpCtx() { 94 return null; } 96 97 protected void createProperties(Object bean, java.beans.BeanInfo info) { 98 BeanNode.Descriptor d = BeanNode.computeProperties(bean, info); 99 Node.Property p = new PropertySupport.ReadWrite( 100 "extraParams", JMSBeanDataNode.class, NbBundle.getMessage(JMSBeanDataNode.class,"LBL_ExtParams"), NbBundle.getMessage(JMSBeanDataNode.class,"DSC_ExtParams") ) { 104 public Object getValue() { 105 return resource.getExtraParams(); 106 } 107 108 public void setValue(Object val){ 109 if (val instanceof Object []) 110 resource.setExtraParams((Object [])val); 111 } 112 113 public PropertyEditor getPropertyEditor(){ 114 return new NameValuePairsPropertyEditor(resource.getExtraParams()); 115 } 116 }; 117 118 Sheet sets = getSheet(); 119 Sheet.Set pset = Sheet.createPropertiesSet(); 120 pset.put(d.property); 121 pset.put(p); 122 sets.put(pset); 124 } 125 126 } 127 | Popular Tags |