1 19 25 26 package org.netbeans.modules.j2ee.sun.share.serverresources; 27 28 import java.beans.*; 29 30 import org.netbeans.modules.j2ee.sun.dd.api.DDProvider; 31 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.Resources; 32 import org.netbeans.modules.j2ee.sun.dd.api.serverresources.PropertyElement; 33 34 import org.netbeans.modules.j2ee.sun.ide.editors.NameValuePair; 35 36 37 41 public class BaseResource extends Object implements java.io.Serializable { 42 43 protected String name; 44 protected String description; 45 protected NameValuePair[] extraParams; 46 47 transient protected PropertyChangeSupport propertySupport; 48 49 50 public BaseResource() { 51 propertySupport = new PropertyChangeSupport(this); 52 } 53 54 protected void initPropertyChangeSupport(){ 55 if(propertySupport==null){ 56 propertySupport = new PropertyChangeSupport ( this ); 57 } 58 59 } 60 61 public void addPropertyChangeListener (PropertyChangeListener listener) { 62 initPropertyChangeSupport(); 63 propertySupport.addPropertyChangeListener (listener); 64 } 65 66 public void removePropertyChangeListener (PropertyChangeListener listener) { 67 initPropertyChangeSupport(); 68 propertySupport.removePropertyChangeListener (listener); 69 } 70 71 public String getName() { 72 return name; 73 } 74 public void setName(String value) { 75 String oldValue = name; 76 this.name = value; 77 initPropertyChangeSupport(); 78 propertySupport.firePropertyChange ("name", oldValue, name); } 80 81 public String getDescription() { 82 return description; 83 } 84 public void setDescription(String value) { 85 String oldValue = description; 86 this.description = value; 87 initPropertyChangeSupport(); 88 propertySupport.firePropertyChange ("description", oldValue, description); } 90 91 public NameValuePair[] getExtraParams() { 92 if(this.extraParams == null){ 93 this.extraParams = new NameValuePair[0]; 94 } 95 return this.extraParams; 96 } 97 public void setExtraParams(Object [] value) { 98 NameValuePair[] pairs = new NameValuePair[value.length]; 99 for (int i = 0; i < value.length; i++) { 100 NameValuePair val = (NameValuePair)value[i]; 101 NameValuePair pair = new NameValuePair(); 102 pair.setParamName(val.getParamName()); 103 pair.setParamValue(val.getParamValue()); 104 pairs[i] = pair; 106 } 107 NameValuePair[] oldValue = extraParams; 108 this.extraParams = pairs; 109 initPropertyChangeSupport(); 110 propertySupport.firePropertyChange ("extraParams", oldValue, extraParams); } 112 113 public Resources getResourceGraph(){ 114 return DDProvider.getDefault().getResourcesGraph(); 115 } 116 117 public PropertyElement populatePropertyElement(PropertyElement prop, NameValuePair pair){ 118 prop.setName(pair.getParamName()); 119 prop.setValue(pair.getParamValue()); 120 return prop; 121 } 122 } 123 | Popular Tags |