diff gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java @ 9064:28c50f5efceb

work on uinfo-vegetation-zones table
author gernotbelger
date Wed, 09 May 2018 16:31:12 +0200
parents 5e38e2924c07
children 8c0d1542c1d8
line wrap: on
line diff
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java	Tue May 08 15:21:23 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DistancePanel.java	Wed May 09 16:31:12 2018 +0200
@@ -8,9 +8,27 @@
 
 package org.dive4elements.river.client.client.ui;
 
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import org.dive4elements.river.client.client.Config;
+import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.client.event.FilterHandler;
+import org.dive4elements.river.client.client.event.RangeFilterEvent;
+import org.dive4elements.river.client.client.event.StringFilterEvent;
+import org.dive4elements.river.client.client.ui.range.DistanceInfoDataSource;
+import org.dive4elements.river.client.client.ui.range.LocationsTable;
+import org.dive4elements.river.client.client.ui.range.RangeTable;
+import org.dive4elements.river.client.shared.model.ArtifactDescription;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.DefaultData;
+import org.dive4elements.river.client.shared.model.DefaultDataItem;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.NumberFormat;
-
 import com.smartgwt.client.data.AdvancedCriteria;
 import com.smartgwt.client.data.Criteria;
 import com.smartgwt.client.data.Criterion;
@@ -37,30 +55,8 @@
 import com.smartgwt.client.widgets.tab.events.TabSelectedEvent;
 import com.smartgwt.client.widgets.tab.events.TabSelectedHandler;
 
-import org.dive4elements.river.client.client.Config;
-import org.dive4elements.river.client.client.FLYSConstants;
-import org.dive4elements.river.client.client.event.FilterHandler;
-import org.dive4elements.river.client.client.event.RangeFilterEvent;
-import org.dive4elements.river.client.client.event.StringFilterEvent;
-import org.dive4elements.river.client.client.ui.range.DistanceInfoDataSource;
-import org.dive4elements.river.client.client.ui.range.LocationsTable;
-import org.dive4elements.river.client.client.ui.range.RangeTable;
-import org.dive4elements.river.client.shared.model.ArtifactDescription;
-import org.dive4elements.river.client.shared.model.Data;
-import org.dive4elements.river.client.shared.model.DataItem;
-import org.dive4elements.river.client.shared.model.DataList;
-import org.dive4elements.river.client.shared.model.DefaultData;
-import org.dive4elements.river.client.shared.model.DefaultDataItem;
-
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-
 /** Panel to allow input of distance for calculation range. */
