1 19 20 package org.netbeans.modules.tasklist.core.filter; 21 22 import javax.swing.*; 23 24 30 public class BooleanFilterCondition extends OneOfFilterCondition { 31 public static final int ISTRUE = 0; 32 public static final int ISFALSE = 1; 33 34 private static String [] NAME_KEYS = { 35 "IsTrue", "IsFalse", }; 38 39 44 public static BooleanFilterCondition[] createConditions() { 45 return new BooleanFilterCondition[] { 46 new BooleanFilterCondition(BooleanFilterCondition.ISTRUE), 47 new BooleanFilterCondition(BooleanFilterCondition.ISFALSE) 48 }; 49 }; 50 51 57 public BooleanFilterCondition(int id) { 58 super(NAME_KEYS, id); 59 } 60 61 public BooleanFilterCondition(final BooleanFilterCondition rhs) { 62 super(rhs); 63 } 64 65 public Object clone() { 66 return new BooleanFilterCondition(this); 67 } 68 69 BooleanFilterCondition() { super(NAME_KEYS);}; 70 71 public JComponent createConstantComponent() { 72 return null; 73 } 74 75 public boolean isTrue(Object obj) { 76 boolean n = ((Boolean ) obj).booleanValue(); 77 switch (getId()) { 78 case ISTRUE: 79 return n == true; 80 case ISFALSE: 81 return n == false; 82 default: 83 throw new InternalError ("wrong id"); } 85 } 86 87 88 private static class Convertor extends OneOfFilterCondition.Convertor { 89 private static final String ELEM_BOOLEAN_CONDITION = "BooleanCondition"; 90 91 public Convertor() { super(ELEM_BOOLEAN_CONDITION, NAME_KEYS);} 92 93 public static BooleanFilterCondition.Convertor create() { 94 return new BooleanFilterCondition.Convertor(); 95 } 96 protected OneOfFilterCondition createCondition() { return new BooleanFilterCondition();} 97 98 } 99 100 } 101 | Popular Tags |