1 19 20 26 package org.netbeans.modules.xml.wsdl.ui.view.property; 27 28 import java.beans.PropertyEditor ; 29 import java.util.ArrayList ; 30 import java.util.Collection ; 31 32 import org.netbeans.modules.xml.schema.model.Enumeration; 33 import org.netbeans.modules.xml.schema.model.SimpleType; 34 import org.netbeans.modules.xml.wsdl.ui.api.property.ComboBoxPropertyEditor; 35 import org.netbeans.modules.xml.wsdl.ui.api.property.PropertyAdapter; 36 import org.openide.nodes.PropertySupport; 37 import org.openide.util.NbBundle; 38 39 45 public class XSDEnumeratedAttributeProperty extends PropertySupport.Reflection { 46 47 private SimpleType mType; 48 private PropertyAdapter mPropAdapter; 49 private boolean optional; 50 private String valueNotSetMessage = NbBundle.getMessage(XSDEnumeratedAttributeProperty.class, "LBL_ValueNotSet"); 51 52 public XSDEnumeratedAttributeProperty(SimpleType type, 53 PropertyAdapter instance, 54 Class valueType, 55 String getter, 56 String setter, boolean isOptional) throws NoSuchMethodException { 57 super(instance, valueType, getter, setter); 58 this.mType = type; 59 mPropAdapter = instance; 60 optional = isOptional; 61 } 62 63 @Override 64 public PropertyEditor getPropertyEditor() { 65 String [] enuValues = getAllEnumeratedValues(); 66 return new ComboBoxPropertyEditor(enuValues); 67 } 68 69 private String [] getAllEnumeratedValues() { 70 ArrayList <String > enuValueList = new ArrayList <String >(); 71 if (optional) { 72 enuValueList.add(valueNotSetMessage); 73 } 74 Collection <Enumeration> coll = mType.getDefinition().getChildren(Enumeration.class); 75 if(coll != null) { 76 for(Enumeration enuFacet : coll) { 77 enuValueList.add(enuFacet.getValue()); 78 } 79 } 80 return enuValueList.toArray(new String [] {}); 81 } 82 83 @Override 84 public boolean canWrite() { 85 return mPropAdapter.isWritable(); 86 } 87 88 } 89 90 91 92 | Popular Tags |