# HG changeset patch
# User gernotbelger
# Date 1527599943 -7200
# Node ID 41f4bc83aa7aa90c411026e2c5385fe1c1d0ddbb
# Parent ffd4e2b0381c205c0ed5b58d886b8aad58b54aab
vegzones improved
diff -r ffd4e2b0381c -r 41f4bc83aa7a artifacts/doc/conf/artifacts/uinfo.xml
--- a/artifacts/doc/conf/artifacts/uinfo.xml Tue May 29 11:38:13 2018 +0200
+++ b/artifacts/doc/conf/artifacts/uinfo.xml Tue May 29 15:19:03 2018 +0200
@@ -248,13 +248,13 @@
-
+
-
+
diff -r ffd4e2b0381c -r 41f4bc83aa7a artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/AbstractUInfoExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/AbstractUInfoExporter.java Tue May 29 11:38:13 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/commons/AbstractUInfoExporter.java Tue May 29 15:19:03 2018 +0200
@@ -92,9 +92,6 @@
// "# Gewässer: "
writeCSVMetaEntry(writer, I18NStrings.CSV_META_RIVER, msg(I18NStrings.CSV_META_RIVER_LABEL), river.getName());
- // "# Höhensystem des Flusses: "
- writeCSVMetaEntry(writer, I18NStrings.CSV_META_HEIGHT_UNIT_RIVER, river.getWstUnit()); // move to child?
-
if (calcRange != null) {
// "# Ort/Bereich (km): "
writeCSVMetaEntry(writer, I18NStrings.CSV_META_RANGE, msg(I18NStrings.CSV_META_RANGE_LABEL), getKmFormatter().format(calcRange.getMinimumDouble()),
diff -r ffd4e2b0381c -r 41f4bc83aa7a artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationExporter.java Tue May 29 11:38:13 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/InundationDurationExporter.java Tue May 29 15:19:03 2018 +0200
@@ -15,6 +15,7 @@
import org.apache.log4j.Logger;
import org.dive4elements.river.artifacts.common.GeneralResultType;
+import org.dive4elements.river.artifacts.common.I18NStrings;
import org.dive4elements.river.artifacts.common.JasperReporter;
import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
import org.dive4elements.river.artifacts.common.ResultRow;
@@ -46,6 +47,10 @@
log.info("SalixLineExporter.writeCSVMeta");
super.writeCSVGlobalMetadataDefaults(writer, results);
+
+ // "# Höhensystem des Flusses: "
+ writeCSVMetaEntry(writer, I18NStrings.CSV_META_HEIGHT_UNIT_RIVER, results.getRiver().getWstUnit());
+
writer.writeNext(new String[] { "" }); // break line
}
diff -r ffd4e2b0381c -r 41f4bc83aa7a artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java Tue May 29 11:38:13 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/salix/SalixLineExporter.java Tue May 29 15:19:03 2018 +0200
@@ -15,6 +15,7 @@
import org.apache.log4j.Logger;
import org.dive4elements.river.artifacts.common.GeneralResultType;
+import org.dive4elements.river.artifacts.common.I18NStrings;
import org.dive4elements.river.artifacts.common.JasperReporter;
import org.dive4elements.river.artifacts.common.MetaAndTableJRDataSource;
import org.dive4elements.river.artifacts.common.ResultRow;
@@ -47,6 +48,9 @@
super.writeCSVGlobalMetadataDefaults(writer, results);
+ // "# Höhensystem des Flusses: "
+ writeCSVMetaEntry(writer, I18NStrings.CSV_META_HEIGHT_UNIT_RIVER, results.getRiver().getWstUnit());
+
// Add Auswerter, Bezugspegel, Jahr/Zeitraum der Wasserspiegellage
// "# Auswerter: "
diff -r ffd4e2b0381c -r 41f4bc83aa7a artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java Tue May 29 11:38:13 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/vegetationzones/VegetationZonesCalculation.java Tue May 29 15:19:03 2018 +0200
@@ -15,7 +15,7 @@
import org.apache.commons.lang.math.DoubleRange;
import org.dive4elements.artifacts.CallContext;
-import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.access.RangeAccess;
import org.dive4elements.river.artifacts.common.ResultRow;
import org.dive4elements.river.artifacts.model.Calculation;
import org.dive4elements.river.artifacts.model.CalculationResult;
@@ -45,9 +45,9 @@
final String user = CalculationUtils.findArtifactUser(this.context, uinfo);
// FIXME: remove, check other states as well
- final RiverAccess access = new RiverAccess(uinfo);
+ final RangeAccess access = new RangeAccess(uinfo);
final River river = access.getRiver();
- final DoubleRange calcRange = null;
+ final DoubleRange calcRange = access.getRange();
final RiverInfo riverInfo = new RiverInfo(river);
final VegetationzonesAccess vAccess = new VegetationzonesAccess(uinfo);
diff -r ffd4e2b0381c -r 41f4bc83aa7a gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Tue May 29 11:38:13 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java Tue May 29 15:19:03 2018 +0200
@@ -1517,4 +1517,11 @@
String bundu();
+ String uinfo_vegetation_zones_validation_empty();
+
+ String uinfo_vegetation_zones_validation_range();
+
+ String uinfo_vegetation_zones_validation_from_greater_to();
+
+ String uinfo_vegetation_zones_invalid_integer();
}
\ No newline at end of file
diff -r ffd4e2b0381c -r 41f4bc83aa7a gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Tue May 29 11:38:13 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Tue May 29 15:19:03 2018 +0200
@@ -810,5 +810,9 @@
uinfo_vegetation_zones_label = Vegetationszonen
uinfo_vegetation_zones_from = \u00dcfd von [d/a]
uinfo_vegetation_zones_to = \u00dcfd bis [d/a]
+uinfo_vegetation_zones_validation_empty = Eingabefeld leer.
+uinfo_vegetation_zones_validation_range = Werte m\u00fcssen zwischen 0 und 365 liegen.
+uinfo_vegetation_zones_validation_from_greater_to = Der Wert f\u00fcr "\u00dcfd von" muss kleiner als "\u00dcfd bis".
+uinfo_vegetation_zones_invalid_integer = Nur Ganzzahlen erlaubt.
bundu = Betrieb und Unterhaltung
\ No newline at end of file
diff -r ffd4e2b0381c -r 41f4bc83aa7a gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Tue May 29 11:38:13 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Tue May 29 15:19:03 2018 +0200
@@ -810,5 +810,9 @@
uinfo_vegetation_zones_label = Vegetationszonen
uinfo_vegetation_zones_from = \u00dcfd von [d/a]
uinfo_vegetation_zones_to = \u00dcfd bis [d/a]
+uinfo_vegetation_zones_validation_empty = Eingabefeld leer.
+uinfo_vegetation_zones_validation_range = Werte m\u00fcssen zwischen 0 und 365 liegen.
+uinfo_vegetation_zones_validation_from_greater_to = Der Wert f\u00fcr "\u00dcfd von" muss kleiner als "\u00dcfd bis".
+uinfo_vegetation_zones_invalid_integer = Nur Ganzzahlen erlaubt.
bundu = Betrieb und Unterhaltung
\ No newline at end of file
diff -r ffd4e2b0381c -r 41f4bc83aa7a gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java Tue May 29 11:38:13 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java Tue May 29 15:19:03 2018 +0200
@@ -9,6 +9,7 @@
*/
package org.dive4elements.river.client.client.ui;
+import com.smartgwt.client.widgets.form.fields.IntegerItem;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
import com.smartgwt.client.widgets.form.validator.Validator;
@@ -32,6 +33,14 @@
return item;
}
+ public static final IntegerItem createIntegerItem(final String identifier, final String title, final int width, final Validator... validator) {
+ final IntegerItem item = new IntegerItem(identifier, title);
+ item.setWidth(width);
+ item.setWrapTitle(false);
+ item.setValidators(validator);
+ return item;
+ }
+
public static VLayout getSpacer(final int height) {
final VLayout spacer = new VLayout();
spacer.setHeight(height);
diff -r ffd4e2b0381c -r 41f4bc83aa7a gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java Tue May 29 11:38:13 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/AbstractVegZonesTablePanel.java Tue May 29 15:19:03 2018 +0200
@@ -20,15 +20,20 @@
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.smartgwt.client.data.Record;
import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.Label;
-import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.validator.IntegerRangeValidator;
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.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.Layout;
import com.smartgwt.client.widgets.layout.VLayout;
/**
@@ -37,26 +42,18 @@
*/
public abstract class AbstractVegZonesTablePanel extends AbstractUIProvider {
private static final long serialVersionUID = 1L;
- public static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
- public static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";
-
- protected static final String datakey = "vegzones";
- protected final ListGrid elements = new ListGrid();
- protected TextItem vegzone;
- protected TextItem start;
- protected TextItem end;
- private ListGrid table;
+ private static final String TABLE_CELL_SEPARATOR = "TABLE_CELL_SEPARATOR";
- protected ListGridField vegzoneField;// = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label());
- protected ListGridField fromField;// = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from());
- protected ListGridField toField;// = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to());
+ private static final String TABLE_ROW_SEPARATOR = "TABLE_ROW_SEPARATOR";
- final protected VLayout root = new VLayout();
- final protected HLayout input = new HLayout();
- final protected VLayout tableLayout = new VLayout();
+ private static final String datakey = "vegzones";
- protected final void createTable(final DataList data, final int width) {
+ private final ListGrid elements = new ListGrid();
+
+ // private final HLayout input = new HLayout();
+
+ protected final ListGrid createTable(final Layout root, final DataList data, final int width, final boolean editable) {
data.add(VegetationzonesTablePanel.getDummyData()); // TODO: GET REAL DATA!
final Label title = new Label(data.get(0).getDescription());
@@ -67,85 +64,75 @@
this.elements.setShowHeaderContextMenu(false);
this.elements.setCanReorderFields(false);
this.elements.setCanSort(false);
- this.elements.setCanEdit(false);
- this.vegzoneField = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label());
- this.fromField = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from());
- this.toField = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to());
- this.vegzoneField.setWidth(245);
- this.fromField.setWidth(80);
- this.toField.setWidth(80);
- this.fromField.setAlign(Alignment.RIGHT);
- this.toField.setAlign(Alignment.RIGHT);
+ this.elements.setCanEdit(editable);
+
+ final ListGridField vegzoneField = new ListGridField("vegzone", this.MSG.uinfo_vegetation_zones_label());
+ vegzoneField.setType(ListGridFieldType.TEXT);
+ vegzoneField.setWidth(245);
+
+ final ListGridField fromField = new ListGridField("from", this.MSG.uinfo_vegetation_zones_from());
+ fromField.setType(ListGridFieldType.INTEGER);
+ final IntegerRangeValidator validator = new IntegerRangeValidator();
+ validator.setMin(0);
+ validator.setMax(365);
+
+ fromField.setValidators(validator);
+ fromField.setWidth(80);
+ fromField.setAlign(Alignment.RIGHT);
+
+ final ListGridField toField = new ListGridField("to", this.MSG.uinfo_vegetation_zones_to());
+ toField.setType(ListGridFieldType.INTEGER);
+ toField.setValidators(validator);
+ toField.setWidth(80);
+ toField.setAlign(Alignment.RIGHT);
+
+ if (editable) {
+ final ListGridField removeField = createRemoveField();
+ this.elements.setFields(vegzoneField, fromField, toField, removeField);
+
+ } else {
+ this.elements.setFields(vegzoneField, fromField, toField);
+ }
addDataInit(data);
- this.root.addMember(title);
- this.tableLayout.addMember(this.elements);
- this.root.addMember(this.input);
- this.root.addMember(this.tableLayout);
- this.root.addMember(PanelHelper.getSpacer(10));
+ root.addMember(title);
+ root.addMember(this.elements);
+ root.addMember(PanelHelper.getSpacer(10));
+ return this.elements;
}
- protected final Canvas createHelper() {
- this.table = new ListGrid();
- this.table.setShowHeaderContextMenu(false);
- this.table.setWidth100();
- this.table.setShowRecordComponents(true);
- this.table.setShowRecordComponentsByCell(true);
- this.table.setHeight100();
- this.table.setEmptyMessage(this.MSG.empty_table());
- this.table.setCanReorderFields(false);
+ private ListGridField createRemoveField() {
- /* Input support pins */
- // final String baseUrl = GWT.getHostPageBaseURL();
- // final ListGridField pinFrom = new ListGridField("fromIcon", this.MSG.uinfo_vegetation_zones_from());
- // pinFrom.setWidth(300);
- // pinFrom.setType(ListGridFieldType.ICON);
- // pinFrom.setCellIcon(baseUrl + this.MSG.markerGreen());
- //
- // final ListGridField pinTo = new ListGridField("toIcon", this.MSG.uinfo_vegetation_zones_to());
- // pinTo.setType(ListGridFieldType.ICON);
- // pinTo.setWidth(300);
- // pinTo.setCellIcon(baseUrl + this.MSG.markerRed());
- //
- // pinFrom.addRecordClickHandler(new RecordClickHandler() {
- // @Override
- // public void onRecordClick(final RecordClickEvent e) {
- // final Record r = e.getRecord();
- // VegetationzonesTableEditPanel.this.vegzone.setValue(r.getAttribute("date")); // date??
- // }
- // });
- //
- // pinFrom.addRecordClickHandler(new RecordClickHandler() {
- // @Override
- // public void onRecordClick(final RecordClickEvent e) {
- // final Record r = e.getRecord();
- // VegetationzonesTableEditPanel.this.start.setValue(r.getAttribute("date"));
- // }
- // });
- //
- // pinTo.addRecordClickHandler(new RecordClickHandler() {
- // @Override
- // public void onRecordClick(final RecordClickEvent e) {
- // final Record r = e.getRecord();
- // VegetationzonesTableEditPanel.this.end.setValue(r.getAttribute("date"));
- // }
- // });
- //
- // final ListGridField date = new ListGridField("date", this.MSG.year());
- // date.setType(ListGridFieldType.TEXT);
- // date.setWidth(100);
- //
- // final ListGridField descr = new ListGridField("description", this.MSG.description());
- // descr.setType(ListGridFieldType.TEXT);
- // descr.setWidth("*");
- //
- // this.table.setFields(pinFrom, pinTo, date, descr);
- return this.table;
+ final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") {
+ {
+ setType(ListGridFieldType.ICON);
+ setIcon(GWT.getHostPageBaseURL() + AbstractVegZonesTablePanel.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());
+ }
+ });
+
+ return removeField;
}
- public abstract Canvas createWidget(final DataList data);
+ public abstract void createWidget(final Layout root, final DataList data);
private final void addDataInit(final DataList data) {
for (final Data dataItemContainer : data.getAll()) {
@@ -166,16 +153,17 @@
@Override
public final Canvas create(final DataList data) {
final VLayout layout = new VLayout();
- final Canvas helper = createHelper();
- this.helperContainer.addMember(helper);
+
+ // final Canvas helper = createHelper();
+ // this.helperContainer.addMember(helper);
final Canvas submit = getNextButton();
- final Canvas widget = createWidget(data);
- layout.addMember(widget);
- layout.addMember(submit); // TODO: SUBMIT
+ final VLayout root = new VLayout();
+ createWidget(root, data);
- // fetchSedimentLoadData(); //TODO: feed from database...
+ layout.addMember(root);
+ layout.addMember(submit);
return layout;
}
@@ -194,9 +182,9 @@
final Data str = getData(items, datakey);
final DataItem[] strItems = str.getItems();
- final String[] entries = strItems[0].getLabel().split(VegetationzonesTablePanel.TABLE_ROW_SEPARATOR);
+ final String[] entries = strItems[0].getLabel().split(AbstractVegZonesTablePanel.TABLE_ROW_SEPARATOR);
for (final String entry : entries) {
- final String[] vals = entry.split(VegetationzonesTablePanel.TABLE_CELL_SEPARATOR);
+ final String[] vals = entry.split(AbstractVegZonesTablePanel.TABLE_CELL_SEPARATOR);
final Label dateLabel = new Label(vals[0] + " (" + vals[1] + "-" + vals[2] + ")");
dateLabel.setHeight(20);
vLayout.addMember(dateLabel);
@@ -239,9 +227,9 @@
String d = "";
for (final ListGridRecord element : lgr) {
final Record r = element;
- d += r.getAttribute("vegzone") + VegetationzonesTablePanel.TABLE_CELL_SEPARATOR + r.getAttribute("from")
- + VegetationzonesTablePanel.TABLE_CELL_SEPARATOR + r.getAttribute("to");
- d += VegetationzonesTablePanel.TABLE_ROW_SEPARATOR;
+ d += r.getAttribute("vegzone") + AbstractVegZonesTablePanel.TABLE_CELL_SEPARATOR + r.getAttribute("from")
+ + AbstractVegZonesTablePanel.TABLE_CELL_SEPARATOR + r.getAttribute("to");
+ d += AbstractVegZonesTablePanel.TABLE_ROW_SEPARATOR;
}
final DataItem item = new DefaultDataItem(datakey, null, d); // DATA-key
@@ -274,5 +262,4 @@
}
return null;
}
-
-}
+}
\ No newline at end of file
diff -r ffd4e2b0381c -r 41f4bc83aa7a gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java Tue May 29 11:38:13 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java Tue May 29 15:19:03 2018 +0200
@@ -11,30 +11,34 @@
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.util.SC;
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.form.fields.TextItem;
+import com.smartgwt.client.widgets.grid.ListGrid;
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;
+import com.smartgwt.client.widgets.layout.Layout;
public class VegetationzonesTableEditPanel extends AbstractVegZonesTablePanel {
private static final long serialVersionUID = 1L;
+ private TextItem vegzone;
+
+ private TextItem start;
+
+ private TextItem end;
+
@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());
+ public void createWidget(final Layout root, final DataList data) {
+
+ final ListGrid elements = super.createTable(root, data, 450, true);
+
+ this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), 200);
+ this.start = PanelHelper.createIntegerItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), 40);
+ this.end = PanelHelper.createIntegerItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), 40);
final HLayout fields = new HLayout();
final HLayout fields2 = new HLayout();
@@ -53,16 +57,9 @@
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();
+ final String message = validate(v1, v2, v3);
+ if (message != null) {
+ SC.warn(message);
return;
}
@@ -70,46 +67,42 @@
r.setAttribute("vegzone", v3);
r.setAttribute("from", v1);
r.setAttribute("to", v2);
- VegetationzonesTableEditPanel.this.elements.addData(r);
+ 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;
+ root.addMember(fields);
+ root.addMember(fields2);
+ root.addMember(PanelHelper.getSpacer(10));
+ root.addMember(add);
+ root.addMember(PanelHelper.getSpacer(20));
}
-}
+ protected String validate(final String v1, final String v2, final String v3) {
+
+ if (v1 == null || v2 == null || v3 == null || v1.trim().isEmpty() || v2.trim().isEmpty() || v3.trim().isEmpty())
+ return this.MSG.uinfo_vegetation_zones_validation_empty();
+
+ try {
+ final Integer from = Integer.valueOf(v1);
+ final Integer to = Integer.valueOf(v2);
+
+ if (from < 0 || from > 365)
+ return this.MSG.uinfo_vegetation_zones_validation_range();
+
+ if (to < 0 || to > 365)
+ return this.MSG.uinfo_vegetation_zones_validation_range();
+
+ if (from > to)
+ return this.MSG.uinfo_vegetation_zones_validation_from_greater_to();
+
+ return null;
+ }
+ catch (final NumberFormatException e) {
+ return this.MSG.uinfo_vegetation_zones_invalid_integer();
+ }
+ }
+}
\ No newline at end of file
diff -r ffd4e2b0381c -r 41f4bc83aa7a gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java Tue May 29 11:38:13 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTablePanel.java Tue May 29 15:19:03 2018 +0200
@@ -10,17 +10,17 @@
import org.dive4elements.river.client.shared.model.DataList;
-import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.layout.Layout;
public class VegetationzonesTablePanel extends AbstractVegZonesTablePanel {
private static final long serialVersionUID = 1L;
@Override
- public Canvas createWidget(final DataList data) {
+ public void createWidget(final Layout root, final DataList data) {
- createTable(data, 420);
- this.elements.setFields(this.vegzoneField, this.fromField, this.toField);
- return this.root;
+ createTable(root, data, 420, false);
+
+ // fetchSedimentLoadData(); //TODO: feed from database...
}
}