001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * Portions Copyrighted 2007 Sun Microsystems, Inc.
027: */
028: package org.netbeans.modules.compapp.casaeditor.nodes;
029:
030: import java.beans.PropertyEditor;
031: import java.lang.reflect.InvocationTargetException;
032: import org.openide.nodes.FilterNode;
033: import org.openide.nodes.Node;
034: import org.openide.actions.PropertiesAction;
035: import org.openide.util.actions.SystemAction;
036:
037: /**
038: *
039: * @author rdara
040: */
041: public class ReadOnlyFilterNode extends FilterNode {
042:
043: public ReadOnlyFilterNode(Node original) {
044: super (original);
045: }
046:
047: @Override
048: public PropertySet[] getPropertySets() {
049: PropertySet[] propertySet = super .getPropertySets();
050: for (int i = 0; i < propertySet.length; i++) {
051: PropertySet pSet = propertySet[i];
052: ReadOnlyPropertySet rpSet = new ReadOnlyPropertySet(pSet);
053: propertySet[i] = rpSet;
054: }
055: return propertySet;
056: }
057:
058: @Override
059: public boolean canRename() {
060: return false;
061: }
062:
063: @Override
064: public boolean canDestroy() {
065: return false;
066: }
067:
068: @Override
069: public boolean canCut() {
070: return false;
071: }
072:
073: @Override
074: public boolean canCopy() {
075: return false;
076: }
077:
078: @Override
079: public boolean hasCustomizer() {
080: return false;
081: }
082:
083: public static class ReadOnlyChildren extends FilterNode.Children {
084:
085: public ReadOnlyChildren(Node node) {
086: super (node);
087: }
088:
089: @Override
090: protected Node[] createNodes(Node n) {
091: return new Node[] { new ReadOnlyFilterNode(n) };
092: }
093: }
094:
095: public static class ReadOnlyProperty extends Node.Property {
096:
097: private Node.Property mDelegate;
098:
099: public ReadOnlyProperty(Node.Property delegate) {
100: super (delegate.getClass());
101: this .mDelegate = delegate;
102: this .setDisplayName(this .mDelegate.getDisplayName());
103: this .setName(this .mDelegate.getName());
104: this .setShortDescription(this .mDelegate
105: .getShortDescription());
106: this .setExpert(this .mDelegate.isExpert());
107: this .setHidden(this .mDelegate.isHidden());
108: this .setPreferred(this .mDelegate.isPreferred());
109:
110: }
111:
112: @Override
113: public boolean equals(Object property) {
114: return this .mDelegate.equals(property);
115: }
116:
117: @Override
118: public String getHtmlDisplayName() {
119: return this .mDelegate.getHtmlDisplayName();
120: }
121:
122: @Override
123: public PropertyEditor getPropertyEditor() {
124: return this .mDelegate.getPropertyEditor();
125: }
126:
127: @Override
128: public Class getValueType() {
129: return this .mDelegate.getValueType();
130: }
131:
132: @Override
133: public int hashCode() {
134: return this .mDelegate.hashCode();
135: }
136:
137: @Override
138: public boolean isDefaultValue() {
139: return this .mDelegate.isDefaultValue();
140: }
141:
142: @Override
143: public void restoreDefaultValue()
144: throws IllegalAccessException,
145: InvocationTargetException {
146: this .mDelegate.restoreDefaultValue();
147: }
148:
149: @Override
150: public boolean supportsDefaultValue() {
151: return this .mDelegate.supportsDefaultValue();
152: }
153:
154: @Override
155: public boolean canRead() {
156: return true;
157: }
158:
159: @Override
160: public boolean canWrite() {
161: return false;
162: }
163:
164: @Override
165: public Object getValue() throws IllegalAccessException,
166: InvocationTargetException {
167: return mDelegate.getValue();
168: }
169:
170: @Override
171: public void setValue(Object val) throws IllegalAccessException,
172: IllegalArgumentException, InvocationTargetException {
173: //do nothing
174: }
175: }
176:
177: public static class ReadOnlyPropertySet extends Node.PropertySet {
178:
179: private Node.PropertySet mDelegate;
180:
181: public ReadOnlyPropertySet(Node.PropertySet delegate) {
182: super (delegate.getName(), delegate.getDisplayName(),
183: delegate.getShortDescription());
184: this .mDelegate = delegate;
185: }
186:
187: @Override
188: public Property[] getProperties() {
189: Property[] properties = this .mDelegate.getProperties();
190: for (int i = 0; i < properties.length; i++) {
191: Property p = properties[i];
192: ReadOnlyProperty rp = new ReadOnlyProperty(p);
193: properties[i] = rp;
194: }
195:
196: return properties;
197: }
198: }
199: }
|