Mercurial > dive4elements > river
changeset 1534:98123d34529b
Added UI parts and event for filtering distances and locations.
flys-client/trunk@3749 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/flys-client/ChangeLog Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/ChangeLog Mon Jan 23 11:07:38 2012 +0000 @@ -1,3 +1,34 @@ +2012-01-23 Raimund Renkert <raimund.renkert@intevation.de> + + Added UI parts and event for filtering distances and locations. + + * src/main/java/de/intevation/flys/client/client/ui/RangeTableFilter.java: + New. Creates textitems for user input. + + * src/main/java/de/intevation/flys/client/client/event/RangeFilterEvent.java: + New. The range filter events contains the 'from' and 'to' value. + + * src/main/java/de/intevation/flys/client/client/event/FilterHandler.java: + Added new filter criteria changed method. + + * src/main/java/de/intevation/flys/client/client/ui/TableFilter.java: + Set the textitem width to a fix value. + + * 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 UI parts to Panels. + + * src/main/java/de/intevation/flys/client/client/ui/ProjectList.java: + Empty implementation for range filter event. The project list has no + ranges to filter. + + * src/main/java/de/intevation/flys/client/client/FLYSConstants.java, + src/main/java/de/intevation/flys/client/client/FLYSConstants.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties, + src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties: + Added i18n strings for new filter. + 2012-01-20 Raimund Renkert <raimund.renkert@intevation.de> Add cross sections loaded from datacage to the master artifacts list.
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.java Mon Jan 23 11:07:38 2012 +0000 @@ -210,8 +210,6 @@ String too_many_values (); - String description(); - String from(); String to(); @@ -306,6 +304,10 @@ String riverMap(); + String range(); + + String description(); + // Elevation window String ele_window_title();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants.properties Mon Jan 23 11:07:38 2012 +0000 @@ -75,6 +75,7 @@ label_cancel = Cancel cancelCalculationLabel = Stop the current calculation. calculationCanceled = The calculation has been canceled. +range = Range # Header images flysLogo = images/flys_logo.gif
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_de.properties Mon Jan 23 11:07:38 2012 +0000 @@ -75,6 +75,7 @@ label_cancel = Abbrechen cancelCalculationLabel = Aktuelle Berechnung abbrechen. calculationCanceled = Die Berechnung wurde abgebrochen. +range = Bereich # Header images flysLogo = images/flys_logo.gif
--- a/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/FLYSConstants_en.properties Mon Jan 23 11:07:38 2012 +0000 @@ -75,6 +75,7 @@ label_cancel = Cancel cancelCalculationLabel = Stop the current calculation. calculationCanceled = The calculation has been canceled. +range = Range # Header images flysLogo = images/flys_logo.gif
--- a/flys-client/src/main/java/de/intevation/flys/client/client/event/FilterHandler.java Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/event/FilterHandler.java Mon Jan 23 11:07:38 2012 +0000 @@ -7,5 +7,7 @@ public interface FilterHandler { void onFilterCriteriaChanged(StringFilterEvent event); + + void onFilterCriteriaChanged(RangeFilterEvent 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/RangeFilterEvent.java Mon Jan 23 11:07:38 2012 +0000 @@ -0,0 +1,27 @@ +package de.intevation.flys.client.client.event; + +/** + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class RangeFilterEvent { + + protected String from; + protected String to; + + + public RangeFilterEvent(String from, String to) { + this.from = from; + this.to = to; + } + + + public String getFrom() { + return String.valueOf(this.from); + } + + + public String getTo() { + return String.valueOf(this.to); + } +} +// 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 Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java Mon Jan 23 11:07:38 2012 +0000 @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.LinkedHashMap; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; @@ -11,6 +12,10 @@ import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.form.DynamicForm; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; @@ -36,6 +41,7 @@ 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; +import de.intevation.flys.client.client.event.RangeFilterEvent; public class DistancePanel extends AbstractUIProvider implements BlurHandler, FilterHandler @@ -55,7 +61,8 @@ protected DoubleRangePanel distancePanel; - protected TableFilter filter; + protected TableFilter filterDescription; + protected RangeTableFilter filterRange; protected TabSet tabs; @@ -478,18 +485,57 @@ tabs.addTab(locations, 0); tabs.addTab(distances, 1); - filter = new TableFilter(); - filter.setHeight("30px"); - filter.addFilterHandler(this); + filterDescription = new TableFilter(); + filterDescription.setHeight("30px"); + filterDescription.addFilterHandler(this); + + filterRange = new RangeTableFilter(); + filterRange.setHeight("30px"); + filterRange.addFilterHandler(this); + filterRange.setVisible(false); + + SelectItem filterCriteria = new SelectItem(); + filterCriteria.setShowTitle(false); + filterCriteria.setWidth(100); + filterCriteria.addChangedHandler(new ChangedHandler() { + public void onChanged(ChangedEvent e) { + if(e.getValue().toString().equals("range")) { + filterRange.setVisible(true); + filterDescription.setVisible(false); + filterDescription.clear(); + } + else { + filterRange.setVisible(false); + filterRange.clear(); + filterDescription.setVisible(true); + } + } + }); + + 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); + + HLayout filterLayout = new HLayout(); + filterLayout.addMember(form); + filterLayout.addMember(filterDescription); + filterLayout.addMember(filterRange); + tabs.addTabSelectedHandler(new TabSelectedHandler() { public void onTabSelected(TabSelectedEvent evt) { - filter.clear(); + filterDescription.clear(); } }); helperContainer.addMember(tabs); - helperContainer.addMember(filter); + helperContainer.addMember(filterLayout); } @@ -508,6 +554,11 @@ } + public void onFilterCriteriaChanged(RangeFilterEvent event) { + GWT.log("filter range"); + } + + protected String getRiverName() { ArtifactDescription adescr = artifact.getArtifactDescription(); DataList[] data = adescr.getOldData();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationDistancePanel.java Mon Jan 23 11:07:38 2012 +0000 @@ -15,7 +15,12 @@ import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.ChangeHandler; import com.smartgwt.client.widgets.form.fields.events.ChangeEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; + import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.TextItem; import com.smartgwt.client.widgets.form.fields.RadioGroupItem; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; @@ -51,6 +56,7 @@ 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.event.RangeFilterEvent; import de.intevation.flys.client.client.ui.range.DistanceInfoDataSource; @@ -137,7 +143,12 @@ protected DistanceInfoObject[] tableData; /** The table filter.*/ - protected TableFilter filter; + protected TableFilter filterDescription; + protected RangeTableFilter filterRange; + + /** The Combobox for table filter criteria. */ + protected SelectItem filterCriteria; + /** * Creates a new LocationDistancePanel instance. @@ -678,7 +689,7 @@ inputTables = new TabSet(); inputTables.addTabSelectedHandler(new TabSelectedHandler() { public void onTabSelected(TabSelectedEvent evt) { - filter.clear(); + filterDescription.clear(); } }); @@ -694,19 +705,59 @@ inputTables.addTab(locations); inputTables.addTab(distances); - filter = new TableFilter(); - filter.setHeight("30px"); - filter.addFilterHandler(this); + filterDescription = new TableFilter(); + filterDescription.setHeight("30px"); + filterDescription.addFilterHandler(this); + + filterRange = new RangeTableFilter(); + filterRange.setHeight("30px"); + filterRange.addFilterHandler(this); + filterRange.setVisible(false); + + filterCriteria = new SelectItem(); + filterCriteria.setShowTitle(false); + filterCriteria.setWidth(100); + filterCriteria.addChangedHandler(new ChangedHandler() { + public void onChanged(ChangedEvent e) { + if(e.getValue().toString().equals("range")) { + filterRange.setVisible(true); + filterDescription.setVisible(false); + filterDescription.clear(); + } + else { + filterRange.setVisible(false); + filterRange.clear(); + filterDescription.setVisible(true); + } + } + }); + + LinkedHashMap<String, String> filterMap = + new LinkedHashMap<String, String>(); + filterMap.put("description", MESSAGES.description()); + filterMap.put("range", MESSAGES.range()); + filterCriteria.setValueMap(filterMap); + filterCriteria.setValue("description"); + + DynamicForm form = new DynamicForm(); + form.setFields(filterCriteria); inputTables.setHeight("*"); VLayout helper = new VLayout(); + HLayout filterLayout = new HLayout(); + + filterLayout.addMember(form); + filterLayout.addMember(filterDescription); + filterLayout.addMember(filterRange); + filterLayout.setHeight("33px"); helper.addMember(inputTables); - helper.addMember(filter); + helper.addMember(filterLayout); helper.setHeight100(); helper.setWidth100(); helperContainer.addMember(helper); + filterLayout.setWidth("200"); return layout; } @@ -730,6 +781,9 @@ } + public void onFilterCriteriaChanged(RangeFilterEvent event) { + GWT.log("filtering range"); + } @Override @@ -1020,7 +1074,7 @@ } if (value.equals(FIELD_VALUE_LOCATION)) { enableLocationPanel(); - filter.clear(); + filterDescription.clear(); // Remove the tab containing the locationDistanceTable. // The 'updateTab()' avoids the tab content to be destroyed. inputTables.updateTab(0, null); @@ -1036,7 +1090,7 @@ } else { enableDistancePanel(); - filter.clear(); + filterDescription.clear(); // Remove the tab containing the locationTable. // The 'updateTab()' avoids the tab content to be destroyed. inputTables.updateTab(0, null);
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/ProjectList.java Mon Jan 23 11:07:38 2012 +0000 @@ -52,6 +52,7 @@ import de.intevation.flys.client.client.event.FilterHandler; import de.intevation.flys.client.client.event.StringFilterEvent; +import de.intevation.flys.client.client.event.RangeFilterEvent; import de.intevation.flys.client.client.Config; import de.intevation.flys.client.client.FLYS; @@ -387,6 +388,11 @@ } + public void onFilterCriteriaChanged(RangeFilterEvent event) { + //Empty. No Ranges to filter. + } + + public void onCollectionChange(CollectionChangeEvent event) { if (event.getOldValue() == null) { updateUserCollections();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/RangeTableFilter.java Mon Jan 23 11:07:38 2012 +0000 @@ -0,0 +1,119 @@ +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.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.KeyUpEvent; +import com.smartgwt.client.widgets.form.fields.events.KeyUpHandler; +import com.smartgwt.client.widgets.layout.HLayout; + +import de.intevation.flys.client.client.event.FilterHandler; +import de.intevation.flys.client.client.event.RangeFilterEvent; +import de.intevation.flys.client.client.FLYSConstants; + + +/** + * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a> + */ +public class RangeTableFilter +extends HLayout +implements ChangedHandler, KeyUpHandler +{ + /** The message class that provides i18n strings. */ + protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); + + protected List<FilterHandler> handlers; + + protected TextItem fromField; + protected TextItem toField; + + public RangeTableFilter() { + super(); + fromField = new TextItem(); + fromField.setTitle(MESSAGES.from()); + fromField.setWidth(60); + toField = new TextItem(); + toField.setTitle(MESSAGES.to()); + toField.setWidth(60); + + + handlers = new ArrayList<FilterHandler>(); + + fromField.addChangedHandler(this); + fromField.addKeyUpHandler(this); + toField.addChangedHandler(this); + toField.addKeyUpHandler(this); + + DynamicForm form = new DynamicForm(); + form.setNumCols(4); + form.setFields(fromField, toField); + + addMember(form); + } + + + public void onChanged(ChangedEvent event) { + // This event handler is to slow... +// fireFilterCriteriaChanged(getSearchString()); + } + + + public void onKeyUp(KeyUpEvent event) { + //To deactivate "As you type" filter add + // ' && event.getKeyName().equals("Enter")' + // to the if-clause. + if (event != null) { + fireFilterCriteriaChanged(getFrom(), getTo()); + } + } + + + public String getFrom() { + if (fromField.getValueAsString() == null) { + return ""; + } + else { + return fromField.getValueAsString(); + } + } + + + public String getTo() { + if (toField.getValueAsString() == null) { + return ""; + } + else { + return toField.getValueAsString(); + } + } + + + public void addFilterHandler(FilterHandler handler) { + if (handler != null) { + handlers.add(handler); + } + } + + + protected void fireFilterCriteriaChanged(String from, String to) { + RangeFilterEvent filter = new RangeFilterEvent(from, to); + + for (FilterHandler handler: handlers) { + handler.onFilterCriteriaChanged(filter); + } + } + + + public void clear() { + fromField.clearValue(); + toField.clearValue(); + fireFilterCriteriaChanged("", ""); + } +} +// 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/SingleLocationPanel.java Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Mon Jan 23 11:07:38 2012 +0000 @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.LinkedHashMap; import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; @@ -9,9 +10,14 @@ import com.smartgwt.client.util.SC; import com.smartgwt.client.widgets.Canvas; import com.smartgwt.client.widgets.Label; +import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.FormItem; +import com.smartgwt.client.widgets.form.fields.SelectItem; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; + import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; import com.smartgwt.client.widgets.grid.ListGrid; @@ -41,6 +47,7 @@ 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; +import de.intevation.flys.client.client.event.RangeFilterEvent; /** @@ -304,12 +311,50 @@ container.setMembersMargin(30); - TableFilter filter = new TableFilter(); + final TableFilter filter = new TableFilter(); filter.setHeight("30px"); filter.addFilterHandler(this); + final RangeTableFilter filterRange = new RangeTableFilter(); + filterRange.setHeight("30px"); + filterRange.addFilterHandler(this); + filterRange.setVisible(false); + + SelectItem filterCriteria = new SelectItem(); + filterCriteria.setShowTitle(false); + filterCriteria.setWidth(100); + filterCriteria.addChangedHandler(new ChangedHandler() { + public void onChanged(ChangedEvent e) { + if(e.getValue().toString().equals("range")) { + filterRange.setVisible(true); + filter.setVisible(false); + filter.clear(); + } + else { + filterRange.setVisible(false); + filterRange.clear(); + filter.setVisible(true); + } + } + }); + + LinkedHashMap<String, String> filterMap = + new LinkedHashMap<String, String>(); + filterMap.put("description", MESSAGES.description()); + filterMap.put("range", MESSAGES.range()); + filterCriteria.setValueMap(filterMap); + filterCriteria.setValue("description"); + + DynamicForm form = new DynamicForm(); + form.setFields(filterCriteria); + + HLayout filterLayout = new HLayout(); + filterLayout.addMember(form); + filterLayout.addMember(filter); + filterLayout.addMember(filterRange); + helperContainer.addMember(locationTable); - helperContainer.addMember(filter); + helperContainer.addMember(filterLayout); createInputPanel(); return layout; } @@ -326,6 +371,12 @@ } } + + public void onFilterCriteriaChanged(RangeFilterEvent event) { + GWT.log("filter range"); + } + + @Override public List<String> validate() { List<String> errors = new ArrayList<String>();
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableFilter.java Fri Jan 20 15:47:14 2012 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/TableFilter.java Mon Jan 23 11:07:38 2012 +0000 @@ -40,6 +40,7 @@ searchfield.addChangedHandler(this); searchfield.addKeyUpHandler(this); + searchfield.setWidth(120); DynamicForm form = new DynamicForm(); form.setFields(searchfield);