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: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.beans.beaninfo;
043:
044: import java.beans.PropertyEditor;
045: import java.beans.PropertyEditorSupport;
046: import java.lang.reflect.InvocationTargetException;
047: import javax.swing.Action;
048: import javax.swing.GrayFilter;
049: import org.netbeans.api.java.source.SourceUtils;
050: import org.openide.filesystems.FileObject;
051: import org.openide.nodes.AbstractNode;
052: import org.openide.nodes.Children;
053: import org.openide.nodes.Node;
054: import org.openide.nodes.PropertySupport;
055: import org.openide.nodes.Sheet;
056: import org.openide.util.NbBundle;
057: import org.openide.util.actions.SystemAction;
058:
059: /**
060: * This class represents BeanInfo root node.
061: *
062: * @author Petr Hrebejk
063: */
064: public final class BiNode extends AbstractNode {
065:
066: // static variables ...........................................................................
067:
068: /** generated Serialized Version UID */
069: //static final long serialVersionUID = -6346315017458451778L;
070: private static String ICON_BASE = "org/netbeans/modules/beans/resources/beanInfo.gif"; // NOI18N
071: private static String ICON_BASE_PATTERNS = "org/netbeans/modules/beans/resources/patternGroup.gif"; // NOI18N
072: private static String WAIT_ICON_BASE = "org/netbeans/modules/beans/resources/wait.gif"; // NOI18N
073: private static String WARNING_ICON_BASE = "org/netbeans/modules/beans/resources/warning.gif"; // NOI18N
074:
075: private static String PROP_NULL_DESCRIPTOR = "nullDescriptor"; // NOI18N
076: private static String PROP_NULL_PROPERTIES = "nullProperties"; // NOI18N
077: private static String PROP_NULL_EVENTS = "nullEvents"; // NOI18N
078: private static String PROP_NULL_METHODS = "nullMethods"; // NOI18N
079: private static String PROP_LAZY_DESCRIPTOR = "lazyDescriptor"; // NOI18N
080: private static String PROP_LAZY_PROPERTIES = "lazyProperties"; // NOI18N
081: private static String PROP_LAZY_EVENTS = "lazyEvents"; // NOI18N
082: private static String PROP_LAZY_METHODS = "lazyMethods"; // NOI18N
083: private static String PROP_BI_ICON_C16 = "iconColor16x16"; // NOI18N
084: private static String PROP_BI_ICON_M16 = "iconMono16x16"; // NOI18N
085: private static String PROP_BI_ICON_C32 = "iconColor32x32"; // NOI18N
086: private static String PROP_BI_ICON_M32 = "iconMono32x32"; // NOI18N
087: private static String PROP_BI_DEFAULT_PROPERTY = "defaultPropertyIndex"; // NOI18N
088: private static String PROP_BI_DEFAULT_EVENT = "defaultEventIndex"; // NOI18N
089: private static String PROP_USE_SUPERCLASS = "useSuperclass"; // NOI18N
090:
091: static javax.swing.GrayFilter grayFilter = null;
092:
093: static {
094: grayFilter = new GrayFilter(true, 5);
095: }
096:
097: // variables ....................................................................................
098:
099: private BiAnalyser biAnalyser;
100:
101: private PropertySupport[] descSubnodeDescriptor = new PropertySupport[] { new PropertySupport.ReadWrite<Boolean>(
102: PROP_NULL_DESCRIPTOR, Boolean.TYPE, GenerateBeanInfoAction
103: .getString("PROP_Bi_" + PROP_NULL_DESCRIPTOR),
104: GenerateBeanInfoAction.getString("HINT_Bi_"
105: + PROP_NULL_DESCRIPTOR)) {
106: public Boolean getValue() {
107: return biAnalyser.isNullDescriptor();
108: }
109:
110: public void setValue(Boolean val)
111: throws IllegalAccessException,
112: IllegalArgumentException, InvocationTargetException {
113: try {
114: biAnalyser.setNullDescriptor(val);
115: } catch (ClassCastException e) {
116: throw new IllegalArgumentException();
117: }
118: iconChange();
119: }
120: } };
121:
122: private PropertySupport[] propSubnodeProperties = new PropertySupport[] { new PropertySupport.ReadWrite<Boolean>(
123: PROP_NULL_PROPERTIES, Boolean.TYPE, GenerateBeanInfoAction
124: .getString("PROP_Bi_" + PROP_NULL_PROPERTIES),
125: GenerateBeanInfoAction.getString("HINT_Bi_"
126: + PROP_NULL_PROPERTIES)) {
127: public Boolean getValue() {
128: return biAnalyser.isNullProperties();
129: }
130:
131: public void setValue(Boolean val)
132: throws IllegalAccessException,
133: IllegalArgumentException, InvocationTargetException {
134: try {
135: biAnalyser.setNullProperties(val);
136: } catch (ClassCastException e) {
137: throw new IllegalArgumentException();
138: }
139: iconChange();
140: }
141: } };
142:
143: private PropertySupport[] eventSubnodeProperties = new PropertySupport[] { new PropertySupport.ReadWrite<Boolean>(
144: PROP_NULL_EVENTS, Boolean.TYPE, GenerateBeanInfoAction
145: .getString("PROP_Bi_" + PROP_NULL_EVENTS),
146: GenerateBeanInfoAction.getString("HINT_Bi_"
147: + PROP_NULL_EVENTS)) {
148: public Boolean getValue() {
149: return biAnalyser.isNullEventSets();
150: }
151:
152: public void setValue(Boolean val)
153: throws IllegalAccessException,
154: IllegalArgumentException, InvocationTargetException {
155: try {
156: biAnalyser.setNullEventSets(val);
157: } catch (ClassCastException e) {
158: throw new IllegalArgumentException();
159: }
160: iconChange();
161: }
162: } };
163:
164: private PropertySupport[] methodSubnodeProperties = new PropertySupport[] { new PropertySupport.ReadWrite<Boolean>(
165: PROP_NULL_PROPERTIES, Boolean.TYPE, GenerateBeanInfoAction
166: .getString("PROP_Bi_" + PROP_NULL_METHODS),
167: GenerateBeanInfoAction.getString("HINT_Bi_"
168: + PROP_NULL_METHODS)) {
169: public Boolean getValue() {
170: return biAnalyser.isNullMethods();
171: }
172:
173: public void setValue(Boolean val)
174: throws IllegalAccessException,
175: IllegalArgumentException, InvocationTargetException {
176: try {
177: biAnalyser.setNullMethods(val);
178: } catch (ClassCastException e) {
179: throw new IllegalArgumentException();
180: }
181: iconChange();
182: }
183: } };
184:
185: // constructors ..................................................................................
186:
187: /**
188: * Creates tree for BeanInfo Analyser.
189: */
190: BiNode(final BiAnalyser biAnalyser) {
191: /*
192: super ( new BiChildren ( biAnalyser,
193: new Class[] {
194: BiFeature.Property.class,
195: BiFeature.IdxProperty.class,
196: BiFeature.EventSet.class } ) );
197: */
198: super (new Children.Array());
199: this .biAnalyser = biAnalyser;
200: setDisplayName(NbBundle.getBundle(BiNode.class).getString(
201: "CTL_NODE_BeanInfo"));
202: setIconBaseWithExtension(ICON_BASE);
203:
204: Node[] subnodes = (biAnalyser.isOlderVersion() ? new Node[] {
205: new SubNode(biAnalyser, new Class[] {
206: BiFeature.Property.class,
207: BiFeature.IdxProperty.class },
208: "CTL_NODE_Properties", // NOI18N
209: ICON_BASE_PATTERNS, propSubnodeProperties, null),
210:
211: new SubNode(
212: biAnalyser,
213: new Class[] { BiFeature.EventSet.class },
214: "CTL_NODE_EventSets", // NOI18N
215: ICON_BASE_PATTERNS, eventSubnodeProperties,
216: null) }
217: : new Node[] {
218: new SubNode(
219: biAnalyser,
220: new Class[] { BiFeature.Descriptor.class },
221: "CTL_NODE_Descriptor", // NOI18N
222: ICON_BASE_PATTERNS,
223: descSubnodeDescriptor,
224: new Node.Property[] { createProperty(
225: biAnalyser,
226: Boolean.TYPE,
227: PROP_LAZY_DESCRIPTOR,
228: GenerateBeanInfoAction
229: .getString("PROP_Bi_"
230: + PROP_LAZY_DESCRIPTOR),
231: GenerateBeanInfoAction
232: .getString("HINT_Bi_"
233: + PROP_LAZY_DESCRIPTOR),
234: "isLazyDescriptor",
235: "setLazyDescriptor") } // NOI18N
236: ),
237:
238: new SubNode(
239: biAnalyser,
240: new Class[] { BiFeature.Property.class,
241: BiFeature.IdxProperty.class },
242: "CTL_NODE_Properties", // NOI18N
243: ICON_BASE_PATTERNS,
244: propSubnodeProperties,
245: new Node.Property[] { createProperty(
246: biAnalyser,
247: Boolean.TYPE,
248: PROP_LAZY_DESCRIPTOR,
249: GenerateBeanInfoAction
250: .getString("PROP_Bi_"
251: + PROP_LAZY_PROPERTIES),
252: GenerateBeanInfoAction
253: .getString("HINT_Bi_"
254: + PROP_LAZY_PROPERTIES),
255: "isLazyProperties",
256: "setLazyProperties") } // NOI18N
257: ),
258:
259: new SubNode(
260: biAnalyser,
261: new Class[] { BiFeature.EventSet.class },
262: "CTL_NODE_EventSets", // NOI18N
263: ICON_BASE_PATTERNS,
264: eventSubnodeProperties,
265: new Node.Property[] { createProperty(
266: biAnalyser,
267: Boolean.TYPE,
268: PROP_LAZY_EVENTS,
269: GenerateBeanInfoAction
270: .getString("PROP_Bi_"
271: + PROP_LAZY_EVENTS),
272: GenerateBeanInfoAction
273: .getString("HINT_Bi_"
274: + PROP_LAZY_EVENTS),
275: "isLazyEventSets",
276: "setLazyEventSets") } // NOI18N
277: ),
278:
279: new SubNode(
280: biAnalyser,
281: new Class[] { BiFeature.Method.class },
282: "CTL_NODE_Methods", // NOI18N
283: ICON_BASE_PATTERNS,
284: methodSubnodeProperties,
285: new Node.Property[] { createProperty(
286: biAnalyser,
287: Boolean.TYPE,
288: PROP_LAZY_METHODS,
289: GenerateBeanInfoAction
290: .getString("PROP_Bi_"
291: + PROP_LAZY_METHODS),
292: GenerateBeanInfoAction
293: .getString("HINT_Bi_"
294: + PROP_LAZY_METHODS),
295: "isLazyMethods",
296: "setLazyMethods") } // NOI18N
297: ) });
298:
299: Sheet sheet = Sheet.createDefault();
300: Sheet.Set ps = sheet.get(Sheet.PROPERTIES);
301:
302: ps.put(new ImagePropertySupportRW(PROP_BI_ICON_C16,
303: GenerateBeanInfoAction.getString("PROP_Bi_"
304: + PROP_BI_ICON_C16), GenerateBeanInfoAction
305: .getString("HINT_Bi_" + PROP_BI_ICON_C16)) {
306: public String getValue() throws IllegalAccessException,
307: InvocationTargetException {
308: if (biAnalyser.getIconC16() != null)
309: ie.setAsText(biAnalyser.getIconC16());
310: else
311: ie.setAsText("null"); //NOI18N
312:
313: return biAnalyser.getIconC16();
314: }
315:
316: public void setValue(String value)
317: throws IllegalAccessException,
318: IllegalArgumentException, InvocationTargetException {
319:
320: biAnalyser.setIconC16(value);
321: }
322: });
323: ps.put(new ImagePropertySupportRW(PROP_BI_ICON_M16,
324: GenerateBeanInfoAction.getString("PROP_Bi_"
325: + PROP_BI_ICON_M16), GenerateBeanInfoAction
326: .getString("HINT_Bi_" + PROP_BI_ICON_M16)) {
327: public String getValue() throws IllegalAccessException,
328: InvocationTargetException {
329: if (biAnalyser.getIconM16() != null)
330: ie.setAsText(biAnalyser.getIconM16());
331: else
332: ie.setAsText("null"); //NOI18N
333: return biAnalyser.getIconM16();
334: }
335:
336: public void setValue(String value)
337: throws IllegalAccessException,
338: IllegalArgumentException, InvocationTargetException {
339:
340: biAnalyser.setIconM16(value);
341: }
342: });
343: ps.put(new ImagePropertySupportRW(PROP_BI_ICON_C32,
344: GenerateBeanInfoAction.getString("PROP_Bi_"
345: + PROP_BI_ICON_C32), GenerateBeanInfoAction
346: .getString("HINT_Bi_" + PROP_BI_ICON_C32)) {
347: public String getValue() throws IllegalAccessException,
348: InvocationTargetException {
349: if (biAnalyser.getIconC32() != null)
350: ie.setAsText(biAnalyser.getIconC32());
351: else
352: ie.setAsText("null"); //NOI18N
353:
354: return biAnalyser.getIconC32();
355: }
356:
357: public void setValue(String value)
358: throws IllegalAccessException,
359: IllegalArgumentException, InvocationTargetException {
360:
361: biAnalyser.setIconC32(value);
362: }
363: });
364: ps.put(new ImagePropertySupportRW(PROP_BI_ICON_M32,
365: GenerateBeanInfoAction.getString("PROP_Bi_"
366: + PROP_BI_ICON_M32), GenerateBeanInfoAction
367: .getString("HINT_Bi_" + PROP_BI_ICON_M32)) {
368: public String getValue() throws IllegalAccessException,
369: InvocationTargetException {
370: if (biAnalyser.getIconM32() != null)
371: ie.setAsText(biAnalyser.getIconM32());
372: else
373: ie.setAsText("null"); //NOI18N
374:
375: return biAnalyser.getIconM32();
376: }
377:
378: public void setValue(String value)
379: throws IllegalAccessException,
380: IllegalArgumentException, InvocationTargetException {
381: biAnalyser.setIconM32(value);
382: }
383: });
384: ps.put(createProperty(biAnalyser, Integer.TYPE,
385: PROP_BI_DEFAULT_PROPERTY, GenerateBeanInfoAction
386: .getString("PROP_Bi_"
387: + PROP_BI_DEFAULT_PROPERTY),
388: GenerateBeanInfoAction.getString("HINT_Bi_"
389: + PROP_BI_DEFAULT_PROPERTY),
390: "getDefaultPropertyIndex", "setDefaultPropertyIndex")); // NOI18N
391:
392: ps.put(createProperty(biAnalyser, Integer.TYPE,
393: PROP_BI_DEFAULT_EVENT, GenerateBeanInfoAction
394: .getString("PROP_Bi_" + PROP_BI_DEFAULT_EVENT),
395: GenerateBeanInfoAction.getString("HINT_Bi_"
396: + PROP_BI_DEFAULT_EVENT),
397: "getDefaultEventIndex", "setDefaultEventIndex")); // NOI18N
398:
399: //only if it is super class version (since 3.3)
400: if (biAnalyser.isSuperclassVersion()) {
401: ps.put(createProperty(biAnalyser, Boolean.TYPE,
402: PROP_USE_SUPERCLASS,
403: GenerateBeanInfoAction.getString("PROP_Bi_"
404: + PROP_USE_SUPERCLASS),
405: GenerateBeanInfoAction.getString("HINT_Bi_"
406: + PROP_USE_SUPERCLASS), "isUseSuperClass",
407: "setUseSuperClass")); // NOI18N
408: }
409: setSheet(sheet);
410:
411: ((Children.Array) getChildren()).add(subnodes);
412:
413: }
414:
415: /** refresh icons after get from introspection change */
416: public void iconChange() {
417: Node[] nodes = ((Children.Array) getChildren()).getNodes();
418: for (int i = 0; i < nodes.length; i++) {
419: ((SubNode) nodes[i]).iconChanged();
420: }
421: }
422:
423: static final class SubNode extends AbstractNode implements
424: Node.Cookie {
425:
426: //private static SystemAction[] staticActions;
427: private BiAnalyser biAnalyser;
428: private Class<?> key;
429:
430: SubNode(BiAnalyser biAnalyser, Class<?>[] keys,
431: String titleKey, String iconBase,
432: Node.Property[] properties, Node.Property[] expert) {
433: super (new BiChildren(biAnalyser, keys));
434: setDisplayName(NbBundle.getBundle(BiNode.class).getString(
435: titleKey));
436: setIconBaseWithExtension(iconBase);
437:
438: this .biAnalyser = biAnalyser;
439: this .key = keys[0];
440:
441: Sheet sheet = Sheet.createDefault();
442: Sheet.Set ps = sheet.get(Sheet.PROPERTIES);
443:
444: for (int i = 0; i < properties.length; i++) {
445: ps.put(properties[i]);
446: }
447:
448: if (expert != null) {
449: Sheet.Set eps = Sheet.createExpertSet();
450:
451: for (int i = 0; i < expert.length; i++) {
452: eps.put(expert[i]);
453: }
454: sheet.put(eps);
455: }
456:
457: setSheet(sheet);
458:
459: getCookieSet().add(this );
460: }
461:
462: @Override
463: public java.awt.Image getIcon(int type) {
464: if (key == BiFeature.Descriptor.class
465: && biAnalyser.isNullDescriptor())
466: return GrayFilter.createDisabledImage(super
467: .getIcon(type));
468: if (key == BiFeature.Property.class
469: && biAnalyser.isNullProperties())
470: return GrayFilter.createDisabledImage(super
471: .getIcon(type));
472: if (key == BiFeature.EventSet.class
473: && biAnalyser.isNullEventSets())
474: return GrayFilter.createDisabledImage(super
475: .getIcon(type));
476: if (key == BiFeature.Method.class
477: && biAnalyser.isNullMethods())
478: return GrayFilter.createDisabledImage(super
479: .getIcon(type));
480:
481: return super .getIcon(type);
482: }
483:
484: @Override
485: public java.awt.Image getOpenedIcon(int type) {
486: if (key == BiFeature.Descriptor.class
487: && biAnalyser.isNullDescriptor())
488: return GrayFilter.createDisabledImage(super
489: .getIcon(type));
490: if (key == BiFeature.Property.class
491: && biAnalyser.isNullProperties())
492: return GrayFilter.createDisabledImage(super
493: .getIcon(type));
494: if (key == BiFeature.EventSet.class
495: && biAnalyser.isNullEventSets())
496: return GrayFilter.createDisabledImage(super
497: .getIcon(type));
498: if (key == BiFeature.Method.class
499: && biAnalyser.isNullMethods())
500: return GrayFilter.createDisabledImage(super
501: .getIcon(type));
502:
503: return super .getOpenedIcon(type);
504: }
505:
506: /** Getter for set of actions that should be present in the
507: * popup menu of this node. This set is used in construction of
508: * menu returned from getContextMenu and specially when a menu for
509: * more nodes is constructed.
510: *
511: * @return array of system actions that should be in popup menu
512: */
513: @Override
514: public Action[] getActions(boolean context) {
515: if (context) {
516: return super .getActions(true);
517: } else {
518: Children ch = getChildren();
519: Node[] nodes = ch.getNodes();
520: if (nodes == null)
521: return new SystemAction[0];
522:
523: if (nodes.length == 0
524: || (nodes[0] != null && ((BiFeatureNode) nodes[0])
525: .getBiFeature() instanceof BiFeature.Descriptor))
526: return new SystemAction[0];
527:
528: return new SystemAction[] {
529: SystemAction.get(BiIncludeAllAction.class),
530: SystemAction.get(BiExcludeAllAction.class),
531: null };
532: }
533: }
534:
535: void includeAll(boolean value) {
536: Children ch = getChildren();
537:
538: Node[] nodes = ch.getNodes();
539:
540: if (nodes == null)
541: return;
542:
543: for (int i = 0; i < nodes.length; i++) {
544: ((BiFeatureNode) nodes[i]).include(value);
545: }
546:
547: }
548:
549: /** refresh icons after get from introspection change */
550: public void iconChanged() {
551: fireIconChange();
552: fireOpenedIconChange();
553:
554: Children ch = getChildren();
555: Node[] nodes = ch.getNodes();
556: if (nodes == null)
557: return;
558:
559: for (int i = 0; i < nodes.length; i++) {
560: ((BiFeatureNode) nodes[i]).iconChanged();
561: }
562: }
563: }
564:
565: // Inner Class ---------------------------------------------------------------
566:
567: static final class Wait extends AbstractNode {
568:
569: Wait() {
570:
571: super (Children.LEAF);
572: setDisplayName(SourceUtils.isScanInProgress() ? NbBundle
573: .getBundle(BiNode.class).getString(
574: "CTL_NODE_WaitScan") : NbBundle.getBundle(
575: BiNode.class).getString("CTL_NODE_Wait"));
576: setIconBaseWithExtension(WAIT_ICON_BASE);
577:
578: }
579: }
580:
581: private static final class Error extends AbstractNode {
582:
583: Error(String name) {
584:
585: super (Children.LEAF);
586: setDisplayName(name);
587: setIconBaseWithExtension(WARNING_ICON_BASE);
588:
589: }
590: }
591:
592: public static Node createNoSourceNode(FileObject bi) {
593: String name = bi.getName();
594: name = name.substring(0, name.length() - "BeanInfo".length()); // NOI18N
595: String ext = bi.getExt();
596: if (ext.length() > 0) {
597: name += '.' + ext;
598: }
599: String msg = NbBundle.getMessage(BiNode.class,
600: "CTL_NODE_MissingBeanFile", name);
601: return new Error(msg);
602: }
603:
604: public static Node createBiNode(BiAnalyser bia) {
605: if (!bia.bis.isNbBeanInfo()) {
606: String msg = NbBundle.getMessage(BiNode.class,
607: "CTL_NODE_UnknownBeanInfoFormat");
608: return new Error(msg);
609: } else if (bia.bis.getSourceDataObject() == null) {
610: return createNoSourceNode(bia.bis.getDataObject()
611: .getPrimaryFile());
612: } else {
613: return new BiNode(bia);
614: }
615: }
616:
617: abstract class ImagePropertySupportRW extends
618: PropertySupport.ReadWrite<String> {
619: BiIconEditor ie = null;
620:
621: ImagePropertySupportRW(String name, String displayName,
622: String shortDescription) {
623: super (name, String.class, displayName, shortDescription);
624: ie = new BiIconEditor(biAnalyser.bis.getSourceDataObject()
625: .getPrimaryFile());
626: }
627:
628: @Override
629: public PropertyEditor getPropertyEditor() {
630: return new PropertyEditorSupport() {
631: @Override
632: public java.awt.Component getCustomEditor() {
633: return ie.getCustomEditor();
634: }
635:
636: @Override
637: public boolean supportsCustomEditor() {
638: return true;
639: }
640:
641: @Override
642: public void setAsText(String text)
643: throws java.lang.IllegalArgumentException {
644: ie.setAsText(text);
645: setValue(ie.getSourceName());
646: }
647: };
648: }
649: }
650:
651: public static <T> Node.Property<T> createProperty(Object inst,
652: Class<T> type, String name, String dispName,
653: String shortDesc, String getter, String setter) {
654: Node.Property<T> prop;
655:
656: try {
657: prop = new PropertySupport.Reflection<T>(inst, type,
658: getter, setter);
659: } catch (NoSuchMethodException e) {
660: throw new IllegalStateException(e.getMessage() + " "
661: + getter); // NOI18N
662: }
663:
664: prop.setName(name);
665: prop.setDisplayName(dispName);
666: prop.setShortDescription(shortDesc);
667: return prop;
668: }
669: }
|