changeset 863:9bb8b7a751ec

Added filter for the "description" row of helper input tables. flys-client/trunk@2670 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 07 Sep 2011 17:22:21 +0000
parents c9549074ecd1
children c0e13cf826d7
files flys-client/ChangeLog flys-client/src/main/java/de/intevation/flys/client/client/event/FilterHandler.java flys-client/src/main/java/de/intevation/flys/client/client/event/StringFilterEvent.java flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java flys-client/src/main/java/de/intevation/flys/client/client/ui/TableFilter.java
diffstat 7 files changed, 345 insertions(+), 118 deletions(-) [+]
line wrap: on
line diff
--- a/flys-client/ChangeLog	Wed Sep 07 13:57:28 2011 +0000
+++ b/flys-client/ChangeLog	Wed Sep 07 17:22:21 2011 +0000
@@ -1,3 +1,22 @@
+2011-09-07  Raimund Renkert <raimund.renkert@intevation.de>
+
+	Added a filter for the "description" row of helper input tables.
+
+	* src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java,
+	  src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java:
+	  Added a filter for the input tables.
+	  The filter works as an "as you type" filter, if this is to slow, go to the
+	  'TableFilter' class and change the 'onKeyPress()' handler as documented in
+	  the code.
+
+	* src/main/java/de/intevation/flys/client/client/event/FilterHandler.java,
+	  src/main/java/de/intevation/flys/client/client/event/StringFilterEvent.java,
+	  src/main/java/de/intevation/flys/client/client/ui/TableFilter.java:
+	  New. These classes/interfaces are implemented by Ingo and are used for the
+	  table filter.
+	  They provide common functionality and interfaces for filtering.
+
 2011-09-07  Ingo Weinzierl <ingo@intevation.de>
 
 	* src/main/java/de/intevation/flys/client/shared/model/Artifact.java,,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/FilterHandler.java	Wed Sep 07 17:22:21 2011 +0000
