1 19 20 package org.netbeans.modules.tasklist.core.filter; 21 22 import javax.swing.*; 23 import org.netbeans.spi.settings.DOMConvertor; 24 25 31 public abstract class FilterCondition { 32 transient private String name = null; 33 34 39 public FilterCondition() { 40 this.name = null; 41 } 42 43 46 protected FilterCondition(final FilterCondition rhs) { 47 this.name = rhs.name; 48 } 49 50 53 public abstract Object clone() ; 54 55 60 public String getName() { 61 if (this.name == null) this.name = getDisplayName(); 62 return this.name; 63 } 64 65 70 public abstract boolean isTrue(Object obj); 71 72 79 public JComponent createConstantComponent() { 80 return null; 81 } 82 83 90 public void getConstantFrom(JComponent cmp) { 91 assert cmp != null : "getConstantFrom() is not implemented!"; 92 } 93 94 final boolean isValueValid(JComponent cmp) { 95 Boolean valid = (Boolean ) cmp.getClientProperty(PROP_VALUE_VALID); 96 if (valid == null) { 97 return true; 98 } else { 99 return valid.booleanValue(); 100 } 101 } 102 103 113 public boolean sameType(FilterCondition fc) { 114 return fc.getClass() == getClass(); 115 } 116 117 public String toString() { 118 return getClass().getName() + 119 "[name=" + name + "]"; } 121 122 123 public static final String PROP_VALUE_VALID = "value-valid"; 124 125 126 protected abstract String getDisplayName(); 127 128 129 135 protected abstract static class Convertor extends DOMConvertor { 136 137 138 protected Convertor(String rootElement) { 139 super("-//NetBeans org.netbeans.modules.tasklist//DTD" + rootElement+" 1.0//EN", "http://tasklist.netbeans.org/dtd/conditions-1_0.dtd", rootElement); } 142 143 public void registerSaver(Object obj, org.netbeans.spi.settings.Saver saver) { 144 } 146 147 public void unregisterSaver(Object obj, org.netbeans.spi.settings.Saver saver) { 148 } 150 151 152 protected void writeCondition(org.w3c.dom.Document document, org.w3c.dom.Element element, FilterCondition cond) 153 throws java.io.IOException , org.w3c.dom.DOMException 154 { 155 } 157 158 protected void readCondition(org.w3c.dom.Element element, FilterCondition condition) 159 throws java.io.IOException , java.lang.ClassNotFoundException 160 { 161 } 163 164 } 165 166 } 167 168 | Popular Tags |