KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > schema > abe > nodes > properties > MinOccursProperty


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.xml.schema.abe.nodes.properties;
21
22 import java.lang.reflect.InvocationTargetException JavaDoc;
23 import java.lang.reflect.Method JavaDoc;
24 import org.netbeans.modules.xml.axi.AXIComponent;
25 import org.netbeans.modules.xml.schema.model.SchemaModel;
26 import org.openide.nodes.PropertySupport;
27
28 /**
29  *
30  * @author Ayub Khan
31  */

32 public class MinOccursProperty extends BaseABENodeProperty {
33     
34     /**
35      * Creates a new instance of BaseABENodeProperty.
36      *
37      * @param component The schema component which property belongs to.
38      * @param valueType The class type of the property.
39      * @param property The property name.
40      * @param propDispName The display name of the property.
41      * @param propDesc Short description about the property.
42      * @param propEditorClass The property editor class
43      * if the property needs special property editor.
44      * If no property editor class is provided default editor
45      * (for type of property) will be used.
46      * The property editor class must provide a default constructor.
47      * Subclasses can also override
48      * getPropertyEditor method to provide property editor.
49      * @throws java.lang.NoSuchMethodException If no getter and setter for the property are found
50      */

51     public MinOccursProperty(AXIComponent component,
52             Class JavaDoc valueType,
53             String JavaDoc property,
54             String JavaDoc propDispName,
55             String JavaDoc propDesc)
56             throws NoSuchMethodException JavaDoc {
57         super(component, valueType, property, propDispName, propDesc, null);
58     }
59     
60     // Methods to support restore to default
61
/**
62      * This api determines if this property has default value.
63      * If the property value is null, its considered as default value.
64      * Subclasses can override if different behaviour expected.
65      * @return Returns true if the property is default value, false otherwise.
66      */

67     @Override JavaDoc
68     public boolean isDefaultValue () {
69         try {
70             return getValue()==DEFAULT_VALUE;
71         } catch (IllegalArgumentException JavaDoc ex) {
72         } catch (InvocationTargetException JavaDoc ex) {
73         } catch (IllegalAccessException JavaDoc ex) {
74         }
75         return false;
76     }
77
78     /**
79      * This api determines if this property supports resetting default value.
80      * This returns true always.
81      * Subclasses can override if different behaviour expected.
82      */

83     @Override JavaDoc
84     public boolean supportsDefaultValue () {
85         return true;
86     }
87
88     /**
89      * This api resets the property to its default value.
90      * It sets property value to null which is considered as default value.
91      * Subclasses can override if different behaviour expected.
92      */

93     @Override JavaDoc
94     public void restoreDefaultValue () throws IllegalAccessException JavaDoc, InvocationTargetException JavaDoc {
95         setValue(DEFAULT_VALUE);
96     }
97     
98     public static final String JavaDoc DEFAULT_VALUE = "1";
99 }
Popular Tags