1 19 24 package org.openide.explorer.propertysheet; 25 26 import org.openide.nodes.Node; 27 import org.openide.nodes.Node.Property; 28 29 import java.beans.PropertyEditor ; 30 31 import javax.swing.SwingUtilities ; 32 import org.openide.util.Exceptions; 33 34 35 48 class ReusablePropertyModel implements ExPropertyModel { 49 static final boolean DEBUG = Boolean.getBoolean("netbeans.reusable.strictthreads"); 50 private transient Property PROPERTY = null; 51 private final ReusablePropertyEnv env; 52 53 54 public ReusablePropertyModel(ReusablePropertyEnv env) { 55 this.env = env; 56 env.setReusablePropertyModel(this); 57 } 58 59 void clear() { 60 PROPERTY = null; 61 } 62 63 65 public void addPropertyChangeListener(java.beans.PropertyChangeListener l) { 66 } 67 68 70 public void removePropertyChangeListener(java.beans.PropertyChangeListener l) { 71 } 72 73 public PropertyEditor getPropertyEditor() { 74 Node.Property p = getProperty(); 75 76 return PropUtils.getPropertyEditor(p, !PropUtils.isExternallyEdited(p)); 80 } 81 82 public Class getPropertyEditorClass() { 83 if (DEBUG) { 84 checkThread(); 85 } 86 87 return getPropertyEditor().getClass(); 88 } 89 90 public Class getPropertyType() { 91 if (DEBUG) { 92 checkThread(); 93 } 94 95 return getProperty().getValueType(); 96 } 97 98 public Object getValue() throws java.lang.reflect.InvocationTargetException { 99 if (DEBUG) { 100 checkThread(); 101 } 102 103 try { 104 return getProperty().getValue(); 105 } catch (IllegalAccessException iae) { 106 Exceptions.printStackTrace(iae); 107 } 108 109 return null; 110 } 111 112 public void setValue(Object v) throws java.lang.reflect.InvocationTargetException { 113 if (DEBUG) { 114 checkThread(); 115 } 116 117 try { 118 getProperty().setValue(v); 119 } catch (IllegalAccessException iae) { 120 Exceptions.printStackTrace(iae); 121 } 122 } 123 124 public Object [] getBeans() { 125 if (DEBUG) { 126 checkThread(); 127 } 128 129 if (env.getNode() instanceof ProxyNode) { 130 return ((ProxyNode) env.getNode()).getOriginalNodes(); 131 } else { 132 return new Object [] { env.getNode() }; 133 } 134 } 135 136 public java.beans.FeatureDescriptor getFeatureDescriptor() { 137 if (DEBUG) { 138 checkThread(); 139 } 140 141 return getProperty(); 142 } 143 144 146 static void checkThread() { 147 if (SwingUtilities.isEventDispatchThread() == false) { 148 throw new IllegalStateException ("Reusable property model accessed from off the AWT thread."); 149 } 150 } 151 152 public Node.Property getProperty() { 153 return PROPERTY; 154 } 155 156 public void setProperty(Node.Property PROPERTY) { 157 this.PROPERTY = PROPERTY; 158 } 159 } 160 | Popular Tags |