# HG changeset patch # User Raimund Renkert # Date 1350991040 -7200 # Node ID 480de0dbca8eb9da93c50f7c3b41a873e4fcc489 # Parent a30647abf009c51a74f1873f54d81854ece2d024 Extended location input helper. The locationpicker has now an attribute whether the input is distance or location to display one or two clickable columns. Replaced the record click handler with cell click handler. diff -r a30647abf009 -r 480de0dbca8e flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationPicker.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationPicker.java Tue Oct 23 09:53:02 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/LocationPicker.java Tue Oct 23 13:17:20 2012 +0200 @@ -4,32 +4,28 @@ 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; -import com.smartgwt.client.data.AdvancedCriteria; +import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.types.OperatorId; - import com.smartgwt.client.widgets.form.DynamicForm; -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.SelectItem; import com.smartgwt.client.widgets.form.fields.StaticTextItem; -import com.smartgwt.client.widgets.layout.HLayout; +import com.smartgwt.client.widgets.form.fields.events.ChangedEvent; +import com.smartgwt.client.widgets.form.fields.events.ChangedHandler; +import com.smartgwt.client.widgets.grid.CellFormatter; import com.smartgwt.client.widgets.grid.ListGrid; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; -import com.smartgwt.client.widgets.grid.CellFormatter; -import com.smartgwt.client.widgets.grid.events.RecordClickHandler; - -import com.smartgwt.client.types.ListGridFieldType; -import com.smartgwt.client.types.Alignment; +import com.smartgwt.client.widgets.grid.events.CellClickHandler; +import com.smartgwt.client.widgets.layout.HLayout; import de.intevation.flys.client.client.FLYSConstants; import de.intevation.flys.client.client.event.FilterHandler; +import de.intevation.flys.client.client.event.RangeFilterEvent; import de.intevation.flys.client.client.event.StringFilterEvent; -import de.intevation.flys.client.client.event.RangeFilterEvent; /** * Bundle widgets and handler for a lacation input helper. @@ -50,13 +46,15 @@ DynamicForm resultCountForm; - RecordClickHandler handler; + CellClickHandler handler; + + boolean isDistance = false; /** Text to show number of matched items when filtered. */ protected StaticTextItem filterResultCount; - public LocationPicker(RecordClickHandler handler) { + public LocationPicker(CellClickHandler handler) { locationTable = new ListGrid(); locationTable.setShowHeaderContextMenu(false); this.handler = handler; @@ -138,7 +136,7 @@ /** * This method creates a table that contains the location values. */ - protected void createLocationTable(/*RecordClickHandler handler*/) { + public void createLocationTable(/*RecordClickHandler handler*/) { GWT.log("Create Location Table in LocationPicker"); String baseUrl = GWT.getHostPageBaseURL(); @@ -153,10 +151,12 @@ ListGridField addLocation = new ListGridField ("", ""); addLocation.setType (ListGridFieldType.ICON); addLocation.setWidth (20); - addLocation.addRecordClickHandler (handler); addLocation.setCellIcon (baseUrl + MSG.markerGreen()); - GWT.log ("i18n: ..... " + MSG.description()); - + ListGridField addTo = new ListGridField ("", ""); + addTo.setType (ListGridFieldType.ICON); + addTo.setWidth (20); + addTo.setCellIcon (baseUrl + MSG.markerRed()); + ListGridField ldescr = new ListGridField("description", MSG.description()); ldescr.setType(ListGridFieldType.TEXT); @@ -198,10 +198,15 @@ new ListGridField("top", MSG.top_edge()); top.setType(ListGridFieldType.TEXT); top.setWidth("10%"); - - - locationTable.setFields( - addLocation, ldescr, loc, lside, bottom, top); + locationTable.addCellClickHandler(handler); + if (isDistance) { + locationTable.setFields( + addLocation, addTo, ldescr, loc, lside, bottom, top); + } + else { + locationTable.setFields( + addLocation, ldescr, loc, lside, bottom, top); + } } @@ -250,5 +255,13 @@ locationTable.filterData(combinedFilter); filterResultCount.setValue(locationTable.getRecords().length); } + + public void setIsDistance(boolean value) { + this.isDistance = value; + } + + public boolean isDistance() { + return this.isDistance; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r a30647abf009 -r 480de0dbca8e flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java Tue Oct 23 09:53:02 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/MultipleLocationPanel.java Tue Oct 23 13:17:20 2012 +0200 @@ -9,8 +9,8 @@ import com.smartgwt.client.widgets.Label; import com.smartgwt.client.widgets.form.fields.events.BlurEvent; import com.smartgwt.client.widgets.form.fields.events.BlurHandler; -import com.smartgwt.client.widgets.grid.events.RecordClickEvent; -import com.smartgwt.client.widgets.grid.events.RecordClickHandler; +import com.smartgwt.client.widgets.grid.events.CellClickEvent; +import com.smartgwt.client.widgets.grid.events.CellClickHandler; import com.smartgwt.client.widgets.layout.HLayout; import com.smartgwt.client.widgets.layout.VLayout; @@ -37,7 +37,7 @@ */ public class MultipleLocationPanel extends LocationPanel -implements RecordClickHandler +implements CellClickHandler { private static final long serialVersionUID = -3359966826794082718L; @@ -317,7 +317,7 @@ * @param e event passed. */ @Override - public void onRecordClick (RecordClickEvent e) { + public void onCellClick (CellClickEvent e) { Record record = e.getRecord(); double[] old = getLocationValues(); double[] selected = DoubleUtils.copyOf(old, old.length + 1); diff -r a30647abf009 -r 480de0dbca8e flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java --- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Tue Oct 23 09:53:02 2012 +0200 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java Tue Oct 23 13:17:20 2012 +0200 @@ -3,7 +3,8 @@ import com.google.gwt.i18n.client.NumberFormat; import com.smartgwt.client.data.Record; -import com.smartgwt.client.widgets.grid.events.RecordClickEvent; + +import com.smartgwt.client.widgets.grid.events.CellClickEvent; import de.intevation.flys.client.shared.model.Data; @@ -105,7 +106,7 @@ * @param e event passed. */ @Override - public void onRecordClick (RecordClickEvent e) { + public void onCellClick (CellClickEvent e) { Record record = e.getRecord(); double[] selected = new double[1]; try {