1 19 20 26 27 package org.netbeans.modules.xml.schema.ui.nodes.schema.properties; 28 29 import java.lang.reflect.InvocationTargetException ; 30 import org.netbeans.modules.xml.schema.model.Element; 31 import org.netbeans.modules.xml.schema.model.Attribute; 32 import org.netbeans.modules.xml.schema.model.SchemaComponent; 33 import org.netbeans.modules.xml.schema.ui.basic.editors.StringEditor; 34 import org.netbeans.modules.xml.schema.ui.nodes.schema.GlobalElementNode; 35 import org.openide.ErrorManager; 36 import org.openide.util.NbBundle; 37 38 39 43 public class FixedProperty extends BaseSchemaProperty { 44 45 46 public FixedProperty(SchemaComponent component, String propName, 47 String propDesc) throws NoSuchMethodException { 48 super(component,String .class,Element.FIXED_PROPERTY, 49 propName,propDesc,StringEditor.class); 50 } 51 52 public void setValue(Object o) throws 53 IllegalAccessException , InvocationTargetException { 54 if(getComponent() instanceof Attribute) { 55 if (((Attribute)getComponent()).getDefault()==null) { 56 super.setValue(o); 57 } else { 58 throwError(); 59 } 60 } else if(getComponent() instanceof Element) { 61 if (((Element)getComponent()).getDefault()==null) { 62 super.setValue(o); 63 } else { 64 throwError(); 65 } 66 } 67 } 68 69 private void throwError(){ 70 String msg = NbBundle.getMessage(GlobalElementNode.class, "MSG_Fixed_DefaultAlreadySet"); IllegalArgumentException iae = new IllegalArgumentException (msg); 72 ErrorManager.getDefault().annotate(iae, ErrorManager.USER, 73 msg, msg, null, new java.util.Date ()); 74 throw iae; 75 76 } 77 78 } 79 | Popular Tags |