1 19 20 26 27 package org.netbeans.modules.xml.schema.ui.nodes.schema.properties; 28 29 import java.lang.reflect.InvocationTargetException ; 30 import java.lang.reflect.Method ; 31 import org.netbeans.modules.xml.schema.model.SchemaComponent; 32 import org.netbeans.modules.xml.schema.model.SchemaModel; 33 import org.netbeans.modules.xml.xam.ui.XAMUtils; 34 import org.openide.nodes.PropertySupport; 35 36 63 public class BaseSchemaProperty extends PropertySupport.Reflection { 64 65 81 public BaseSchemaProperty(SchemaComponent component, 82 Class valueType, 83 String property, 84 String propDispName, 85 String propDesc, 86 Class propEditorClass) 87 throws NoSuchMethodException { 88 super(component,valueType,property); 89 super.setName(property); 90 super.setDisplayName(propDispName); 91 super.setShortDescription(propDesc); 92 if(propEditorClass!=null) 93 super.setPropertyEditorClass(propEditorClass); 94 } 95 96 113 public BaseSchemaProperty(SchemaComponent component, 114 Class valueType, 115 Method getter, 116 Method setter, 117 String property, 118 String propDispName, 119 String propDesc, 120 Class propEditorClass) { 121 super(component,valueType,getter,setter); 122 super.setName(property); 123 super.setDisplayName(propDispName); 124 super.setShortDescription(propDesc); 125 if(propEditorClass!=null) 126 super.setPropertyEditorClass(propEditorClass); 127 } 128 129 133 @Override 134 public boolean canWrite() { 135 SchemaModel model = getComponent().getModel(); 137 return XAMUtils.isWritable(model); 138 } 139 140 147 @Override 148 public boolean isDefaultValue () { 149 try { 150 return getValue()==null; 151 } catch (IllegalArgumentException ex) { 152 } catch (InvocationTargetException ex) { 153 } catch (IllegalAccessException ex) { 154 } 155 return false; 156 } 157 158 163 @Override 164 public boolean supportsDefaultValue () { 165 return true; 166 } 167 168 173 @Override 174 public void restoreDefaultValue () throws IllegalAccessException , InvocationTargetException { 175 setValue(null); 176 } 177 178 protected SchemaComponent getComponent() { 179 return (SchemaComponent)instance; 180 } 181 182 protected void setComponent(SchemaComponent sc) { 183 instance = sc; 184 } 185 186 190 public static String firstLetterToUpperCase(String s, String pref) { 191 switch (s.length()) { 192 case 0: 193 return pref; 194 195 case 1: 196 return pref + Character.toUpperCase(s.charAt(0)); 197 198 default: 199 return pref + Character.toUpperCase(s.charAt(0)) + s.substring(1); 200 } 201 } 202 203 } | Popular Tags |