1 19 20 package org.netbeans.core.execution.beaninfo.editors; 21 22 import java.awt.*; 23 import java.beans.*; 24 import org.openide.execution.NbClassPath; 25 import org.openide.explorer.propertysheet.ExPropertyEditor; 26 import org.openide.explorer.propertysheet.PropertyEnv; 27 import org.openide.nodes.Node; 28 29 32 public class NbClassPathEditor extends Object implements ExPropertyEditor { 33 private NbClassPath pd; 34 private PropertyChangeSupport support; 35 private boolean editable = true; 36 37 public NbClassPathEditor () { 38 support = new PropertyChangeSupport (this); 39 } 40 41 public Object getValue () { 42 return pd; 43 } 44 45 public void setValue (Object value) { 46 Object old = pd; 47 pd = (NbClassPath) value; 48 support.firePropertyChange ("value", old, pd); } 50 51 public String getAsText () { 52 if ( pd != null ) 53 return pd.getClassPath (); 54 else 55 return "null"; } 57 58 public void setAsText (String string) { 59 if ( ! "null".equals( string ) ) 60 setValue (new NbClassPath (string)); 61 } 62 63 public String getJavaInitializationString () { 64 return "new NbClassPath (" + getAsText () + ")"; } 66 67 public String [] getTags () { 68 return null; 69 } 70 71 public boolean isPaintable () { 72 return false; 73 } 74 75 public void paintValue (Graphics g, Rectangle rectangle) { 76 } 77 78 public boolean supportsCustomEditor () { 79 return true; 80 } 81 82 public Component getCustomEditor () { 83 return new NbClassPathCustomEditor (this); 84 } 85 86 public void addPropertyChangeListener (PropertyChangeListener propertyChangeListener) { 87 support.addPropertyChangeListener (propertyChangeListener); 88 } 89 90 public void removePropertyChangeListener (PropertyChangeListener propertyChangeListener) { 91 support.removePropertyChangeListener (propertyChangeListener); 92 } 93 94 95 public boolean isEditable(){ 96 return editable; 97 } 98 99 public void attachEnv(PropertyEnv env) { 100 FeatureDescriptor desc = env.getFeatureDescriptor(); 101 if (desc instanceof Node.Property){ 102 Node.Property prop = (Node.Property)desc; 103 editable = prop.canWrite(); 104 } 105 } 106 } 107 | Popular Tags |