-public class DistancePanel
-    extends AbstractUIProvider implements BlurHandler, FilterHandler
-{
+public class DistancePanel extends AbstractUIProvider implements BlurHandler, FilterHandler {
 
     private static final long serialVersionUID = -883142387908664588L;
 
@@ -68,12 +64,11 @@
 
     public static final String FIELD_LOWER = "ld_from";
     public static final String FIELD_UPPER = "ld_to";
-    public static final String FIELD_STEP  = "ld_step";
-
+    public static final String FIELD_STEP = "ld_step";
 
     protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
 
-    protected RangeTable     distancesTable;
+    protected RangeTable distancesTable;
     protected LocationsTable locationsTable;
 
     protected DoubleRangePanel distancePanel;
@@ -93,28 +88,24 @@
         this("right");
     }
 
-
-    public DistancePanel(String labelOrientation) {
-        distancePanel  = new DoubleRangePanel(
-            labelFrom(), labelTo(), labelStep(),
-            0d, 0d, 0d, 250, this, labelOrientation);
+    public DistancePanel(final String labelOrientation) {
+        this.distancePanel = new DoubleRangePanel(labelFrom(), labelTo(), labelStep(), 0d, 0d, 0d, 250, this, labelOrientation);
     }
 
-
     @Override
-    public Canvas create(DataList data) {
-        VLayout layout = new VLayout();
+    public Canvas create(final DataList data) {
+        final VLayout layout = new VLayout();
         layout.setMembersMargin(10);
 
-        Label label = new Label(getLabel());
+        final Label label = new Label(getLabel());
 
-        Canvas submit = getNextButton();
+        final Canvas submit = getNextButton();
 
         label.setHeight(25);
-        distancePanel.setHeight(50);
+        this.distancePanel.setHeight(50);
 
         layout.addMember(label);
-        layout.addMember(distancePanel);
+        layout.addMember(this.distancePanel);
         layout.addMember(submit);
 
         initMinMaxValues(data);
@@ -124,16 +115,15 @@
         return layout;
     }
 
-
     @Override
-    public Canvas createOld(DataList dataList) {
-        String s = getOldSelectionString(dataList);
-        String l = dataList.getLabel();
+    public Canvas createOld(final DataList dataList) {
+        final String s = getOldSelectionString(dataList);
+        final String l = dataList.getLabel();
 
-        Label label    = new Label(l);
-        Label selected = new Label(s);
+        final Label label = new Label(l);
+        final Label selected = new Label(s);
 
-        HLayout layout = new HLayout();
+        final HLayout layout = new HLayout();
 
         layout.setWidth(400);
         label.setWidth(200);
@@ -146,19 +136,18 @@
         return layout;
     }
 
-
-    protected String getOldSelectionString(DataList dataList) {
-        List<Data> items = dataList.getAll();
+    protected String getOldSelectionString(final DataList dataList) {
+        final List<Data> items = dataList.getAll();
 
-        Data dFrom = getData(items, getLowerField());
-        Data dTo   = getData(items, getUpperField());
-        Data dStep = getData(items, getStepField());
+        final Data dFrom = getData(items, getLowerField());
+        final Data dTo = getData(items, getUpperField());
+        final Data dStep = getData(items, getStepField());
 
-        DataItem[] from = dFrom.getItems();
-        DataItem[] to   = dTo.getItems();
-        DataItem[] step = dStep.getItems();
+        final DataItem[] from = dFrom.getItems();
+        final DataItem[] to = dTo.getItems();
+        final DataItem[] step = dStep.getItems();
 
-        StringBuilder sb = new StringBuilder();
+        final StringBuilder sb = new StringBuilder();
         sb.append(from[0].getLabel());
         sb.append(" " + getUnitFrom() + " - ");
         sb.append(to[0].getLabel());
@@ -169,78 +158,64 @@
         return sb.toString();
     }
 
-
     protected String getLabel() {
-        return MSG.distance_state();
+        return this.MSG.distance_state();
     }
 
-
     protected String labelFrom() {
         return getLabelFrom() + " [" + getUnitFrom() + "]";
     }
 
-
     protected String getLabelFrom() {
-        return MSG.dpLabelFrom();
+        return this.MSG.dpLabelFrom();
     }
 
-
     protected String getUnitFrom() {
-        return MSG.dpUnitFrom();
+        return this.MSG.dpUnitFrom();
     }
 
-
     protected String labelTo() {
         return getLabelTo() + " [" + getUnitTo() + "]";
     }
 
-
     protected String getLabelTo() {
-        return MSG.dpLabelTo();
+        return this.MSG.dpLabelTo();
     }
 
-
     protected String getUnitTo() {
-        return MSG.dpUnitTo();
+        return this.MSG.dpUnitTo();
     }
 
-
     protected String labelStep() {
         return getLabelStep() + " [" + getUnitStep() + "]";
     }
 
-
     protected String getLabelStep() {
-        return MSG.dpLabelStep();
+        return this.MSG.dpLabelStep();
     }
 
-
     protected String getUnitStep() {
-        return MSG.dpUnitStep();
+        return this.MSG.dpUnitStep();
     }
 
-
     protected String getLowerField() {
         return FIELD_LOWER;
     }
 
-
     protected String getUpperField() {
         return FIELD_UPPER;
     }
 
-
     protected String getStepField() {
         return FIELD_STEP;
     }
 
-
     @Override
     public List<String> validate() {
-        List<String> errors = new ArrayList<String>();
+        final List<String> errors = new ArrayList<String>();
 
-        if (!distancePanel.validateForm()) {
-            errors.add(MSG.wrongFormat());
+        if (!this.distancePanel.validateForm()) {
+            errors.add(this.MSG.wrongFormat());
 
             return errors;
         }
@@ -251,413 +226,366 @@
         return errors;
     }
 
-
-    protected void validateFrom(List<String> errors) {
-        double from = distancePanel.getFrom();
+    protected void validateFrom(final List<String> errors) {
+        final double from = this.distancePanel.getFrom();
 
-        if (from < min || from > max) {
-            NumberFormat nf = NumberFormat.getDecimalFormat();
+        if (from < this.min || from > this.max) {
+            final NumberFormat nf = NumberFormat.getDecimalFormat();
 
-            String tmp = MSG.error_validate_lower_range();
-            tmp        = tmp.replace("$1", nf.format(from));
-            tmp        = tmp.replace("$2", nf.format(min));
+            String tmp = this.MSG.error_validate_lower_range();
+            tmp = tmp.replace("$1", nf.format(from));
+            tmp = tmp.replace("$2", nf.format(this.min));
 
-            distancePanel.setFrom(min);
+            this.distancePanel.setFrom(this.min);
             errors.add(tmp);
         }
     }
 
-
-    protected void validateTo(List<String> errors) {
-        double to = distancePanel.getTo();
+    protected void validateTo(final List<String> errors) {
+        final double to = this.distancePanel.getTo();
 
-        if (to < min || to > max) {
-            NumberFormat nf = NumberFormat.getDecimalFormat();
+        if (to < this.min || to > this.max) {
+            final NumberFormat nf = NumberFormat.getDecimalFormat();
 
-            String tmp = MSG.error_validate_upper_range();
-            tmp        = tmp.replace("$1", nf.format(to));
-            tmp        = tmp.replace("$2", nf.format(max));
+            String tmp = this.MSG.error_validate_upper_range();
+            tmp = tmp.replace("$1", nf.format(to));
+            tmp = tmp.replace("$2", nf.format(this.max));
 
-            distancePanel.setTo(max);
+            this.distancePanel.setTo(this.max);
             errors.add(tmp);
         }
     }
 
-
     @Override
     public Data[] getData() {
-        Data[] data = new Data[4];
+        final Data[] data = new Data[4];
 
         data[0] = getDataFrom();
         data[1] = getDataTo();
         data[2] = getDataStep();
 
-        DataItem item = new DefaultDataItem("ld_mode","ld_mode", "distance");
-        data[3]       = new DefaultData(
-            "ld_mode", null, null, new DataItem[] { item });
+        final DataItem item = new DefaultDataItem("ld_mode", "ld_mode", "distance");
+        data[3] = new DefaultData("ld_mode", null, null, new DataItem[] { item });
 
         return data;
     }
 
-
     protected Data getDataFrom() {
-        String value = String.valueOf(distancePanel.getFrom());
-        String field = getLowerField();
+        final String value = String.valueOf(this.distancePanel.getFrom());
+        final String field = getLowerField();
 
-        DataItem item = new DefaultDataItem(field, field, value);
-        return new DefaultData(
-            field, null, null, new DataItem[] { item });
+        final DataItem item = new DefaultDataItem(field, field, value);
+        return new DefaultData(field, null, null, new DataItem[] { item });
     }
 
-
     protected Data getDataTo() {
-        String value = String.valueOf(distancePanel.getTo());
-        String field = getUpperField();
+        final String value = String.valueOf(this.distancePanel.getTo());
+        final String field = getUpperField();
 
-        DataItem item = new DefaultDataItem(field, field, value);
-        return new DefaultData(
-            field, null, null, new DataItem[] { item });
+        final DataItem item = new DefaultDataItem(field, field, value);
+        return new DefaultData(field, null, null, new DataItem[] { item });
     }
 
-
     protected Data getDataStep() {
-        String value = String.valueOf(distancePanel.getStep());
-        String field = getStepField();
+        final String value = String.valueOf(this.distancePanel.getStep());
+        final String field = getStepField();
 
-        DataItem item = new DefaultDataItem(field, field, value);
-        return new DefaultData(
-            field, null, null, new DataItem[] { item });
-    }
-
-
-    @Override
-    public void onBlur(BlurEvent event) {
-        distancePanel.validateForm();
+        final DataItem item = new DefaultDataItem(field, field, value);
+        return new DefaultData(field, null, null, new DataItem[] { item });
     }
 
+    @Override
+    public void onBlur(final BlurEvent event) {
+        this.distancePanel.validateForm();
+    }
 
-    protected void initMinMaxValues(DataList data) {
-        Data f = getData(data.getAll(), getLowerField());
-        Data t = getData(data.getAll(), getUpperField());
+    protected void initMinMaxValues(final DataList data) {
+        final Data f = getData(data.getAll(), getLowerField());
+        final Data t = getData(data.getAll(), getUpperField());
 
-        DataItem[] fItems = f.getItems();
-        DataItem[] tItems = t.getItems();
+        final DataItem[] fItems = f.getItems();
+        final DataItem[] tItems = t.getItems();
 
         try {
-            min = Double.valueOf(fItems[0].getStringValue());
-            max = Double.valueOf(tItems[0].getStringValue());
+            this.min = Double.valueOf(fItems[0].getStringValue());
+            this.max = Double.valueOf(tItems[0].getStringValue());
         }
-        catch (NumberFormatException nfe) {
-            min = -Double.MAX_VALUE;
-            max =  Double.MAX_VALUE;
+        catch (final NumberFormatException nfe) {
+            this.min = -Double.MAX_VALUE;
+            this.max = Double.MAX_VALUE;
         }
     }
 
-
-    protected void initDefaultValues(DataList data) {
+    protected void initDefaultValues(final DataList data) {
         initDefaultFrom(data);
         initDefaultTo(data);
         initDefaultStep(data);
     }
 
-
-    protected void initDefaultFrom(DataList data) {
-        Data f = getData(data.getAll(), getLowerField());
+    protected void initDefaultFrom(final DataList data) {
+        final Data f = getData(data.getAll(), getLowerField());
 
         double from = getDefaultFrom();
 
         try {
             from = getDefaultValue(f);
         }
-        catch (NumberFormatException nfe) {
+        catch (final NumberFormatException nfe) {
             // do nothing
         }
 
-        distancePanel.setFrom(from);
+        this.distancePanel.setFrom(from);
     }
 
-
     protected double getDefaultFrom() {
-        return min;
+        return this.min;
     }
 
-
-    protected void initDefaultTo(DataList data) {
-        Data t = getData(data.getAll(), getUpperField());
+    protected void initDefaultTo(final DataList data) {
+        final Data t = getData(data.getAll(), getUpperField());
 
         double to = getDefaultTo();
 
         try {
             to = getDefaultValue(t);
         }
-        catch (NumberFormatException nfe) {
+        catch (final NumberFormatException nfe) {
             // do nothing
         }
 
-        distancePanel.setTo(to);
+        this.distancePanel.setTo(to);
     }
 
-
     protected double getDefaultTo() {
-        return max;
+        return this.max;
     }
 
-
-    protected void initDefaultStep(DataList data) {
-        Data s = getData(data.getAll(), getStepField());
+    protected void initDefaultStep(final DataList data) {
+        final Data s = getData(data.getAll(), getStepField());
 
         double step = getDefaultStep();
 
         try {
             step = getDefaultValue(s);
         }
-        catch (NumberFormatException nfe) {
+        catch (final NumberFormatException nfe) {
             // do nothing
         }
 
-        distancePanel.setStep(step);
+        this.distancePanel.setStep(step);
     }
 
-
     protected double getDefaultStep() {
         return DEFAULT_STEP_WIDTH;
     }
 
-
     /** Gets the double from default in data, null if none. */
-    protected double getDefaultValue(Data data)
-    throws NumberFormatException
-    {
-        DataItem def      = data.getDefault();
-        String   defValue = def != null ? def.getStringValue() : null;
+    protected double getDefaultValue(final Data data) throws NumberFormatException {
+        final DataItem def = data.getDefault();
+        final String defValue = def != null ? def.getStringValue() : null;
 
         return Double.valueOf(defValue);
     }
 
-
     protected void initHelperPanel() {
-        distancesTable = new RangeTable();
-        locationsTable = new LocationsTable();
-
-        Config config = Config.getInstance();
-        String url    = config.getServerUrl();
-        String river  = getRiverName();
+        this.distancesTable = new RangeTable();
+        this.locationsTable = new LocationsTable();
 
-        distancesTable.setAutoFetchData(true);
-        locationsTable.setAutoFetchData(true);
-        distancesTable.setDataSource(new DistanceInfoDataSource(
-            url, river, "distances"));
-        locationsTable.setDataSource(new DistanceInfoDataSource(
-            url, river, "locations"));
+        final Config config = Config.getInstance();
+        final String url = config.getServerUrl();
+        final String river = getRiverName();
 
-        distancesTable.addRecordClickHandler(new RecordClickHandler() {
+        this.distancesTable.setAutoFetchData(true);
+        this.locationsTable.setAutoFetchData(true);
+        this.distancesTable.setDataSource(new DistanceInfoDataSource(url, river, "distances"));
+        this.locationsTable.setDataSource(new DistanceInfoDataSource(url, river, "locations"));
+
+        this.distancesTable.addRecordClickHandler(new RecordClickHandler() {
             @Override
-            public void onRecordClick(RecordClickEvent e) {
-                Record r = e.getRecord();
+            public void onRecordClick(final RecordClickEvent e) {
+                final Record r = e.getRecord();
 
-                String from = r.getAttribute("from");
-                String to   = r.getAttribute("to");
+                final String from = r.getAttribute("from");
+                final String to = r.getAttribute("to");
 
                 try {
-                    distancePanel.setFrom(Double.valueOf(from));
-                    distancePanel.setTo(Double.valueOf(to));
-                }
-                catch (NumberFormatException nfe) {
-                    SC.warn(MSG.wrongFormat());
+                    DistancePanel.this.distancePanel.setFrom(Double.valueOf(from));
+                    DistancePanel.this.distancePanel.setTo(Double.valueOf(to));
                 }
-            }
-        });
-
-        locationsTable.addRecordClickHandler(new RecordClickHandler() {
-            @Override
-            public void onRecordClick(RecordClickEvent e) {
-                Record  r = e.getRecord();
-                int field = e.getFieldNum();
-
-                try {
-                    String value = r.getAttribute("from");
-
-                    switch (field) {
-                    case 0:
-                        distancePanel.setFrom(Double.valueOf(value));
-                        break;
-                    case 1:
-                        distancePanel.setTo(Double.valueOf(value));
-                        break;
-                    }
-                }
-                catch (NumberFormatException nfe) {
-                    SC.warn(MSG.wrongFormat());
+                catch (final NumberFormatException nfe) {
+                    SC.warn(DistancePanel.this.MSG.wrongFormat());
                 }
             }
         });
 
-        tabs = new TabSet();
-        tabs.setWidth100();
-        tabs.setHeight100();
-
-        Tab locations = new Tab(MSG.locations());
-        Tab distances = new Tab(MSG.distance());
-
-        locations.setPane(locationsTable);
-        distances.setPane(distancesTable);
-
-        tabs.addTab(locations, 0);
-        tabs.addTab(distances, 1);
-
-        filterResultCount = new StaticTextItem(MSG.resultCount());
-        filterResultCount.setTitleAlign(Alignment.LEFT);
-        filterResultCount.setTitleStyle("color: #000");
+        this.locationsTable.addRecordClickHandler(new RecordClickHandler() {
+            @Override
+            public void onRecordClick(final RecordClickEvent e) {
+                final Record r = e.getRecord();
+                final int field = e.getFieldNum();
 
-        filterDescription = new TableFilter();
-        filterDescription.setHeight("30px");
-        filterDescription.addFilterHandler(this);
-
-        filterRange = new RangeTableFilter();
-        filterRange.setHeight("30px");
-        filterRange.addFilterHandler(this);
-        filterRange.setVisible(false);
+                try {
+                    final String value = r.getAttribute("from");
 
-        SelectItem filterCriteria = new SelectItem();
-        filterCriteria.setShowTitle(false);
-        filterCriteria.setWidth(100);
-        filterCriteria.addChangedHandler(new ChangedHandler() {
-            @Override
-            public void onChanged(ChangedEvent e) {
-                if(e.getValue().toString().equals("range")) {
-                    filterRange.setVisible(true);
-                    filterDescription.setVisible(false);
-                    filterDescription.clear();
+                    switch (field) {
+                    case 0:
+                        DistancePanel.this.distancePanel.setFrom(Double.valueOf(value));
+                        break;
+                    case 1:
+                        DistancePanel.this.distancePanel.setTo(Double.valueOf(value));
+                        break;
+                    }
                 }
-                else {
-                    filterRange.setVisible(false);
-                    filterRange.clear();
-                    filterDescription.setVisible(true);
+                catch (final NumberFormatException nfe) {
+                    SC.warn(DistancePanel.this.MSG.wrongFormat());
                 }
             }
         });
 
-        LinkedHashMap<String, String> filterMap =
-            new LinkedHashMap<String, String>();
-        filterMap.put("description", MSG.description());
-        filterMap.put("range", MSG.range());
-        filterCriteria.setValueMap(filterMap);
-        filterCriteria.setValue("description");
-
-        DynamicForm form = new DynamicForm();
-        form.setFields(filterCriteria);
-
-        DynamicForm form2 = new DynamicForm();
-        form2.setFields(filterResultCount);
+        this.tabs = new TabSet();
+        this.tabs.setWidth100();
+        this.tabs.setHeight100();
 
-        HLayout filterLayout = new HLayout();
-        filterLayout.addMember(form);
-        filterLayout.addMember(filterDescription);
-        filterLayout.addMember(filterRange);
-        filterLayout.setHeight(30);
-        tabs.addTabSelectedHandler(new TabSelectedHandler() {
+        final Tab locations = new Tab(this.MSG.locations());
+        final Tab distances = new Tab(this.MSG.distance());
+
+        locations.setPane(this.locationsTable);
+        distances.setPane(this.distancesTable);
+
+        this.tabs.addTab(locations, 0);
+        this.tabs.addTab(distances, 1);
+
+        this.filterResultCount = new StaticTextItem(this.MSG.resultCount());
+        this.filterResultCount.setTitleAlign(Alignment.LEFT);
+        this.filterResultCount.setTitleStyle("color: #000");
+
+        this.filterDescription = new TableFilter();
+        this.filterDescription.setHeight("30px");
+        this.filterDescription.addFilterHandler(this);
+
+        this.filterRange = new RangeTableFilter();
+        this.filterRange.setHeight("30px");
+        this.filterRange.addFilterHandler(this);
+        this.filterRange.setVisible(false);
+
+        final SelectItem filterCriteria = new SelectItem();
+        filterCriteria.setShowTitle(false);
+        filterCriteria.setWidth(100);
+        filterCriteria.addChangedHandler(new ChangedHandler() {
             @Override
-            public void onTabSelected(TabSelectedEvent evt) {
-                filterDescription.clear();
-                filterRange.clear();
-                filterResultCount.setValue("");
-
-                Canvas c = evt.getTabPane();
-                if(c instanceof ListGrid) {
-                    currentFiltered = (ListGrid)c;
+            public void onChanged(final ChangedEvent e) {
+                if (e.getValue().toString().equals("range")) {
+                    DistancePanel.this.filterRange.setVisible(true);
+                    DistancePanel.this.filterDescription.setVisible(false);
+                    DistancePanel.this.filterDescription.clear();
+                } else {
+                    DistancePanel.this.filterRange.setVisible(false);
+                    DistancePanel.this.filterRange.clear();
+                    DistancePanel.this.filterDescription.setVisible(true);
                 }
             }
         });
 
-        helperContainer.addMember(tabs);
-        helperContainer.addMember(filterLayout);
-        helperContainer.addMember(form2);
+        final LinkedHashMap<String, String> filterMap = new LinkedHashMap<String, String>();
+        filterMap.put("description", this.MSG.description());
+        filterMap.put("range", this.MSG.range());
+        filterCriteria.setValueMap(filterMap);
+        filterCriteria.setValue("description");
+
+        final DynamicForm form = new DynamicForm();
+        form.setFields(filterCriteria);
+
+        final DynamicForm form2 = new DynamicForm();
+        form2.setFields(this.filterResultCount);
+
+        final HLayout filterLayout = new HLayout();
+        filterLayout.addMember(form);
+        filterLayout.addMember(this.filterDescription);
+        filterLayout.addMember(this.filterRange);
+        filterLayout.setHeight(30);
+        this.tabs.addTabSelectedHandler(new TabSelectedHandler() {
+            @Override
+            public void onTabSelected(final TabSelectedEvent evt) {
+                DistancePanel.this.filterDescription.clear();
+                DistancePanel.this.filterRange.clear();
+                DistancePanel.this.filterResultCount.setValue("");
+
+                final Canvas c = evt.getTabPane();
+                if (c instanceof ListGrid) {
+                    DistancePanel.this.currentFiltered = (ListGrid) c;
+                }
+            }
+        });
+
+        this.helperContainer.addMember(this.tabs);
+        this.helperContainer.addMember(filterLayout);
+        this.helperContainer.addMember(form2);
     }
 
-
     @Override
-    public void onFilterCriteriaChanged(StringFilterEvent event) {
-        String search = event.getFilter();
+    public void onFilterCriteriaChanged(final StringFilterEvent event) {
+        final String search = event.getFilter();
 
         if (search != null && search.length() > 0) {
-            Criteria c = new Criteria("description", search);
-            locationsTable.filterData(c);
-            distancesTable.filterData(c);
-            filterResultCount.setValue(currentFiltered.getRecords().length);
-        }
-        else {
-            locationsTable.clearCriteria();
-            distancesTable.clearCriteria();
-            filterResultCount.setValue("");
+            final Criteria c = new Criteria("description", search);
+            this.locationsTable.filterData(c);
+            this.distancesTable.filterData(c);
+            this.filterResultCount.setValue(this.currentFiltered.getRecords().length);
+        } else {
+            this.locationsTable.clearCriteria();
+            this.distancesTable.clearCriteria();
+            this.filterResultCount.setValue("");
         }
     }
 
-
     @Override
-    public void onFilterCriteriaChanged(RangeFilterEvent event) {
-        Float from = event.getFrom() - 0.001f;
-        Float to = event.getTo() + 0.001f;
+    public void onFilterCriteriaChanged(final RangeFilterEvent event) {
+        final Float from = event.getFrom() - 0.001f;
+        final Float to = event.getTo() + 0.001f;
 
         Criterion combinedFilter = null;
         Criterion locationFilter = null;
 
         if (from.equals(Float.NaN) && to.equals(Float.NaN)) {
-            locationsTable.clearCriteria();
-            distancesTable.clearCriteria();
-            filterResultCount.setValue("");
+            this.locationsTable.clearCriteria();
+            this.distancesTable.clearCriteria();
+            this.filterResultCount.setValue("");
             return;
         }
 
         if (from.equals(Float.NaN)) {
-            combinedFilter =
-                new Criterion("to", OperatorId.LESS_OR_EQUAL, to);
+            combinedFilter = new Criterion("to", OperatorId.LESS_OR_EQUAL, to);
 
-            locationFilter =
-                new Criterion("from", OperatorId.LESS_OR_EQUAL, to);
+            locationFilter = new Criterion("from", OperatorId.LESS_OR_EQUAL, to);
 
-            locationsTable.filterData(locationFilter);
-            distancesTable.filterData(combinedFilter);
-            filterResultCount.setValue(currentFiltered.getRecords().length);
+            this.locationsTable.filterData(locationFilter);
+            this.distancesTable.filterData(combinedFilter);
+            this.filterResultCount.setValue(this.currentFiltered.getRecords().length);
             return;
         }
 
         if (to.equals(Float.NaN)) {
-            combinedFilter =
-                new Criterion("from", OperatorId.GREATER_OR_EQUAL, from);
-        }
-        else {
-            AdvancedCriteria c1 =
-                new AdvancedCriteria(OperatorId.AND, new Criterion[] {
-                    new Criterion("from", OperatorId.GREATER_OR_EQUAL, from),
-                    new Criterion("from", OperatorId.LESS_OR_EQUAL, to)
-                });
+            combinedFilter = new Criterion("from", OperatorId.GREATER_OR_EQUAL, from);
+        } else {
+            final AdvancedCriteria c1 = new AdvancedCriteria(OperatorId.AND,
+                    new Criterion[] { new Criterion("from", OperatorId.GREATER_OR_EQUAL, from), new Criterion("from", OperatorId.LESS_OR_EQUAL, to) });
 
-            AdvancedCriteria c2 =
-                new AdvancedCriteria(OperatorId.AND, new Criterion[] {
-                    new Criterion("to", OperatorId.GREATER_OR_EQUAL, from),
-                    new Criterion("to", OperatorId.LESS_OR_EQUAL, to)
-                });
+            final AdvancedCriteria c2 = new AdvancedCriteria(OperatorId.AND,
+                    new Criterion[] { new Criterion("to", OperatorId.GREATER_OR_EQUAL, from), new Criterion("to", OperatorId.LESS_OR_EQUAL, to) });
 
-            AdvancedCriteria c3 =
-                new AdvancedCriteria(OperatorId.AND, new Criterion[] {
-                    new Criterion("from", OperatorId.LESS_OR_EQUAL, to),
-                    new Criterion("to", OperatorId.GREATER_OR_EQUAL, from)
-                });
+            final AdvancedCriteria c3 = new AdvancedCriteria(OperatorId.AND,
+                    new Criterion[] { new Criterion("from", OperatorId.LESS_OR_EQUAL, to), new Criterion("to", OperatorId.GREATER_OR_EQUAL, from) });
 
-            combinedFilter =
-                new AdvancedCriteria(OperatorId.OR, new Criterion[] {
-                    c1, c2, c3
-                });
+            combinedFilter = new AdvancedCriteria(OperatorId.OR, new Criterion[] { c1, c2, c3 });
         }
-        locationsTable.filterData(combinedFilter);
-        distancesTable.filterData(combinedFilter);
-        filterResultCount.setValue(currentFiltered.getRecords().length);
+        this.locationsTable.filterData(combinedFilter);
+        this.distancesTable.filterData(combinedFilter);
+        this.filterResultCount.setValue(this.currentFiltered.getRecords().length);
 
     }
 
-
     protected String getRiverName() {
-        ArtifactDescription adescr = artifact.getArtifactDescription();
+        final ArtifactDescription adescr = this.artifact.getArtifactDescription();
         return adescr.getRiver();
     }
 }

http://dive4elements.wald.intevation.org