1 19 20 26 27 package org.netbeans.modules.xml.schema.abe.nodes.properties; 28 29 import java.lang.reflect.InvocationTargetException ; 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 42 public class FixedProperty extends BaseABENodeProperty { 43 44 45 public FixedProperty(AXIComponent component, String propName, 46 String propDesc) throws NoSuchMethodException { 47 super(component,String .class,Element.PROP_FIXED, 48 propName,propDesc,StringEditor.class); 49 } 50 51 public void setValue(Object o) throws 52 IllegalAccessException , InvocationTargetException { 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 msg = NbBundle.getMessage(GlobalElementNode.class, "MSG_Fixed_DefaultAlreadySet"); IllegalArgumentException iae = new IllegalArgumentException (msg); 71 ErrorManager.getDefault().annotate(iae, ErrorManager.USER, 72 msg, msg, null, new java.util.Date ()); 73 throw iae; 74 75 } 76 77 } 78 | Popular Tags |