Mercurial > dive4elements > river
view gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java @ 9102:21e65960a9e3
fix-analysis distance range bugfix
author | gernotbelger |
---|---|
date | Mon, 28 May 2018 18:18:21 +0200 |
parents | 611a523fc42f |
children | 41f4bc83aa7a |
line wrap: on
line source
/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde * Software engineering by Intevation GmbH * * This file is Free Software under the GNU AGPL (>=v3) * and comes with ABSOLUTELY NO WARRANTY! Check out the * documentation coming with Dive4Elements River for details. */ package org.dive4elements.river.client.client.ui.uinfo; import org.dive4elements.river.client.client.ui.PanelHelper; import org.dive4elements.river.client.shared.model.DataList; import com.google.gwt.core.client.GWT; import com.smartgwt.client.types.ListGridFieldType; import com.smartgwt.client.widgets.Button; import com.smartgwt.client.widgets.Canvas; 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.validator.IsIntegerValidator; import com.smartgwt.client.widgets.form.validator.IsStringValidator; import com.smartgwt.client.widgets.grid.ListGridField; import com.smartgwt.client.widgets.grid.ListGridRecord; import com.smartgwt.client.widgets.grid.events.RecordClickEvent; import com.smartgwt.client.widgets.grid.events.RecordClickHandler; import com.smartgwt.client.widgets.layout.HLayout; public class VegetationzonesTableEditPanel extends AbstractVegZonesTablePanel { private static final long serialVersionUID = 1L; @Override public Canvas createWidget(final DataList data) { super.createTable(data, 450); this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), 200, new IsStringValidator()); this.start = PanelHelper.createItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), 40, new IsIntegerValidator()); this.end = PanelHelper.createItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), 40, new IsIntegerValidator()); final HLayout fields = new HLayout(); final HLayout fields2 = new HLayout(); final Button add = new Button(this.MSG.add_date()); // TODO: make key more generic or change to more specific final DynamicForm form1 = new DynamicForm(); final DynamicForm form2 = new DynamicForm(); form2.setNumCols(5); form1.setNumCols(7); form1.setFields(this.vegzone); form2.setFields(this.start, this.end); add.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent ce) { final String v1 = VegetationzonesTableEditPanel.this.start.getValueAsString(); final String v2 = VegetationzonesTableEditPanel.this.end.getValueAsString(); final String v3 = VegetationzonesTableEditPanel.this.vegzone.getValueAsString(); if (v1 == null || v2 == null || v3 == null) { return; } try { final double test = Double.valueOf(v1); final double test2 = Double.valueOf(v2); // TODO: MAKE MESSAGE, Apply Format (1.000,00) } catch (final Exception e) { e.printStackTrace(); return; } final ListGridRecord r = new ListGridRecord(); r.setAttribute("vegzone", v3); r.setAttribute("from", v1); r.setAttribute("to", v2); VegetationzonesTableEditPanel.this.elements.addData(r); } }); final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") { { setType(ListGridFieldType.ICON); setIcon(GWT.getHostPageBaseURL() + VegetationzonesTableEditPanel.this.MSG.removeFeature()); setCanEdit(false); setCanFilter(false); setCanSort(false); setCanGroupBy(false); setCanFreeze(false); setWidth(25); } }; this.elements.addRecordClickHandler(new RecordClickHandler() { @Override public void onRecordClick(final RecordClickEvent event) { // Just handle remove-clicks if (!event.getField().getName().equals(removeField.getName())) { return; } event.getViewer().removeData(event.getRecord()); } }); this.elements.setFields(super.vegzoneField, super.fromField, super.toField, removeField); fields.addMember(form1); fields2.addMember(form2); this.root.addMember(fields); this.root.addMember(fields2); this.root.addMember(PanelHelper.getSpacer(10)); this.root.addMember(add); this.root.addMember(PanelHelper.getSpacer(20)); return this.root; } }