KickJava   Java API By Example, From Geeks To Geeks.

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


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 /*
21  * FixedProperty.java
22  *
23  * Created on January 5, 2006, 3:21 PM
24  *
25  */

26
27 package org.netbeans.modules.xml.schema.abe.nodes.properties;
28
29 import java.lang.reflect.InvocationTargetException JavaDoc;
30 import org.netbeans.modules.xml.axi.Element;
31 import org.netbeans.modules.xml.axi.Attribute;
32 import org.netbeans.modules.xml.axi.AXIComponent;
33 import org.netbeans.modules.xml.schema.ui.nodes.schema.GlobalElementNode;
34 import org.openide.ErrorManager;
35 import org.openide.util.NbBundle;
36
37
38 /**
39  *
40  * @author Ajit Bhate
41  */

42 public class FixedProperty extends BaseABENodeProperty {
43     
44     /** Creates a new instance of FixedProperty */
45     public FixedProperty(AXIComponent component, String JavaDoc propName,
46             String JavaDoc propDesc) throws NoSuchMethodException JavaDoc {
47         super(component,String JavaDoc.class,Element.PROP_FIXED,
48                 propName,propDesc,StringEditor.class);
49     }
50     
51     public void setValue(Object JavaDoc o) throws
52             IllegalAccessException JavaDoc, InvocationTargetException JavaDoc{
53         if(getComponent() instanceof Attribute) {
54             if (((Attribute)getComponent()).getDefault()==null) {
55                 super.setValue(o);
56             } else {
57                 throwError();
58             }
59         } else if(getComponent() instanceof Element) {
60             if (((Element)getComponent()).getDefault()==null) {
61                 super.setValue(o);
62             } else {
63                 throwError();
64             }
65         }
66     }
67     
68     private void throwError(){
69         String JavaDoc msg = NbBundle.getMessage(GlobalElementNode.class, "MSG_Fixed_DefaultAlreadySet"); //NOI18N
70
IllegalArgumentException JavaDoc iae = new IllegalArgumentException JavaDoc(msg);
71         ErrorManager.getDefault().annotate(iae, ErrorManager.USER,
72                 msg, msg, null, new java.util.Date JavaDoc());
73         throw iae;
74         
75     }
76
77 }
78
Popular Tags