1 19 20 28 29 package org.netbeans.modules.xml.schema.ui.basic.editors; 30 31 import java.beans.PropertyEditorSupport ; 32 import org.netbeans.modules.xml.schema.model.Occur; 33 import org.openide.util.NbBundle; 34 35 39 public class ZeroOrOneEditor extends PropertyEditorSupport { 40 41 public static final String EMPTY_STRING = ""; 43 44 public ZeroOrOneEditor() { 45 } 46 47 public String [] getTags() { 48 return new String [] {NbBundle.getMessage(ZeroOrOneEditor.class,"LBL_0"), 49 NbBundle.getMessage(ZeroOrOneEditor.class,"LBL_1")}; 50 } 51 52 public void setAsText(String text) throws IllegalArgumentException { 53 if (text == null){ 54 setValue(null); 55 return; 56 } else if(NbBundle.getMessage(ZeroOrOneEditor.class,"LBL_0").equals(text)) { 57 setValue(Occur.ZeroOne.ZERO); 58 } else if (NbBundle.getMessage(ZeroOrOneEditor.class,"LBL_1").equals(text)) { 59 setValue(Occur.ZeroOne.ONE); 60 } 61 } 62 63 public String getAsText() { 64 Object val = getValue(); 65 if (val == null){ 66 return null; 67 } 68 if (val instanceof Integer ){ 69 return ((Integer )val).toString(); 70 } 71 return val.toString(); 73 } 74 } 75 | Popular Tags |