@@ -0,0 +1,11 @@
+package de.intevation.flys.client.client.event;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public interface FilterHandler {
+
+    void onFilterCriteriaChanged(StringFilterEvent event);
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/StringFilterEvent.java	Wed Sep 07 17:22:21 2011 +0000
@@ -0,0 +1,20 @@
+package de.intevation.flys.client.client.event;
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class StringFilterEvent {
+
+    protected String filter;
+
+
+    public StringFilterEvent(String filter) {
+        this.filter = filter;
+    }
+
+
+    public String getFilter() {
+        return filter;
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java	Wed Sep 07 13:57:28 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java	Wed Sep 07 17:22:21 2011 +0000
@@ -6,6 +6,7 @@
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.NumberFormat;
 
+import com.smartgwt.client.data.Criteria;
 import com.smartgwt.client.data.Record;
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.Canvas;
@@ -31,9 +32,12 @@
 import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource;
 import de.intevation.flys.client.client.ui.range.RangeTable;
 import de.intevation.flys.client.client.ui.range.LocationsTable;
+import de.intevation.flys.client.client.event.FilterHandler;
+import de.intevation.flys.client.client.event.StringFilterEvent;
 
 
-public class DistancePanel extends AbstractUIProvider implements BlurHandler {
+public class DistancePanel extends AbstractUIProvider implements BlurHandler, FilterHandler
+{
 
     public static final int DEFAULT_STEP_WIDTH = 100;
 
@@ -461,7 +465,26 @@
         tabs.addTab(locations, 0);
         tabs.addTab(distances, 1);
 
+        TableFilter filter = new TableFilter();
+        filter.setHeight("30px");
+        filter.addFilterHandler(this);
+
         helperContainer.addMember(tabs);
+        helperContainer.addMember(filter);
+    }
+
+
+    public void onFilterCriteriaChanged(StringFilterEvent event) {
+        String search = event.getFilter();
+
+        if (search != null && search.length() > 0) {
+            Criteria c = new Criteria("description", search);
+            locationsTable.filterData(c);
+            distancesTable.filterData(c);
+        }
+        else {
+            // TODO Remove filter
+        }
     }
 
 
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java	Wed Sep 07 13:57:28 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java	Wed Sep 07 17:22:21 2011 +0000
@@ -8,6 +8,7 @@
 import com.google.gwt.i18n.client.NumberFormat;
 import com.google.gwt.user.client.rpc.AsyncCallback;
 
+import com.smartgwt.client.data.Criteria;
 import com.smartgwt.client.widgets.Canvas;
 import com.smartgwt.client.widgets.Label;
 import com.smartgwt.client.widgets.form.DynamicForm;
@@ -47,6 +48,11 @@
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.FLYSImages;
 import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.event.FilterHandler;
+import de.intevation.flys.client.client.event.StringFilterEvent;
+import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource;
+import de.intevation.flys.client.client.ui.range.RangeTable;
+import de.intevation.flys.client.client.ui.range.LocationsTable;
 
 
 /**
@@ -56,7 +62,7 @@
  */
 public class LocationDistancePanel
 extends      AbstractUIProvider
-implements   ChangeHandler, BlurHandler
+implements   ChangeHandler, BlurHandler, FilterHandler
 {
     /** The message class that provides i18n strings. */
     protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
@@ -139,8 +145,14 @@
      */
     public LocationDistancePanel() {
         distanceTable  = new ListGrid();
+        distanceTable.setAutoFetchData(true);
+
         locationsTable = new ListGrid();
+        locationsTable.setAutoFetchData(true);
+
         locationDistanceTable = new ListGrid();
+        locationDistanceTable.setAutoFetchData(true);
+
         locationDistanceTable.setShowHeaderContextMenu(false);
         distanceTable.setShowHeaderContextMenu(false);
         locationsTable.setShowHeaderContextMenu(false);
@@ -167,9 +179,9 @@
 
         initDefaults(data);
 
+        createLocationTableDistance ();
         createDistanceTable();
         createLocationTable();
-        createLocationTableDistance ();
 
         widget.setHeight(50);
         label.setHeight(25);
@@ -186,6 +198,7 @@
      * This method creates a table that contains the distance values.
      */
     protected void createDistanceTable() {
+
         distanceTable.setWidth100();
         distanceTable.setShowRecordComponents(true);
         distanceTable.setShowRecordComponentsByCell(true);
@@ -199,15 +212,26 @@
             public void onRecordClick (RecordClickEvent e) {
                 if (!isLocationMode ()) {
                     Record r = e.getRecord();
-                    double min = r.getAttributeAsDouble("from");
-                    double max = r.getAttributeAsDouble("to");
-                    setDistanceValues(min, max);
+                    try {
+                        double min = Double.parseDouble(r.getAttribute("from"));
+                        double max = Double.parseDouble(r.getAttribute("to"));
+                        setDistanceValues(min, max);
+                    }
+                    catch(NumberFormatException nfe) {
+                        // Is there anything to do?
+                    }
                 }
                 else {
                     double[] selected;
                     Record r = e.getRecord();
-                    double min = r.getAttributeAsDouble("from");
-                    double max = r.getAttributeAsDouble("to");
+                    double min = 0, max = 0;
+                    try {
+                        min = Double.parseDouble(r.getAttribute("from"));
+                        max = Double.parseDouble(r.getAttribute("to"));
+                    }
+                    catch(NumberFormatException nfe) {
+                        // Is there anything to do?
+                    }
                     if (getLocationValues() != null) {
                         double[] val = getLocationValues();
                         selected = new double[val.length + 2];
@@ -274,7 +298,7 @@
 
         addLocation.addRecordClickHandler (new RecordClickHandler () {
             public void onRecordClick (RecordClickEvent e) {
-                ListGridRecord[] records = locationsTable.getSelection();
+                Record record = e.getRecord();
                 double[] selected;
                 if (getLocationValues() != null) {
                     double[] val = getLocationValues();
@@ -282,12 +306,18 @@
                     for(int i = 0; i < val.length; i++){
                         selected[i] = val[i];
                     }
-                    selected[val.length] =
-                        records[0].getAttributeAsDouble("from");
+                    try {
+                        selected[val.length] =
+                            Double.parseDouble(record.getAttribute("from"));
+                    }
+                    catch(NumberFormatException nfe) {
+                        // Is there anything to do here?
+                    }
                 }
                 else {
                     selected = new double[1];
-                    selected[0] = records[0].getAttributeAsDouble("from");
+                    selected[0] =
+                        Double.parseDouble(record.getAttribute("from"));
                 }
                 setLocationValues(selected);
             }
@@ -324,8 +354,6 @@
      * This method creates a table that contains the location values.
      */
     protected void createLocationTableDistance (){
-        locationDistanceTable = null;
-        locationDistanceTable = new ListGrid ();
         locationDistanceTable.setWidth100();
         locationDistanceTable.setShowRecordComponents(true);
         locationDistanceTable.setShowRecordComponentsByCell(true);
@@ -342,6 +370,43 @@
         addto2.setWidth (20);
         addto2.setCellIcon (IMAGES.markerRed ().getURL ());
 
+        locationDistanceTable.addCellClickHandler (new CellClickHandler () {
+            public void onCellClick (CellClickEvent e) {
+                if (e.getColNum() == 0) {
+                    Record r = e.getRecord ();
+                    try {
+                        double fromvalue =
+                             Double.parseDouble(r.getAttribute("from"));
+                        double tovalue = getTo ();
+                        setDistanceValues (fromvalue, tovalue);
+                    }
+                    catch(NumberFormatException nfe) {
+                        // Is there anything to do in here?
+                    }
+                }
+                else if (e.getColNum() == 1) {
+                    Record r = e.getRecord ();
+                    try {
+                        double fromvalue = getFrom ();
+                        double tovalue =
+                            Double.parseDouble(r.getAttribute("from"));
+                        setDistanceValues (fromvalue, tovalue);
+                    }
+                    catch(NumberFormatException nfe) {
+                        // Is there anything to do in here?
+                    }
+                }
+            }
+        });
+        ListGridField bottom =
+            new ListGridField("bottom", MESSAGES.bottom_edge());
+        bottom.setType(ListGridFieldType.TEXT);
+        bottom.setWidth(30);
+
+        ListGridField top =
+            new ListGridField("top", MESSAGES.top_edge());
+        top.setType(ListGridFieldType.TEXT);
+        top.setWidth(30);
 
         ListGridField ldescr = new ListGridField("description",
                 MESSAGES.description());
@@ -354,31 +419,6 @@
         ListGridField loc = new ListGridField("from", MESSAGES.locations());
         loc.setType(ListGridFieldType.TEXT);
         loc.setWidth(40);
-        locationDistanceTable.addCellClickHandler (new CellClickHandler () {
-            public void onCellClick (CellClickEvent e) {
-                if (e.getColNum() == 0) {
-                    Record r = e.getRecord ();
-                    double fromvalue = r.getAttributeAsDouble ("from");
-                    double tovalue = getTo ();
-                    setDistanceValues (fromvalue, tovalue);
-                }
-                else if (e.getColNum() == 1) {
-                    Record r = e.getRecord ();
-                    double fromvalue = getFrom ();
-                    double tovalue = r.getAttributeAsDouble ("to");
-                    setDistanceValues (fromvalue, tovalue);
-                }
-            }
-        });
-        ListGridField bottom =
-            new ListGridField("bottom", MESSAGES.bottom_edge());
-        bottom.setType(ListGridFieldType.TEXT);
-        bottom.setWidth(30);
-
-        ListGridField top =
-            new ListGridField("top", MESSAGES.top_edge());
-        top.setType(ListGridFieldType.TEXT);
-        top.setWidth(30);
 
         locationDistanceTable.setFields(
             addfrom, addto2, ldescr, loc, lside, bottom, top);
@@ -562,18 +602,48 @@
         inputTables.setWidth100();
         inputTables.setHeight100();
 
-        locations.setPane(locationsTable);
+        locations.setPane(locationDistanceTable);
         distances.setPane(distanceTable);
 
         inputTables.addTab(locations);
         inputTables.addTab(distances);
 
-        helperContainer.addMember(inputTables);
+        TableFilter filter = new TableFilter();
+        filter.setHeight("30px");
+        filter.addFilterHandler(this);
+
+        inputTables.setHeight("*");
+
+        VLayout helper = new VLayout();
+        helper.addMember(inputTables);
+        helper.addMember(filter);
+        helper.setHeight100();
+        helper.setWidth100();
+
+        helperContainer.addChild(helper);
 
         return layout;
     }
 
 
+    public void onFilterCriteriaChanged(StringFilterEvent event) {
+        String search = event.getFilter();
+
+        if (search != null && search.length() > 0) {
+            Criteria c = new Criteria("description", search);
+
+            locationsTable.filterData(c);
+            distanceTable.filterData(c);
+            locationDistanceTable.filterData(c);
+        }
+        else {
+            // TODO Remove filter
+        }
+    }
+
+
+
+
     @Override
     public List<String> validate() {
         if (isLocationMode()) {
@@ -859,42 +929,32 @@
         }
         if (value.equals(FIELD_VALUE_LOCATION)) {
             enableLocationPanel();
+            // Remove the tab containing the locationDistanceTable.
+            // The 'updateTab()' avoids the tab content to be destroyed.
+            inputTables.updateTab(0, null);
+            inputTables.removeTab(0);
 
-            while (inputTables.getNumTabs() > 0) {
-                inputTables.removeTab(0);
-            }
+            // Create a new tab containing the locationTable
             Tab t1 = new Tab (MESSAGES.locations());
-            createLocationTable();
             t1.setPane(locationsTable);
-            inputTables.addTab(t1);
-            createDistanceTable();
-            Tab t2 = new Tab (MESSAGES.distance());
-            t2.setPane(distanceTable);
-            inputTables.addTab(t2);
-            updateDistanceInfo(tableData);
+            inputTables.addTab(t1, 0);
 
-            helperContainer.addMember(inputTables);
+            // Bring this tab to front.
             inputTables.selectTab(0);
         }
         else {
             enableDistancePanel();
+            // Remove the tab containing the locationTable.
+            // The 'updateTab()' avoids the tab content to be destroyed.
+            inputTables.updateTab(0, null);
+            inputTables.removeTab(0);
 
-            while (inputTables.getNumTabs () > 0) {
-                inputTables.removeTab(0);
-            }
+            //Create a new tab containing the locationDistanceTable.
             Tab t1 = new Tab(MESSAGES.locations());
-            createLocationTableDistance ();
             t1.setPane(locationDistanceTable);
-            inputTables.addTab(t1);
-            createDistanceTable ();
-            Tab t2 = new Tab(MESSAGES.distance ());
-            t2.setPane(distanceTable);
-            inputTables.addTab(t2);
-            if (tableData != null) {
-                updateDistanceInfo(tableData);
-            }
+            inputTables.addTab(t1, 0);
 
-            helperContainer.addMember(inputTables);
+            // Bring the distanceTable tab to front.
             inputTables.selectTab(1);
         }
     }
@@ -1040,29 +1100,16 @@
             }
         }
 
-        distanceInfoService.getDistanceInfo(url, locale, river,
-            new AsyncCallback<DistanceInfoObject[]>() {
-                public void onFailure(Throwable caught) {
-                    GWT.log("Could not recieve distance informations.");
-                    GWT.log(caught.getMessage());
-                }
-
-                public void onSuccess(DistanceInfoObject[] di) {
-                    int num = di != null ? di.length :0;
-                    GWT.log("Recieved " + num + " distance informations.");
-
-                    if (num == 0) {
-                        return;
-                    }
-                    tableData = di;
-                    updateDistanceInfo(di);
-                }
-            }
-        );
+        distanceTable.setDataSource(new DistanceInfoDataSource(
+            url, river, "distances"));
+        locationsTable.setDataSource(new DistanceInfoDataSource(
+            url, river, "locations"));
+        locationDistanceTable.setDataSource(new DistanceInfoDataSource(
+            url, river, "locations"));
     }
 
 
-    protected void updateDistanceInfo(DistanceInfoObject[] di) {
+/*    protected void updateDistanceInfo(DistanceInfoObject[] di) {
         int i = 0;
         for (DistanceInfoObject dio: di) {
             if (dio.getTo() != null) {
@@ -1074,7 +1121,7 @@
             }
         }
         return;
-    }
+    }*/
 
 
     protected double getFrom() {
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java	Wed Sep 07 13:57:28 2011 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java	Wed Sep 07 17:22:21 2011 +0000
@@ -21,6 +21,8 @@
 import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
 import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
 
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.Record;
 import com.smartgwt.client.types.ListGridFieldType;
 
 import de.intevation.flys.client.shared.model.Data;
@@ -37,6 +39,9 @@
 import de.intevation.flys.client.client.FLYSConstants;
 import de.intevation.flys.client.client.FLYSImages;
 import de.intevation.flys.client.client.Config;
+import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource;
+import de.intevation.flys.client.client.event.FilterHandler;
+import de.intevation.flys.client.client.event.StringFilterEvent;
 
 
 /**
@@ -46,6 +51,7 @@
  */
 public class SingleLocationPanel
 extends      AbstractUIProvider
+implements   FilterHandler
 {
     /** The message class that provides i18n strings.*/
     protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
@@ -135,9 +141,15 @@
         addLocation.setWidth (20);
         addLocation.addRecordClickHandler (new RecordClickHandler () {
             public void onRecordClick (RecordClickEvent e) {
-                ListGridRecord[] records = locationTable.getSelection();
+                Record record = e.getRecord();
                 double[] selected = new double[1];
-                selected[0] = records[0].getAttributeAsDouble("from");
+                try {
+                    selected[0] =
+                        Double.parseDouble(record.getAttribute("from"));
+                }
+                catch(NumberFormatException nfe) {
+                    // Is there anything else to do here?
+                }
                 setLocationValues(selected);
             }
         });
@@ -264,17 +276,36 @@
                 MESSAGES.unitLocation(),
                 getLocationValues(),
                 new BlurHandler(){public void onBlur(BlurEvent be) {}});
+
+        locationTable.setAutoFetchData(true);
+
         container.addMember(locationPanel);
 
         layout.addMember(container);
 
         container.setMembersMargin(30);
 
+        TableFilter filter = new TableFilter();
+        filter.setHeight("30px");
+        filter.addFilterHandler(this);
+
         helperContainer.addMember(locationTable);
+        helperContainer.addMember(filter);
         createInputPanel();
         return layout;
     }
 
+    public void onFilterCriteriaChanged(StringFilterEvent event) {
+        String search = event.getFilter();
+
+        if (search != null && search.length() > 0) {
+            Criteria c = new Criteria("description", search);
+            locationTable.filterData(c);
+        }
+        else {
+            // TODO Remove filter
+        }
+    }
 
     @Override
     public List<String> validate() {
@@ -399,36 +430,8 @@
             }
         }
 
-        distanceInfoService.getDistanceInfo(url, locale, river,
-            new AsyncCallback<DistanceInfoObject[]>() {
-                public void onFailure(Throwable caught) {
-                    GWT.log("Could not recieve location informations.");
-                    GWT.log(caught.getMessage());
-                }
-
-                public void onSuccess(DistanceInfoObject[] di) {
-                    int num = di != null ? di.length :0;
-                    GWT.log("Recieved " + num + " location informations.");
-
-                    if (num == 0) {
-                        return;
-                    }
-                    tableData = di;
-                    updateLocationInfo(di);
-                }
-            }
-        );
-    }
-
-
-    protected void updateLocationInfo(DistanceInfoObject[] di) {
-        int i = 0;
-        for (DistanceInfoObject dio: di) {
-            if (dio.getTo() == null) {
-                locationTable.addData(new DistanceInfoRecord(dio));
-            }
-        }
-        return;
+        locationTable.setDataSource(new DistanceInfoDataSource(
+            url, river, "locations"));
     }
 
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableFilter.java	Wed Sep 07 17:22:21 2011 +0000
@@ -0,0 +1,104 @@
+package de.intevation.flys.client.client.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
+import com.smartgwt.client.widgets.form.fields.events.ChangedHandler;
+import com.smartgwt.client.widgets.form.fields.events.KeyPressEvent;
+import com.smartgwt.client.widgets.form.fields.events.KeyPressHandler;
+import com.smartgwt.client.widgets.layout.HLayout;
+
+import de.intevation.flys.client.client.event.FilterHandler;
+import de.intevation.flys.client.client.event.StringFilterEvent;
+
+
+/**
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
+ */
+public class TableFilter
+extends      HLayout
+implements   ChangedHandler, ClickHandler, KeyPressHandler
+{
+    public static final String SEARCH_FIELD = "searchfield";
+
+
+    protected List<FilterHandler> handlers;
+
+    protected TextItem searchfield;
+
+
+    public TableFilter() {
+        super();
+        searchfield = new TextItem(SEARCH_FIELD);
+        handlers    = new ArrayList<FilterHandler>();
+
+        searchfield.addChangedHandler(this);
+        searchfield.addKeyPressHandler(this);
+
+        DynamicForm form = new DynamicForm();
+        form.setFields(searchfield);
+
+        IButton clear = new IButton("Clear");
+        clear.addClickHandler(this);
+
+        addMember(form);
+        addMember(clear);
+    }
+
+
+    public void onChanged(ChangedEvent event) {
+        // This event handler is to slow...
+//        fireFilterCriteriaChanged(getSearchString());
+    }
+
+
+    public void onKeyPress(KeyPressEvent event) {
+        //To deactivate "As you type" filter add
+        // ' && event.getKeyName().equals("Enter")'
+        // to the if-clause.
+        if (event != null) {
+        //    fireFilterCriteriaChanged(getSearchString());
+        }
+    }
+
+
+    public void onClick(ClickEvent event) {
+        searchfield.setValue("");
+        fireFilterCriteriaChanged("");
+    }
+
+
+    public void clearSearch() {
+        searchfield.setValue("");
+    }
+
+
+    public String getSearchString() {
+        return searchfield.getValueAsString();
+    }
+
+
+    public void addFilterHandler(FilterHandler handler) {
+        if (handler != null) {
+            handlers.add(handler);
+        }
+    }
+
+
+    protected void fireFilterCriteriaChanged(String searchstring) {
+        StringFilterEvent filter = new StringFilterEvent(searchstring);
+
+        for (FilterHandler handler: handlers) {
+            handler.onFilterCriteriaChanged(filter);
+        }
+    }
+}
+// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org