Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java @ 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 | dfbc6693247e |
children | d08cf5ed1bfc |
line wrap: on
line diff
--- 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")); }