1 19 24 25 package org.netbeans.modules.j2ee.sun.ide.editors; 26 import org.openide.util.NbBundle; 27 28 32 public class CharsetDisplayPreferenceEditor extends LogLevelEditor{ 33 34 public static Integer DEFAULT_PREF_VAL = Integer.valueOf("1"); 36 private Integer val = DEFAULT_PREF_VAL; 37 38 39 40 public CharsetDisplayPreferenceEditor() { 41 } 42 43 static String [] choices = { 44 NbBundle.getMessage(CharsetDisplayPreferenceEditor.class,"VAL_CANONICAL"), NbBundle.getMessage(CharsetDisplayPreferenceEditor.class,"VAL_ALIAS_ASIDE"), NbBundle.getMessage(CharsetDisplayPreferenceEditor.class,"VAL_ALIAS"), }; 48 49 public String [] getTags() { 50 return choices; 51 } 52 53 public String getAsText() { 54 return choices[val.intValue()]; 55 } 56 57 public void setAsText(String string) throws IllegalArgumentException { 58 int intVal = 1; 59 if((string==null)||(string.equals(""))) throw new IllegalArgumentException (); 61 else 62 intVal = java.util.Arrays.binarySearch(choices,string); 63 if (intVal < 0) { 64 intVal = 1; 65 } 66 if (intVal > 2){ 67 intVal = 1; 68 } 69 String valS = String.valueOf(intVal); 70 val = Integer.valueOf(valS); 71 this.firePropertyChange(); 72 } 73 74 public void setValue(Object val) { 75 if (val==null){ 76 val=DEFAULT_PREF_VAL; 77 } 78 if (! (val instanceof Integer )) { 79 throw new IllegalArgumentException (); 80 } 81 82 this.val = (Integer ) val; 83 int ival = this.val.intValue(); 84 if (ival < 0 || ival > 2){ 85 this.val = DEFAULT_PREF_VAL; 86 } 87 } 89 90 public Object getValue() { 91 return this.val; 92 } 93 } 94 | Popular Tags |