1 19 20 package org.netbeans.modules.xml.wsdl.ui.view.grapheditor.widget; 21 22 import java.beans.PropertyEditor ; 23 import java.lang.reflect.InvocationTargetException ; 24 25 import org.openide.actions.PropertiesAction; 26 import org.openide.nodes.FilterNode; 27 import org.openide.nodes.Node; 28 import org.openide.util.actions.SystemAction; 29 30 35 public class ReadOnlyWidgetFilterNode extends FilterNode { 36 37 42 public ReadOnlyWidgetFilterNode(Node original) { 43 super(original); 45 } 46 47 @Override 48 public javax.swing.Action [] getActions(boolean context) { 49 return new javax.swing.Action [] { 50 SystemAction.get(PropertiesAction.class)}; 51 } 52 53 54 @Override 55 public PropertySet[] getPropertySets () { 56 PropertySet[] propertySet = super.getPropertySets(); 57 for(int i = 0; i < propertySet.length; i++) { 58 PropertySet pSet = propertySet[i]; 59 ReadOnlyPropertySet rpSet = new ReadOnlyPropertySet(pSet); 60 propertySet[i] = rpSet; 61 } 62 return propertySet; 63 } 64 65 @Override 66 public boolean canRename() 67 { 68 return false; 69 } 70 71 @Override 72 public boolean canDestroy() 73 { 74 return false; 75 } 76 77 @Override 78 public boolean canCut() 79 { 80 return false; 81 } 82 83 @Override 84 public boolean canCopy() 85 { 86 return false; 87 } 88 89 @Override 90 public boolean hasCustomizer() 91 { 92 return false; 93 } 94 95 96 public static class ReadOnlyChildren extends FilterNode.Children { 97 98 public ReadOnlyChildren(Node node) { 99 super(node); 100 } 101 102 @Override 103 protected Node[] createNodes(Node n) { 104 return new Node[] {new ReadOnlyWidgetFilterNode(n)}; 105 } 106 } 107 108 public static class ReadOnlyProperty extends Node.Property { 109 110 private Node.Property mDelegate; 111 112 public ReadOnlyProperty(Node.Property delegate) { 113 super(delegate.getClass()); 114 this.mDelegate = delegate; 115 this.setDisplayName(this.mDelegate.getDisplayName()); 116 this.setName(this.mDelegate.getName()); 117 this.setShortDescription(this.mDelegate.getShortDescription()); 118 this.setExpert(this.mDelegate.isExpert()); 119 this.setHidden(this.mDelegate.isHidden()); 120 this.setPreferred(this.mDelegate.isPreferred()); 121 122 } 123 124 @Override 125 public boolean equals(Object property) { 126 return this.mDelegate.equals(property); 127 } 128 129 @Override 130 public String getHtmlDisplayName() { 131 return this.mDelegate.getHtmlDisplayName(); 132 } 133 134 @Override 135 public PropertyEditor getPropertyEditor() { 136 return this.mDelegate.getPropertyEditor(); 137 } 138 139 @Override 140 public Class getValueType() { 141 return this.mDelegate.getValueType(); 142 } 143 144 @Override 145 public int hashCode() { 146 return this.mDelegate.hashCode(); 147 } 148 149 @Override 150 public boolean isDefaultValue() { 151 return this.mDelegate.isDefaultValue(); 152 } 153 154 @Override 155 public void restoreDefaultValue() throws IllegalAccessException , 156 InvocationTargetException { 157 this.mDelegate.restoreDefaultValue(); 158 } 159 160 @Override 161 public boolean supportsDefaultValue() { 162 return this.mDelegate.supportsDefaultValue(); 163 } 164 165 @Override 166 public boolean canRead() { 167 return true; 168 } 169 170 @Override 171 public boolean canWrite() { 172 return false; 173 } 174 175 @Override 176 public Object getValue() throws IllegalAccessException , 177 InvocationTargetException { 178 return mDelegate.getValue(); 179 } 180 181 @Override 182 public void setValue(Object val) throws IllegalAccessException , 183 IllegalArgumentException , InvocationTargetException { 184 } 186 } 187 188 public static class ReadOnlyPropertySet extends Node.PropertySet { 189 190 private Node.PropertySet mDelegate; 191 192 public ReadOnlyPropertySet(Node.PropertySet delegate) { 193 super(delegate.getName(), delegate.getDisplayName(), delegate.getShortDescription()); 194 this.mDelegate = delegate; 195 } 196 197 @Override 198 public Property[] getProperties() { 199 Property[] properties = this.mDelegate.getProperties(); 200 for(int i = 0; i < properties.length; i++) { 201 Property p = properties[i]; 202 ReadOnlyProperty rp = new ReadOnlyProperty(p); 203 properties[i] = rp; 204 } 205 206 return properties; 207 } 208 } 209 } 210 | Popular Tags |