1 package autotest.common.table; 2 3 import autotest.common.SimpleCallback; 4 5 import com.google.gwt.json.client.JSONObject; 6 import com.google.gwt.user.client.ui.Widget; 7 8 import java.util.ArrayList; 9 import java.util.List; 10 11 public abstract class Filter { 12 protected List<SimpleCallback> callbacks = new ArrayList<SimpleCallback>(); 13 addParams(JSONObject params)14 public abstract void addParams(JSONObject params); isActive()15 public abstract boolean isActive(); getWidget()16 public abstract Widget getWidget(); 17 18 // is this filter controlled by a user-facing widget? isUserControlled()19 public boolean isUserControlled() { 20 return getWidget() != null; 21 } 22 addCallback(SimpleCallback callback)23 public void addCallback(SimpleCallback callback) { 24 callbacks.add(callback); 25 } 26 removeCallback(SimpleCallback callback)27 public void removeCallback(SimpleCallback callback) { 28 callbacks.remove(callback); 29 } 30 notifyListeners()31 protected void notifyListeners() { 32 for (SimpleCallback callback : callbacks) { 33 callback.doCallback(this); 34 } 35 } 36 } 37