1 19 20 28 29 package org.netbeans.modules.xml.schema.ui.basic.editors; 30 31 import java.beans.FeatureDescriptor ; 32 import java.beans.PropertyEditorSupport ; 33 import org.openide.explorer.propertysheet.ExPropertyEditor; 34 import org.openide.explorer.propertysheet.PropertyEnv; 35 import org.openide.util.NbBundle; 36 37 42 public class AnyNamespaceEditor extends PropertyEditorSupport 43 implements ExPropertyEditor{ 44 45 48 public AnyNamespaceEditor() { 49 } 50 51 public String [] getTags() { 52 return new String [] {NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_ANY"), 53 NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Other"), 54 NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_TargetNamespace"), 55 NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Local")}; 56 } 57 58 public void setAsText(String text) throws IllegalArgumentException { 59 if (text.equalsIgnoreCase(NbBundle.getMessage(BooleanDefaultFalseEditor.class, 60 "LBL_ANY"))){ 61 setValue("##any"); 62 } 63 else if (text.equalsIgnoreCase(NbBundle.getMessage(BooleanDefaultFalseEditor.class, 64 "LBL_Other"))){ 65 setValue("##other"); 66 } 67 else if (text.equalsIgnoreCase(NbBundle.getMessage(BooleanDefaultFalseEditor.class, 68 "LBL_TargetNamespace"))){ 69 setValue("##targetNamespace"); 70 } 71 else if (text.equalsIgnoreCase(NbBundle.getMessage(BooleanDefaultFalseEditor.class, 72 "LBL_Local"))){ 73 setValue("##local"); 74 } 75 else { 76 setValue(text); 77 } 78 79 } 80 81 public String getAsText() { 82 Object obj = getValue(); 83 if (obj == null){ 84 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_ANY"); 85 } 86 if (obj instanceof String ){ 87 String val = (String )obj; 88 if(val.equals("##any")) 89 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_ANY"); 90 if(val.equals("##other")) 91 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Other"); 92 if(val.equals("##targetNamespace")) 93 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_TargetNamespace"); 94 if(val.equals("##local")) 95 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_Local"); 96 return val; 97 } 98 return NbBundle.getMessage(BooleanDefaultFalseEditor.class,"LBL_ANY"); 100 } 101 102 107 public void attachEnv(PropertyEnv env ) { 108 FeatureDescriptor desc = env.getFeatureDescriptor(); 109 desc.setValue("canEditAsText", Boolean.TRUE); } 112 } 113 | Popular Tags |