[PATCH] epoch-panels, single-input-panels

Wald Commits scm-commit at wald.intevation.org
Wed May 23 17:30:33 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1527089424 -7200
# Node ID aafae1ab25f04e36271b3405d93f200fb3e8d5c6
# Parent  fc02833dbcc13c6507d50f224cecf9598e92eaca
epoch-panels, single-input-panels

diff -r fc02833dbcc1 -r aafae1ab25f0 artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/LoadEpochSelect.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/LoadEpochSelect.java	Tue May 22 17:44:05 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/uinfo/inundationduration/LoadEpochSelect.java	Wed May 23 17:30:24 2018 +0200
@@ -8,8 +8,21 @@
 
 package org.dive4elements.river.artifacts.uinfo.inundationduration;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 import org.apache.log4j.Logger;
+import org.dive4elements.artifacts.Artifact;
+import org.dive4elements.artifacts.CallContext;
+import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator;
+import org.dive4elements.river.artifacts.D4EArtifact;
+import org.dive4elements.river.artifacts.access.RiverAccess;
+import org.dive4elements.river.artifacts.model.CollisionHibernateFactory;
+import org.dive4elements.river.artifacts.states.AddTableDataHelper;
 import org.dive4elements.river.artifacts.states.DefaultState;
+import org.dive4elements.river.model.sinfo.Collision;
+import org.w3c.dom.Element;
 
 public class LoadEpochSelect extends DefaultState {
     /** The log used in this class. */
@@ -25,4 +38,37 @@
     protected String getUIProvider() {
         return "uinfo.inundationduration.load_totalepoch_select";
     }
+
+    @Override
+    protected void appendItems(final Artifact artifact, final ElementCreator creator, final String name, final CallContext context, final Element select) {
+        final String dataKey = "totalepoch";
+        try {
+            if (dataKey.equals(name)) {
+
+                final AddTableDataHelper helper = new AddTableDataHelper(creator, select, "year", context.getMeta()); // pinKeycolum; nicht zu verweschseln mit
+                                                                                                                      // datakey..artifact.
+
+                // helper.addColumn(0, "pinfrom", "60", "common.client.ui.selection", "ICON", "CENTER", "from");
+                helper.addColumn(0, "year", "60", "year", "INTEGER", "LEFT", null); // Keine Pins
+
+                final RiverAccess access = new RiverAccess((D4EArtifact) artifact);
+                final List<Collision> collisions = CollisionHibernateFactory.getCollisionsByRiver(access.getRiver());// TODO: DATASOURCE?! Has to be
+                                                                                                                     // uinfo.inundation_duration
+                // (Überflutungsdauern Aue) irgendwas...
+
+                for (final Collision coll : collisions) {
+                    final Integer year = coll.getYear();
+                    final Map<String, String> row = new HashMap<>();
+                    row.put("year", year.toString()); // Nullpointer?
+                    helper.addRow(row);
+
+                }
+                helper.submitMapToXml();
+            }
+        }
+        catch (final IllegalArgumentException iae) {
+            iae.printStackTrace();
+        }
+    }
+
 }
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractEpochPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractEpochPanel.java	Wed May 23 17:30:24 2018 +0200
@@ -0,0 +1,262 @@
+/** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
+ * Software engineering by
+ *  Björnsen Beratende Ingenieure GmbH
+ *  Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
+ *
+ * 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;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.TreeSet;
+
+import org.dive4elements.river.client.client.ui.FromToTableHelperPanel.IColumnClickHandler;
+import org.dive4elements.river.client.shared.model.Data;
+import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.DefaultData;
+import org.dive4elements.river.client.shared.model.DefaultDataItem;
+
+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.grid.ListGrid;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.layout.HLayout;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public abstract class AbstractEpochPanel extends AbstractUIProvider {
+
+    private static final long serialVersionUID = 1L;
+
+    protected enum Type {
+        singleMinMax, multi
+        // Type singleMinMax: nur eine Epoche kann gesetzt werden; minMax vorbelegt aus Datenquelle
+        // Type multi: mehrere epochs können eingegeben werden
+    }
+
+    private TextItem start;
+
+    private TextItem end;
+
+    private ListGrid elements;
+
+    private List<String> validInputs = new ArrayList<String>();
+
+    private final Type type;
+
+    public AbstractEpochPanel(final Type type) {
+        this.type = type;
+    }
+
+    protected abstract String getDatakey();
+
+    protected abstract Canvas createWidget(final DataList data);
+
+    private final void postCreate() {
+        switch (this.type) {
+        case singleMinMax:
+            final TreeSet<String> minMax = new TreeSet<String>(this.validInputs);
+            if (minMax.size() > 1) {
+                this.start.setValue(minMax.first());
+                this.end.setValue(minMax.last());
+            } else {
+                // TODO: THIS STATE IS INVALID; RETURN - es gibt keinen Mechanismus, der das verhindert; müsste
+                // im State davor passieren)
+            }
+            break;
+        case multi:
+            break; // do nothing
+        default:
+            throw new IllegalStateException();
+        }
+    }
+
+    protected final TextItem createStartInputItem(final String title) {
+        this.start = PanelHelper.createItem(title);
+        return this.start;
+    }
+
+    protected final TextItem createEndInputItem(final String title) {
+        this.end = PanelHelper.createItem(title);
+        return this.end;
+    }
+
+    protected final ListGrid createListGrid() {
+        this.elements = new ListGrid();
+        this.elements.setShowHeaderContextMenu(false);
+        this.elements.setCanReorderFields(false);
+        this.elements.setCanSort(false);
+        this.elements.setCanEdit(false);
+        return this.elements;
+    }
+
+    @Override
+    public final Canvas createOld(final DataList dataList) {
+        final HLayout layout = new HLayout();
+        layout.setWidth("400px");
+        final VLayout vLayout = new VLayout();
+        vLayout.setWidth(130);
+        final Label label = new Label(dataList.getLabel());
+        label.setWidth("200px");
+        label.setHeight(25);
+
+        final List<Data> items = dataList.getAll();
+        final Data str = getData(items, getDatakey());
+        final DataItem[] strItems = str.getItems();
+
+        final String[] pairs = strItems[0].getLabel().split(";");
+        for (final String pair : pairs) {
+            final Label dateLabel = new Label(pair.replace(",", " - "));
+            dateLabel.setHeight(20);
+            vLayout.addMember(dateLabel);
+        }
+        final Canvas back = getBackButton(dataList.getState());
+        layout.addMember(label);
+        layout.addMember(vLayout);
+        layout.addMember(back);
+
+        return layout;
+    }
+
+    @Override
+    public final Canvas create(final DataList data) {
+        final VLayout layout = new VLayout();
+        final Canvas submit = getNextButton();
+        final Canvas widget = createWidget(data);
+
+        layout.addMember(widget);
+        layout.addMember(submit);
+
+        final IColumnClickHandler fromHandler = createHandler(this.start);
+        final IColumnClickHandler toHandler = createHandler(this.end);
+
+        final FromToTableHelperPanel helper = new FromToTableHelperPanel(data, getDatakey(), this.MSG, fromHandler, toHandler);
+        this.validInputs = helper.getKeycolEntries();
+        final Canvas table = helper.getTable();
+
+        this.helperContainer.addMember(table);
+
+        postCreate();
+        return layout;
+    }
+
+    private final IColumnClickHandler createHandler(final TextItem field) {
+        final IColumnClickHandler handler = new IColumnClickHandler() {
+
+            @Override
+            public void columnClicked(final String value) {
+                field.setValue(value);
+            }
+        };
+        return handler;
+    }
+
+    /*
+     * Validate the epoch input. We do this here and not in an overridden
+     * validate method as we want to validate before an epoch is added
+     * to the list of epochs.
+     */
+    protected final boolean isValidEpoch(final String y1, final String y2) {
+        // First check that both are integer
+        // int iY1;
+        // int iY2;
+        final List<String> errors = new ArrayList<String>();
+        try {
+            // iY1 =
+            Integer.parseInt(y1);
+        }
+        catch (final NumberFormatException e) {
+            errors.add(this.MSG.wrongFormat() + ": " + y1);
+        }
+        try {
+            // iY2 =
+            Integer.parseInt(y2);
+        }
+        catch (final NumberFormatException e) {
+            errors.add(this.MSG.wrongFormat() + ": " + y2);
+        }
+        if (!errors.isEmpty()) {
+            showErrors(errors);
+            return false;
+        }
+        boolean startIsGood = false;
+        boolean endIsGood = false;
+        for (final String validYear : this.validInputs) {
+            if (startIsGood || y1.equals(validYear)) {
+                startIsGood = true;
+            }
+            if (endIsGood || y2.equals(validYear)) {
+                endIsGood = true;
+            }
+            if (startIsGood && endIsGood) {
+                break;
+            }
+            /*
+             * alternative check if data lies in between
+             * int aYear = Integer.parseInt(validYear);
+             * if (aYear >= iY1 && aYear <= iY2) {
+             * isGood = true;
+             * break;
+             * }
+             */
+        }
+        if (!startIsGood) {
+            String tmp = this.MSG.no_data_for_year();
+            tmp = tmp.replace("$1", y1);
+            errors.add(tmp);
+        }
+        if (!endIsGood) {
+            String tmp = this.MSG.no_data_for_year();
+            tmp = tmp.replace("$1", y2);
+            errors.add(tmp);
+        }
+        if (!errors.isEmpty()) {
+            showErrors(errors);
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    protected final Data[] getData() {
+        final List<Data> data = new ArrayList<Data>();
+        switch (this.type) {
+
+        case singleMinMax:
+            data.add(buildResult(this.start.getValueAsString(), this.end.getValueAsString()));
+
+            break;
+        case multi:
+            final ListGridRecord[] lgr = this.elements.getRecords();
+            if (lgr.length == 0) {
+                return new Data[0];
+            }
+            for (final ListGridRecord element : lgr) {
+                data.add(buildResult(element.getAttribute("from"), element.getAttribute("to")));
+            }
+            break;
+        default:
+            throw new IllegalStateException();
+        }
+        return data.toArray(new Data[data.size()]);
+    }
+
+    private final Data buildResult(final String startStr, final String endStr) {
+        final StringBuilder builder = new StringBuilder();
+        builder.append(startStr);
+        builder.append(",");
+        builder.append(endStr);
+        builder.append(";");
+        final DataItem item = new DefaultDataItem(getDatakey(), null, builder.toString());
+        return new DefaultData(getDatakey(), null, null, new DataItem[] { item });
+    }
+
+}
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractSingleItemPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractSingleItemPanel.java	Tue May 22 17:44:05 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractSingleItemPanel.java	Wed May 23 17:30:24 2018 +0200
@@ -21,10 +21,7 @@
 
 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.TextItem;
-import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
-import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
@@ -34,24 +31,30 @@
  */
 public abstract class AbstractSingleItemPanel extends AbstractUIProvider {
 
-    protected static final String FORM_ID = "FORM_ID";
+    private static final long serialVersionUID = 1L;
 
-    protected TextItem inputItem;
+    protected enum Type {
+        single, multi // "SingleItem" (Klassenname) meint, dass es nur ein einziges Eingabefeld gibt (nicht from-to; epoch)
+        // Type multi: append (year): es können mehrere Werte eingegeben werden; Leerzeichen-getrennt
+        // Type single: append (year, sohlhöhendifferenz): nur ein Wert ist zulässig
+    }
 
-    protected List<String> validInputs = new ArrayList<String>();
+    private final Type type;
 
-    protected ListGrid table;
+    private TextItem inputItem;
+
+    private List<String> validInputs = new ArrayList<String>();
 
     protected abstract String getDatakey();
 
-    protected abstract void appendValue(final String value);
+    protected abstract Canvas createWidget(final DataList data);
 
-    protected abstract boolean getTitleVisible();
-
-    protected abstract String errorForItemMsg();
+    public AbstractSingleItemPanel(final Type type) {
+        this.type = type;
+    }
 
     @Override
-    public Canvas create(final DataList data) {
+    public final Canvas create(final DataList data) {
         final VLayout layout = new VLayout();
         final IColumnClickHandler fromHandler = new IColumnClickHandler() { // add to external class
 
@@ -76,28 +79,8 @@
         return layout;
     }
 
-    public Canvas createWidget(final DataList data) {
-        final VLayout layout = new VLayout();
-
-        final Label title = new Label(data.get(0).getDescription());
-        title.setHeight("25px");
-
-        final DynamicForm form = new DynamicForm();
-        form.setID(FORM_ID);
-        form.setNumCols(4);
-        this.inputItem = new TextItem(this.MSG.years());
-        this.inputItem.setShowTitle(getTitleVisible());
-        this.inputItem.setValidators(new IsIntegerValidator()); // TODO: validator to be overriden...
-        form.setFields(this.inputItem);
-
-        layout.addMember(title);
-        layout.addMember(form);
-
-        return layout;
-    }
-
     @Override
-    public Canvas createOld(final DataList dataList) {
+    public final Canvas createOld(final DataList dataList) {
         final List<Data> items = dataList.getAll();
         final Data years = getData(items, getDatakey());
         final DataItem[] yearsItems = years.getItems();
@@ -121,20 +104,45 @@
     }
 
     @Override
-    public List<String> validate() {
+    protected final Data[] getData() {
+        final List<String> errors = this.validate();
+        if (errors.size() > 0) {
+            showErrors(errors); // TODO: do not allow advance state
+            // return null;
+        }
+        if (this.inputItem != null && !this.inputItem.getValueAsString().isEmpty()) {
+            final List<Data> data = new ArrayList<Data>();
+
+            final DataItem yearsdata = new DefaultDataItem(getDatakey(), getDatakey(), this.inputItem.getValueAsString().trim());
+            data.add(new DefaultData(getDatakey(), null, null, new DataItem[] { yearsdata }));
+
+            return data.toArray(new Data[data.size()]);
+        }
+        return new Data[0];
+    }
+
+    protected final TextItem createInputItem(final String title) {
+        this.inputItem = PanelHelper.createItem(title);// new TextItem(title);
+        return this.inputItem;
+    }
+
+    private final List<String> checkForEmpty() {
         final List<String> errors = new ArrayList<String>();
 
         if (this.inputItem.getValueAsString() == null || this.inputItem.getValueAsString().trim().isEmpty()) {
             errors.add(this.MSG.empty_filter());
             return errors;
         }
-        final String sValue = this.inputItem.getValueAsString();
-        String filtered = "";
-        int goodValues = 0;
+        return errors;
+    }
 
-        int value = 0;
+    private final List<String> validateSingleInput(final String sValue) {
+        final List<String> errors = new ArrayList<String>();
+        // String filtered = "";
+        // int goodValues = 0;
+
         try {
-            value = Integer.parseInt(sValue);
+            Integer.parseInt(sValue);
         }
         catch (final NumberFormatException e) {
             errors.add(this.MSG.wrongFormat() + ": " + sValue);
@@ -154,32 +162,63 @@
             errors.add(tmp);
             // continue;
         }
-        goodValues++;
-        if (goodValues > 1) {
-            filtered += " " + Integer.toString(value);
-        } else {
-            filtered = Integer.toString(value);
+        // goodValues++;
+        // if (goodValues > 1) {
+        // filtered += " " + Integer.toString(value);
+        // } else {
+        // filtered = Integer.toString(value);
+        // }
+        return errors;
+    }
+
+    protected abstract String errorForItemMsg();
+
+    protected final void appendValue(final String value) {
+
+        switch (this.type) {
+        case multi:
+            // APPEND = ADD to existing -> MULTI YEAR
+            final String oldYears = this.inputItem.getValueAsString();
+            if (oldYears != null && !oldYears.isEmpty())
+                this.inputItem.setValue(oldYears.trim() + " " + value);
+            else
+                this.inputItem.setValue(value);
+
+            break;
+
+        case single:
+            this.inputItem.setValue(value);
+            break;
+
+        default:
+            throw new IllegalStateException();
+        }
+    }
+
+    @Override
+    public final List<String> validate() {
+
+        final List<String> errors = new ArrayList<String>();
+        errors.addAll(this.checkForEmpty());
+
+        final String sValue = this.inputItem.getValueAsString();
+
+        switch (this.type) {
+        case multi:
+            final String[] sValues = sValue.trim().split(" ");
+            for (final String value : sValues) {
+                errors.addAll(this.validateSingleInput(value));
+            }
+            break;
+
+        case single:
+            errors.addAll(this.validateSingleInput(sValue));
+            break;
+
+        default:
+            throw new IllegalStateException();
         }
 
         return errors;
     }
-
-    @Override
-    protected Data[] getData() {
-        final List<String> errors = this.validate();
-        if (errors.size() > 0) {
-            showErrors(errors); // TODO: do not allow advance state
-            // return null;
-        }
-        if (this.inputItem != null && !this.inputItem.getValueAsString().isEmpty()) {
-            final List<Data> data = new ArrayList<Data>();
-
-            final DataItem yearsdata = new DefaultDataItem(getDatakey(), getDatakey(), this.inputItem.getValueAsString().trim());
-            data.add(new DefaultData(getDatakey(), null, null, new DataItem[] { yearsdata }));
-
-            return data.toArray(new Data[data.size()]);
-        }
-        return new Data[0];
-    }
-
-}
+}
\ No newline at end of file
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractUIProvider.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractUIProvider.java	Tue May 22 17:44:05 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractUIProvider.java	Wed May 23 17:30:24 2018 +0200
@@ -138,13 +138,12 @@
     @Override
     public void onClick(final ClickEvent e) {
         final List<String> errors = validate();
-        // if (errors == null || errors.isEmpty()) {
-        final Data[] data = getData();
-        fireStepForwardEvent(new StepForwardEvent(data));
-        // }
-        // else {
-        // showErrors(errors);
-        // }
+        if (errors == null || errors.isEmpty()) {
+            final Data[] data = getData();
+            fireStepForwardEvent(new StepForwardEvent(data));
+        } else {
+            showErrors(errors);
+        }
     }
 
     protected void showErrors(final List<String> errors) {
diff -r fc02833dbcc1 -r aafae1ab25f0 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 22 17:44:05 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/PanelHelper.java	Wed May 23 17:30:24 2018 +0200
@@ -10,6 +10,7 @@
 package org.dive4elements.river.client.client.ui;
 
 import com.smartgwt.client.widgets.form.fields.TextItem;
+import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
 import com.smartgwt.client.widgets.form.validator.Validator;
 import com.smartgwt.client.widgets.layout.VLayout;
 
@@ -36,4 +37,21 @@
         spacer.setHeight(height);
         return spacer;
     }
+
+    public static TextItem createItem(final String title) {
+        final TextItem inputItem = new TextItem(title);
+
+        final boolean hideTitle = title == null || title.isEmpty();
+        inputItem.setShowTitle(!hideTitle);
+        // final CustomValidator validator = new CustomValidator() {
+        // @Override
+        // protected boolean condition(final Object value) {
+        // return validate().size() > 0 ? false : true;
+        // }
+        // };
+        inputItem.setValidators(new IsIntegerValidator()); // Validator hat keinen sichtbaren Effekt.
+        inputItem.setWidth(60);
+        return inputItem;
+
+    }
 }
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Tue May 22 17:44:05 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Wed May 23 17:30:24 2018 +0200
@@ -27,9 +27,8 @@
 import org.dive4elements.river.client.client.ui.sinfo.FlowDepthMinMaxTwinPanel;
 import org.dive4elements.river.client.client.ui.sinfo.FlowDepthTwinPanel;
 import org.dive4elements.river.client.client.ui.sq.SQPeriodPanel;
-import org.dive4elements.river.client.client.ui.uinfo.InundationDurLoadEpochPanel;
 import org.dive4elements.river.client.client.ui.uinfo.LoadSedimentHeightPanel;
-import org.dive4elements.river.client.client.ui.uinfo.LoadSingleEpochPanel;
+import org.dive4elements.river.client.client.ui.uinfo.LoadSingleEpochMinMaxPanel;
 import org.dive4elements.river.client.client.ui.uinfo.LoadSingleYearPanel;
 import org.dive4elements.river.client.client.ui.uinfo.VegetationzonesTableEditPanel;
 import org.dive4elements.river.client.client.ui.uinfo.VegetationzonesTablePanel;
@@ -159,12 +158,10 @@
             return new CollisionLoadYearPanel();
         } else if (uiProvider.equals("sinfo.collision.load_epoch_select")) {
             return new CollisionLoadEpochPanel();
-        } else if (uiProvider.equals("uinfo.inundation_duration.load_epoch_select")) {
-            return new InundationDurLoadEpochPanel();
         } else if (uiProvider.equals("common.state.load_single_year_select")) {
             return new LoadSingleYearPanel();
         } else if (uiProvider.equals("uinfo.inundationduration.load_totalepoch_select")) {
-            return new LoadSingleEpochPanel();
+            return new LoadSingleEpochMinMaxPanel();
         } else if (uiProvider.equals("minfo.sedimentload_sqti_select")) {
             return new SedLoadSQTiPanel();
         } else if (uiProvider.equals("uinfo.sedimentheight_select")) {
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/CollisionLoadEpochPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/CollisionLoadEpochPanel.java	Tue May 22 17:44:05 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/CollisionLoadEpochPanel.java	Wed May 23 17:30:24 2018 +0200
@@ -8,22 +8,10 @@
 
 package org.dive4elements.river.client.client.ui.sinfo;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.dive4elements.river.client.client.services.SedimentLoadInfoService;
-import org.dive4elements.river.client.client.services.SedimentLoadInfoServiceAsync;
-import org.dive4elements.river.client.client.ui.AbstractUIProvider;
-import org.dive4elements.river.client.client.ui.FromToTableHelperPanel;
-import org.dive4elements.river.client.client.ui.FromToTableHelperPanel.IColumnClickHandler;
-import org.dive4elements.river.client.shared.model.Data;
-import org.dive4elements.river.client.shared.model.DataItem;
+import org.dive4elements.river.client.client.ui.AbstractEpochPanel;
 import org.dive4elements.river.client.shared.model.DataList;
-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.ListGridFieldType;
 import com.smartgwt.client.widgets.Button;
 import com.smartgwt.client.widgets.Canvas;
@@ -32,7 +20,6 @@
 import com.smartgwt.client.widgets.events.ClickHandler;
 import com.smartgwt.client.widgets.form.DynamicForm;
 import com.smartgwt.client.widgets.form.fields.TextItem;
-import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
 import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridField;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -41,45 +28,44 @@
 import com.smartgwt.client.widgets.layout.HLayout;
 import com.smartgwt.client.widgets.layout.VLayout;
 
-// FIXME: copy of SedLoadEpochPanel
-public class CollisionLoadEpochPanel extends AbstractUIProvider {
-    protected SedimentLoadInfoServiceAsync sedLoadInfoService = GWT.create(SedimentLoadInfoService.class);
+public class CollisionLoadEpochPanel extends AbstractEpochPanel {
 
-    protected ListGrid elements;
-    private TextItem start;
-    private TextItem end;
+    private static final long serialVersionUID = 1L;
 
-    private final String getDatakey() {
+    @Override
+    protected String getDatakey() {
         return "epochs";
     }
 
-    protected List<String> validYears = new ArrayList<String>();
+    public CollisionLoadEpochPanel() {
+        super(Type.multi);
+    }
 
-    public Canvas createWidget(final DataList data) {
+    @Override
+    protected Canvas createWidget(final DataList data) {
         final HLayout input = new HLayout();
         final VLayout root = new VLayout();
         final VLayout grid = new VLayout();
         final VLayout intFields = new VLayout();
         final Button add = new Button(this.MSG.add_date());
-        this.elements = new ListGrid();
+        final ListGrid elements = createListGrid();
+        elements.setWidth(185);
+        elements.setHeight(120);
 
         final Label title = new Label(data.get(0).getDescription());
         title.setHeight("25px");
 
         final DynamicForm form = new DynamicForm();
         form.setNumCols(4);
-        this.start = new TextItem(this.MSG.from());
-        this.start.setWidth(60);
-        this.start.setValidators(new IsIntegerValidator());
-        this.end = new TextItem(this.MSG.to());
-        this.end.setWidth(60);
-        this.end.setValidators(new IsIntegerValidator());
-        form.setFields(this.start, this.end);
+        final TextItem start = createStartInputItem(this.MSG.from());
+        final TextItem end = createEndInputItem(this.MSG.to());
+
+        form.setFields(start, end);
         add.addClickHandler(new ClickHandler() {
             @Override
             public void onClick(final ClickEvent ce) {
-                final String v1 = CollisionLoadEpochPanel.this.start.getValueAsString();
-                final String v2 = CollisionLoadEpochPanel.this.end.getValueAsString();
+                final String v1 = start.getValueAsString();
+                final String v2 = end.getValueAsString();
                 if (v1 == null || v2 == null) {
                     return;
                 }
@@ -89,18 +75,13 @@
                 final ListGridRecord r = new ListGridRecord();
                 r.setAttribute("from", v1);
                 r.setAttribute("to", v2);
-                CollisionLoadEpochPanel.this.elements.addData(r);
+                elements.addData(r);
             }
         });
 
         final Label sel = new Label(this.MSG.select());
         sel.setHeight(25);
-        this.elements.setWidth(185);
-        this.elements.setHeight(120);
-        this.elements.setShowHeaderContextMenu(false);
-        this.elements.setCanReorderFields(false);
-        this.elements.setCanSort(false);
-        this.elements.setCanEdit(false);
+
         final ListGridField from = new ListGridField("from", this.MSG.from());
         final ListGridField to = new ListGridField("to", this.MSG.to());
         from.setWidth(70);
@@ -119,7 +100,7 @@
             }
         };
 
-        this.elements.addRecordClickHandler(new RecordClickHandler() {
+        elements.addRecordClickHandler(new RecordClickHandler() {
             @Override
             public void onRecordClick(final RecordClickEvent event) {
                 // Just handle remove-clicks
@@ -130,12 +111,12 @@
             }
         });
 
-        this.elements.setFields(from, to, removeField);
+        elements.setFields(from, to, removeField);
 
         intFields.addMember(form);
         intFields.addMember(add);
         grid.addMember(sel);
-        grid.addMember(this.elements);
+        grid.addMember(elements);
         input.addMember(intFields);
         input.addMember(grid);
         root.addMember(title);
@@ -144,148 +125,4 @@
         return root;
     }
 
-    @Override
-    public Canvas createOld(final DataList dataList) {
-        final HLayout layout = new HLayout();
-        layout.setWidth("400px");
-        final VLayout vLayout = new VLayout();
-        vLayout.setWidth(130);
-        final Label label = new Label(dataList.getLabel());
-        label.setWidth("200px");
-        label.setHeight(25);
-
-        final List<Data> items = dataList.getAll();
-        final Data str = getData(items, getDatakey());
-        final DataItem[] strItems = str.getItems();
-
-        final String[] pairs = strItems[0].getLabel().split(";");
-        for (final String pair : pairs) {
-            final String[] vals = pair.split(",");
-            final Label dateLabel = new Label(vals[0] + " - " + vals[1]);
-            dateLabel.setHeight(20);
-            vLayout.addMember(dateLabel);
-        }
-        final Canvas back = getBackButton(dataList.getState());
-        layout.addMember(label);
-        layout.addMember(vLayout);
-        layout.addMember(back);
-
-        return layout;
-    }
-
-    @Override
-    public Canvas create(final DataList data) {
-        final VLayout layout = new VLayout();
-        final Canvas submit = getNextButton();
-        final Canvas widget = createWidget(data);
-
-        layout.addMember(widget);
-        layout.addMember(submit);
-
-        final IColumnClickHandler fromHandler = createHandler(this.start);
-        final IColumnClickHandler toHandler = createHandler(this.end);
-
-        final FromToTableHelperPanel helper = new FromToTableHelperPanel(data, getDatakey(), this.MSG, fromHandler, toHandler);
-        this.validYears = helper.getKeycolEntries();
-        final Canvas table = helper.getTable();
-
-        this.helperContainer.addMember(table);
-        return layout;
-    }
-
-    private IColumnClickHandler createHandler(final TextItem field) {
-        final IColumnClickHandler handler = new IColumnClickHandler() {
-
-            @Override
-            public void columnClicked(final String value) {
-                field.setValue(value);
-            }
-        };
-
-        return handler;
-    }
-
-    @Override
-    protected Data[] getData() {
-        final List<Data> data = new ArrayList<Data>();
-
-        final ListGridRecord[] lgr = this.elements.getRecords();
-        if (lgr.length == 0) {
-            return new Data[0];
-        }
-        String d = "";
-        for (final ListGridRecord element : lgr) {
-            final Record r = element;
-            d += r.getAttribute("from") + "," + r.getAttribute("to");
-            d += ";";
-        }
-
-        final DataItem item = new DefaultDataItem(getDatakey(), null, d);
-        data.add(new DefaultData(getDatakey(), null, null, new DataItem[] { item }));
-        return data.toArray(new Data[data.size()]);
-    }
-
-    /*
-     * Validate the epoch input. We do this here and not in an overridden
-     * validate method as we want to validate before an epoch is added
-     * to the list of epochs.
-     */
-    protected boolean isValidEpoch(final String y1, final String y2) {
-        // First check that both are integer
-        int iY1;
-        int iY2;
-        final List<String> errors = new ArrayList<String>();
-        try {
-            iY1 = Integer.parseInt(y1);
-        }
-        catch (final NumberFormatException e) {
-            errors.add(this.MSG.wrongFormat() + ": " + y1);
-        }
-        try {
-            iY2 = Integer.parseInt(y2);
-        }
-        catch (final NumberFormatException e) {
-            errors.add(this.MSG.wrongFormat() + ": " + y2);
-        }
-        if (!errors.isEmpty()) {
-            showErrors(errors);
-            return false;
-        }
-        boolean startIsGood = false;
-        boolean endIsGood = false;
-        for (final String validYear : this.validYears) {
-            if (startIsGood || y1.equals(validYear)) {
-                startIsGood = true;
-            }
-            if (endIsGood || y2.equals(validYear)) {
-                endIsGood = true;
-            }
-            if (startIsGood && endIsGood) {
-                break;
-            }
-            /*
-             * alternative check if data lies in between
-             * int aYear = Integer.parseInt(validYear);
-             * if (aYear >= iY1 && aYear <= iY2) {
-             * isGood = true;
-             * break;
-             * }
-             */
-        }
-        if (!startIsGood) {
-            String tmp = this.MSG.no_data_for_year();
-            tmp = tmp.replace("$1", y1);
-            errors.add(tmp);
-        }
-        if (!endIsGood) {
-            String tmp = this.MSG.no_data_for_year();
-            tmp = tmp.replace("$1", y2);
-            errors.add(tmp);
-        }
-        if (!errors.isEmpty()) {
-            showErrors(errors);
-            return false;
-        }
-        return true;
-    }
 }
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/CollisionLoadYearPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/CollisionLoadYearPanel.java	Tue May 22 17:44:05 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/CollisionLoadYearPanel.java	Wed May 23 17:30:24 2018 +0200
@@ -9,34 +9,49 @@
 package org.dive4elements.river.client.client.ui.sinfo;
 
 import org.dive4elements.river.client.client.ui.AbstractSingleItemPanel;
+import org.dive4elements.river.client.shared.model.DataList;
+
+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.TextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
 
 public class CollisionLoadYearPanel extends AbstractSingleItemPanel {
 
+    private static final long serialVersionUID = 1L;
+
+    public CollisionLoadYearPanel() {
+        super(Type.multi);
+    }
+
     @Override
     protected String getDatakey() {
         return "years"; // MULTIPLE; get From server (sinfo.xml data for state)
     }
 
-    public CollisionLoadYearPanel() {
-    }
+    @Override
+    public Canvas createWidget(final DataList data) {
+        final VLayout layout = new VLayout();
 
-    @Override
-    protected final void appendValue(final String value) { // APPEND = ADD to existing -> MULTI YEAR
-        final String oldYears = super.inputItem.getValueAsString();
-        if (oldYears != null && !oldYears.isEmpty()) {
-            super.inputItem.setValue(oldYears.trim() + " " + value);
-        } else {
-            super.inputItem.setValue(value);
-        }
-    }
+        final Label title = new Label(data.get(0).getDescription());
+        title.setHeight("25px");
 
-    @Override
-    protected boolean getTitleVisible() {
-        return true;
+        final DynamicForm form = new DynamicForm();
+        form.setNumCols(4);
+
+        final TextItem inputItem = createInputItem(this.MSG.years());
+        inputItem.setWidth(100);
+        form.setFields(inputItem);
+
+        layout.addMember(title);
+        layout.addMember(form);
+
+        return layout;
     }
 
     @Override
     protected String errorForItemMsg() {
         return this.MSG.no_data_for_year();
     }
-}
+}
\ No newline at end of file
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/InundationDurLoadEpochPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/InundationDurLoadEpochPanel.java	Tue May 22 17:44:05 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,383 +0,0 @@
-/* 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 java.util.ArrayList;
-import java.util.List;
-
-import org.dive4elements.river.client.client.Config;
-import org.dive4elements.river.client.client.FLYSConstants;
-import org.dive4elements.river.client.client.services.SedimentLoadInfoService;
-import org.dive4elements.river.client.client.services.SedimentLoadInfoServiceAsync;
-import org.dive4elements.river.client.client.ui.AbstractUIProvider;
-import org.dive4elements.river.client.shared.model.ArtifactDescription;
-import org.dive4elements.river.client.shared.model.Data;
-import org.dive4elements.river.client.shared.model.DataItem;
-import org.dive4elements.river.client.shared.model.DataList;
-import org.dive4elements.river.client.shared.model.DefaultData;
-import org.dive4elements.river.client.shared.model.DefaultDataItem;
-import org.dive4elements.river.client.shared.model.SedimentLoadInfoObject;
-import org.dive4elements.river.client.shared.model.SedimentLoadInfoRecord;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Record;
-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.Label;
-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.fields.TextItem;
-import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
-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.VLayout;
-
-public class InundationDurLoadEpochPanel extends AbstractUIProvider {
-    protected SedimentLoadInfoServiceAsync sedLoadInfoService = GWT.create(SedimentLoadInfoService.class);
-
-    protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
-
-    protected ListGrid elements;
-    private TextItem start;
-    private TextItem end;
-    private ListGrid sedLoadTable; // TODO: Datenquelle für Collision richtig wählen! Sediment komplett eliminieren
-
-    protected List<String> validYears;
-
-    public Canvas createWidget(final DataList data) {
-        final HLayout input = new HLayout();
-        final VLayout root = new VLayout();
-        final VLayout grid = new VLayout();
-        final VLayout intFields = new VLayout();
-        final Button add = new Button(this.MSG.add_date());
-        this.elements = new ListGrid();
-
-        final Label title = new Label(data.get(0).getDescription());
-        title.setHeight("25px");
-
-        final DynamicForm form = new DynamicForm();
-        form.setNumCols(4);
-        this.start = new TextItem(this.MSG.from());
-        this.start.setWidth(60);
-        this.start.setValidators(new IsIntegerValidator());
-        this.end = new TextItem(this.MSG.to());
-        this.end.setWidth(60);
-        this.end.setValidators(new IsIntegerValidator());
-        form.setFields(this.start, this.end);
-        add.addClickHandler(new ClickHandler() {
-            @Override
-            public void onClick(final ClickEvent ce) {
-                final String v1 = InundationDurLoadEpochPanel.this.start.getValueAsString();
-                final String v2 = InundationDurLoadEpochPanel.this.end.getValueAsString();
-                if (v1 == null || v2 == null) {
-                    return;
-                }
-                if (!isValidEpoch(v1, v2)) {
-                    return;
-                }
-                final ListGridRecord r = new ListGridRecord();
-                r.setAttribute("from", v1);
-                r.setAttribute("to", v2);
-                InundationDurLoadEpochPanel.this.elements.addData(r);
-            }
-        });
-
-        final Label sel = new Label(this.MSG.select());
-        sel.setHeight(25);
-        this.elements.setWidth(185);
-        this.elements.setHeight(120);
-        this.elements.setShowHeaderContextMenu(false);
-        this.elements.setCanReorderFields(false);
-        this.elements.setCanSort(false);
-        this.elements.setCanEdit(false);
-        final ListGridField from = new ListGridField("from", this.MSG.from());
-        final ListGridField to = new ListGridField("to", this.MSG.to());
-        from.setWidth(70);
-        to.setWidth(70);
-
-        final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") {
-            {
-                setType(ListGridFieldType.ICON);
-                setIcon(GWT.getHostPageBaseURL() + InundationDurLoadEpochPanel.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(from, to, removeField);
-
-        intFields.addMember(form);
-        intFields.addMember(add);
-        grid.addMember(sel);
-        grid.addMember(this.elements);
-        input.addMember(intFields);
-        input.addMember(grid);
-        root.addMember(title);
-        root.addMember(input);
-
-        return root;
-    }
-
-    @Override
-    public Canvas createOld(final DataList dataList) {
-        final HLayout layout = new HLayout();
-        layout.setWidth("400px");
-        final VLayout vLayout = new VLayout();
-        vLayout.setWidth(130);
-        final Label label = new Label(dataList.getLabel());
-        label.setWidth("200px");
-        label.setHeight(25);
-
-        final List<Data> items = dataList.getAll();
-        final Data str = getData(items, "epochs");
-        final DataItem[] strItems = str.getItems();
-
-        final String[] pairs = strItems[0].getLabel().split(";");
-        for (final String pair : pairs) {
-            final String[] vals = pair.split(",");
-            final Label dateLabel = new Label(vals[0] + " - " + vals[1]);
-            dateLabel.setHeight(20);
-            vLayout.addMember(dateLabel);
-        }
-        final Canvas back = getBackButton(dataList.getState());
-        layout.addMember(label);
-        layout.addMember(vLayout);
-        layout.addMember(back);
-
-        return layout;
-    }
-
-    @Override
-    public Canvas create(final DataList data) {
-        final VLayout layout = new VLayout();
-        final Canvas helper = createHelper();
-        this.helperContainer.addMember(helper);
-
-        final Canvas submit = getNextButton();
-        final Canvas widget = createWidget(data);
-
-        layout.addMember(widget);
-        layout.addMember(submit);
-
-        fetchSedimentLoadData();
-
-        return layout;
-    }
-
-    private Canvas createHelper() {
-        this.sedLoadTable = new ListGrid();
-        this.sedLoadTable.setShowHeaderContextMenu(false);
-        this.sedLoadTable.setWidth100();
-        this.sedLoadTable.setShowRecordComponents(true);
-        this.sedLoadTable.setShowRecordComponentsByCell(true);
-        this.sedLoadTable.setHeight100();
-        this.sedLoadTable.setEmptyMessage(this.MSG.empty_table());
-        this.sedLoadTable.setCanReorderFields(false);
-
-        /* Input support pins */
-        final String baseUrl = GWT.getHostPageBaseURL();
-        final ListGridField pinFrom = new ListGridField("fromIcon", this.MESSAGES.from());
-        pinFrom.setWidth(30);
-        pinFrom.setType(ListGridFieldType.ICON);
-        pinFrom.setCellIcon(baseUrl + this.MESSAGES.markerGreen());
-
-        final ListGridField pinTo = new ListGridField("toIcon", this.MESSAGES.to());
-        pinTo.setType(ListGridFieldType.ICON);
-        pinTo.setWidth(30);
-        pinTo.setCellIcon(baseUrl + this.MESSAGES.markerRed());
-
-        pinFrom.addRecordClickHandler(new RecordClickHandler() {
-            @Override
-            public void onRecordClick(final RecordClickEvent e) {
-                final Record r = e.getRecord();
-                InundationDurLoadEpochPanel.this.start.setValue(r.getAttribute("date"));
-            }
-        });
-
-        pinTo.addRecordClickHandler(new RecordClickHandler() {
-            @Override
-            public void onRecordClick(final RecordClickEvent e) {
-                final Record r = e.getRecord();
-                InundationDurLoadEpochPanel.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.sedLoadTable.setFields(pinFrom, pinTo, date, descr);
-        return this.sedLoadTable;
-    }
-
-    @Override
-    protected Data[] getData() {
-        final List<Data> data = new ArrayList<Data>();
-
-        final ListGridRecord[] lgr = this.elements.getRecords();
-        if (lgr.length == 0) {
-            return new Data[0];
-        }
-        String d = "";
-        for (final ListGridRecord element : lgr) {
-            final Record r = element;
-            d += r.getAttribute("from") + "," + r.getAttribute("to");
-            d += ";";
-        }
-
-        final DataItem item = new DefaultDataItem("epochs", null, d);
-        data.add(new DefaultData("epochs", null, null, new DataItem[] { item }));
-        return data.toArray(new Data[data.size()]);
-    }
-
-    protected void fetchSedimentLoadData() {
-        final Config config = Config.getInstance();
-        final String locale = config.getLocale();
-
-        final ArtifactDescription adescr = this.artifact.getArtifactDescription();
-        final DataList[] data = adescr.getOldData();
-
-        final double[] km = this.artifact.getArtifactDescription().getKMRange();
-        final String river = this.artifact.getArtifactDescription().getRiver();
-
-        String sq_ti_id = "";
-        this.validYears = new ArrayList<String>(data.length);
-        for (final DataList element : data) {
-            final Data str = getData(element.getAll(), "sq_ti_id");
-            if (str != null) {
-                final DataItem[] strItems = str.getItems();
-                sq_ti_id = strItems[0].getStringValue();
-                break;
-            }
-        }
-
-        if (sq_ti_id.isEmpty()) {
-            GWT.log("Failed to find sq time interval id in data.");
-        }
-
-        this.sedLoadInfoService.getSedimentLoadInfo(locale, river, "single", km[0], km[1], sq_ti_id, new AsyncCallback<SedimentLoadInfoObject[]>() {
-            @Override
-            public void onFailure(final Throwable caught) {
-                GWT.log("Could not recieve sediment load informations.");
-                SC.warn(InundationDurLoadEpochPanel.this.MSG.getString(caught.getMessage()));
-            }
-
-            @Override
-            public void onSuccess(final SedimentLoadInfoObject[] sedLoad) {
-                final int num = sedLoad != null ? sedLoad.length : 0;
-                GWT.log("Recieved " + num + " sediment load informations.");
-
-                if (num == 0) {
-                    return;
-                }
-
-                addSedimentLoadInfo(sedLoad);
-            }
-        });
-    }
-
-    protected void addSedimentLoadInfo(final SedimentLoadInfoObject[] sedLoad) {
-        for (final SedimentLoadInfoObject sl : sedLoad) {
-            final SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl);
-            this.sedLoadTable.addData(rec);
-            this.validYears.add(rec.getDate());
-        }
-    }
-
-    /*
-     * Validate the epoch input. We do this here and not in an overridden
-     * validate method as we want to validate before an epoch is added
-     * to the list of epochs.
-     */
-    protected boolean isValidEpoch(final String y1, final String y2) {
-        // First check that both are integer
-        int iY1;
-        int iY2;
-        final List<String> errors = new ArrayList<String>();
-        try {
-            iY1 = Integer.parseInt(y1);
-        }
-        catch (final NumberFormatException e) {
-            errors.add(this.MESSAGES.wrongFormat() + ": " + y1);
-        }
-        try {
-            iY2 = Integer.parseInt(y2);
-        }
-        catch (final NumberFormatException e) {
-            errors.add(this.MESSAGES.wrongFormat() + ": " + y2);
-        }
-        if (!errors.isEmpty()) {
-            showErrors(errors);
-            return false;
-        }
-        boolean startIsGood = false;
-        boolean endIsGood = false;
-        for (final String validYear : this.validYears) {
-            if (startIsGood || y1.equals(validYear)) {
-                startIsGood = true;
-            }
-            if (endIsGood || y2.equals(validYear)) {
-                endIsGood = true;
-            }
-            if (startIsGood && endIsGood) {
-                break;
-            }
-            /*
-             * alternative check if data lies in between
-             * int aYear = Integer.parseInt(validYear);
-             * if (aYear >= iY1 && aYear <= iY2) {
-             * isGood = true;
-             * break;
-             * }
-             */
-        }
-        if (!startIsGood) {
-            String tmp = this.MESSAGES.no_data_for_year();
-            tmp = tmp.replace("$1", y1);
-            errors.add(tmp);
-        }
-        if (!endIsGood) {
-            String tmp = this.MESSAGES.no_data_for_year();
-            tmp = tmp.replace("$1", y2);
-            errors.add(tmp);
-        }
-        if (!errors.isEmpty()) {
-            showErrors(errors);
-            return false;
-        }
-        return true;
-    }
-}
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSedimentHeightPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSedimentHeightPanel.java	Tue May 22 17:44:05 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSedimentHeightPanel.java	Wed May 23 17:30:24 2018 +0200
@@ -12,14 +12,17 @@
 import org.dive4elements.river.client.shared.model.DataList;
 
 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.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TextItem;
 import com.smartgwt.client.widgets.layout.VLayout;
 
 public class LoadSedimentHeightPanel extends AbstractSingleItemPanel {
     private static final long serialVersionUID = 1L;
 
     public LoadSedimentHeightPanel() {
+        super(Type.single);
     }
 
     @Override
@@ -28,37 +31,29 @@
     }
 
     @Override
-    protected boolean getTitleVisible() {
-        return false;
-    }
-
-    @Override
     protected String errorForItemMsg() {
         return this.MSG.no_data_sediment_difference();
     }
 
     @Override
     public Canvas createWidget(final DataList data) {
-        final VLayout layout = (VLayout) super.createWidget(data);
+        final VLayout layout = new VLayout();
 
-        //
-        // final Label title = new Label(data.get(0).getDescription());
-        // title.setHeight("35px");
-        //
-        // sorgt dafür, dass HINTER dem Eingabefeld noch ein Textfeld erscheint
-        final DynamicForm form = (DynamicForm) layout.getMember(FORM_ID);
+        final Label title = new Label(data.get(0).getDescription());
+        title.setHeight("25px");
+
+        final DynamicForm form = new DynamicForm();
+        form.setNumCols(4);
+        final TextItem inputItem = createInputItem("");
         final StaticTextItem textItem = new StaticTextItem("IRRELEVANT_NAME");
+
         textItem.setValue("cm");
         textItem.setShowTitle(false);
+        form.setFields(inputItem, textItem);
 
-        form.setFields(this.inputItem, textItem);
+        layout.addMember(title);
+        layout.addMember(form);
 
         return layout;
     }
-
-    @Override
-    protected void appendValue(final String value) { // SINGLE-Input: COPY -> TODO: helper
-        this.inputItem.setValue(value);
-    }
-
-}
+}
\ No newline at end of file
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleEpochMinMaxPanel.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleEpochMinMaxPanel.java	Wed May 23 17:30:24 2018 +0200
@@ -0,0 +1,58 @@
+/* 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.AbstractEpochPanel;
+import org.dive4elements.river.client.client.ui.PanelHelper;
+import org.dive4elements.river.client.shared.model.DataList;
+
+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.TextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
+
+public class LoadSingleEpochMinMaxPanel extends AbstractEpochPanel {
+
+    private static final long serialVersionUID = 1L;
+
+    public LoadSingleEpochMinMaxPanel() {
+        super(Type.singleMinMax);
+    }
+
+    @Override
+    protected String getDatakey() {
+        return "totalepoch";
+    }
+
+    @Override
+    protected Canvas createWidget(final DataList data) {
+        final VLayout root = new VLayout();
+
+        final Label title = new Label(data.get(0).getDescription());
+        title.setHeight("25px");
+
+        final DynamicForm form = new DynamicForm();
+        form.setNumCols(4);
+        final TextItem start = createStartInputItem(this.MSG.from());
+        start.setCanEdit(false);
+
+        final TextItem end = createEndInputItem(this.MSG.to());
+        end.setCanEdit(false);
+
+        form.setFields(start, end);
+
+        root.addMember(title);
+        root.addMember(PanelHelper.getSpacer(10));
+        root.addMember(form);
+
+        return root;
+    }
+
+}
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleEpochPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleEpochPanel.java	Tue May 22 17:44:05 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,328 +0,0 @@
-/* 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 java.util.ArrayList;
-import java.util.List;
-
-import org.dive4elements.river.client.client.Config;
-import org.dive4elements.river.client.client.FLYSConstants;
-import org.dive4elements.river.client.client.services.SedimentLoadInfoService;
-import org.dive4elements.river.client.client.services.SedimentLoadInfoServiceAsync;
-import org.dive4elements.river.client.client.ui.AbstractUIProvider;
-import org.dive4elements.river.client.client.ui.PanelHelper;
-import org.dive4elements.river.client.shared.model.ArtifactDescription;
-import org.dive4elements.river.client.shared.model.Data;
-import org.dive4elements.river.client.shared.model.DataItem;
-import org.dive4elements.river.client.shared.model.DataList;
-import org.dive4elements.river.client.shared.model.DefaultData;
-import org.dive4elements.river.client.shared.model.DefaultDataItem;
-import org.dive4elements.river.client.shared.model.SedimentLoadInfoObject;
-import org.dive4elements.river.client.shared.model.SedimentLoadInfoRecord;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.types.ListGridFieldType;
-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.TextItem;
-import com.smartgwt.client.widgets.form.validator.IsIntegerValidator;
-import com.smartgwt.client.widgets.grid.ListGrid;
-import com.smartgwt.client.widgets.grid.ListGridField;
-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.VLayout;
-
-public class LoadSingleEpochPanel extends AbstractUIProvider {
-    private static final long serialVersionUID = 1L;
-
-    protected SedimentLoadInfoServiceAsync sedLoadInfoService = GWT.create(SedimentLoadInfoService.class);
-
-    protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
-
-    protected ListGrid elements;
-    private TextItem start;
-    private TextItem end;
-    private ListGrid sedLoadTable;
-
-    protected List<String> validYears;
-
-    public Canvas createWidget(final DataList data) {
-        // final HLayout input = new HLayout();
-        final VLayout root = new VLayout();
-        // final VLayout intFields = new VLayout();
-
-        final Label title = new Label(data.get(0).getDescription());
-        title.setHeight("25px");
-
-        final DynamicForm form = new DynamicForm();
-        form.setNumCols(4);
-        this.start = new TextItem(this.MSG.from());
-        this.start.setWidth(60);
-        this.start.setValue(2000);// TODO: get minDate
-        this.start.setCanEdit(false);
-        this.start.setValidators(new IsIntegerValidator());
-        this.end = new TextItem(this.MSG.to());
-        this.end.setWidth(60);
-        this.end.setValidators(new IsIntegerValidator());
-        this.end.setCanEdit(false);
-        this.end.setValue(2005);// TODO: get maxDate
-        form.setFields(this.start, this.end);
-
-        // intFields.addMember(form);
-        // input.addMember(intFields);
-        root.addMember(title);
-        root.addMember(PanelHelper.getSpacer(10));
-        root.addMember(form);
-
-        // root.addMember(input);
-
-        return root;
-    }
-
-    @Override
-    public Canvas createOld(final DataList dataList) {
-        final HLayout layout = new HLayout();
-        layout.setWidth("400px");
-        final VLayout vLayout = new VLayout();
-        vLayout.setWidth(130);
-        final Label label = new Label(dataList.getLabel());
-        label.setWidth("200px");
-        label.setHeight(25);
-
-        final List<Data> items = dataList.getAll();
-        final Data str = getData(items, "totalepoch");
-        final DataItem[] strItems = str.getItems();
-
-        final String[] pairs = strItems[0].getLabel().split(";");
-        for (final String pair : pairs) {
-            final String[] vals = pair.split(",");
-            final Label dateLabel = new Label(vals[0] + " - " + vals[1]);
-            dateLabel.setHeight(20);
-            vLayout.addMember(dateLabel);
-        }
-        final Canvas back = getBackButton(dataList.getState());
-        layout.addMember(label);
-        layout.addMember(vLayout);
-        layout.addMember(back);
-
-        return layout;
-    }
-
-    @Override
-    public Canvas create(final DataList data) {
-        final VLayout layout = new VLayout();
-        final Canvas helper = createHelper();
-        this.helperContainer.addMember(helper);
-
-        final Canvas submit = getNextButton();
-        final Canvas widget = createWidget(data);
-
-        layout.addMember(widget);
-        layout.addMember(submit);
-
-        fetchSedimentLoadData();
-
-        return layout;
-    }
-
-    private Canvas createHelper() {
-        this.sedLoadTable = new ListGrid(); // TODO: get minMax from right datasource
-        this.sedLoadTable.setShowHeaderContextMenu(false);
-        this.sedLoadTable.setWidth100();
-        this.sedLoadTable.setShowRecordComponents(true);
-        this.sedLoadTable.setShowRecordComponentsByCell(true);
-        this.sedLoadTable.setHeight100();
-        this.sedLoadTable.setEmptyMessage(this.MSG.empty_table());
-        this.sedLoadTable.setCanReorderFields(false);
-
-        /* Input support pins */
-        final String baseUrl = GWT.getHostPageBaseURL();
-        final ListGridField pinFrom = new ListGridField("fromIcon", this.MESSAGES.from());
-        pinFrom.setWidth(30);
-        pinFrom.setType(ListGridFieldType.ICON);
-        pinFrom.setCellIcon(baseUrl + this.MESSAGES.markerGreen());
-
-        final ListGridField pinTo = new ListGridField("toIcon", this.MESSAGES.to());
-        pinTo.setType(ListGridFieldType.ICON);
-        pinTo.setWidth(30);
-        pinTo.setCellIcon(baseUrl + this.MESSAGES.markerRed());
-
-        pinFrom.addRecordClickHandler(new RecordClickHandler() {
-            @Override
-            public void onRecordClick(final RecordClickEvent e) {
-                final Record r = e.getRecord();
-                LoadSingleEpochPanel.this.start.setValue("darf nicht geändert werden");// r.getAttribute("date"));
-            }
-        });
-
-        pinTo.addRecordClickHandler(new RecordClickHandler() {
-            @Override
-            public void onRecordClick(final RecordClickEvent e) {
-                final Record r = e.getRecord();
-                LoadSingleEpochPanel.this.end.setValue("darf nicht geändert werden");
-            }
-        });
-
-        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.sedLoadTable.setFields(pinFrom, pinTo, date, descr);
-        return this.sedLoadTable;
-    }
-
-    @Override
-    protected Data[] getData() {
-        final List<Data> data = new ArrayList<Data>();
-
-        // final ListGridRecord[] lgr = this.elements.getRecords();
-        // if (lgr.length == 0) {
-        // return new Data[0];
-        // }
-        String d = "";
-        // // for (final ListGridRecord element : lgr) {
-        // final Record r = element;
-        // d += r.getAttribute("from") + "," + r.getAttribute("to");
-        // d += ";";
-        // }
-
-        d = this.start.getValueAsString() + "," + this.end.getValueAsString() + ";";
-
-        final DataItem item = new DefaultDataItem("totalepoch", null, d);
-        data.add(new DefaultData("totalepoch", null, null, new DataItem[] { item }));
-        return data.toArray(new Data[data.size()]);
-    }
-
-    protected void fetchSedimentLoadData() {
-        final Config config = Config.getInstance();
-        final String locale = config.getLocale();
-
-        final ArtifactDescription adescr = this.artifact.getArtifactDescription();
-        final DataList[] data = adescr.getOldData();
-
-        final double[] km = this.artifact.getArtifactDescription().getKMRange();
-        final String river = this.artifact.getArtifactDescription().getRiver();
-
-        String sq_ti_id = "";
-        this.validYears = new ArrayList<String>(data.length);
-        for (final DataList element : data) {
-            final Data str = getData(element.getAll(), "sq_ti_id");
-            if (str != null) {
-                final DataItem[] strItems = str.getItems();
-                sq_ti_id = strItems[0].getStringValue();
-                break;
-            }
-        }
-
-        if (sq_ti_id.isEmpty()) {
-            GWT.log("Failed to find sq time interval id in data.");
-        }
-
-        this.sedLoadInfoService.getSedimentLoadInfo(locale, river, "single", km[0], km[1], sq_ti_id, new AsyncCallback<SedimentLoadInfoObject[]>() {
-            @Override
-            public void onFailure(final Throwable caught) {
-                GWT.log("Could not recieve sediment load informations.");
-                SC.warn(LoadSingleEpochPanel.this.MSG.getString(caught.getMessage()));
-            }
-
-            @Override
-            public void onSuccess(final SedimentLoadInfoObject[] sedLoad) {
-                final int num = sedLoad != null ? sedLoad.length : 0;
-                GWT.log("Recieved " + num + " sediment load informations.");
-
-                if (num == 0) {
-                    return;
-                }
-
-                addSedimentLoadInfo(sedLoad);
-            }
-        });
-    }
-
-    protected void addSedimentLoadInfo(final SedimentLoadInfoObject[] sedLoad) {
-        for (final SedimentLoadInfoObject sl : sedLoad) {
-            final SedimentLoadInfoRecord rec = new SedimentLoadInfoRecord(sl);
-            this.sedLoadTable.addData(rec);
-            this.validYears.add(rec.getDate());
-        }
-    }
-
-    /*
-     * Validate the epoch input. We do this here and not in an overridden
-     * validate method as we want to validate before an epoch is added
-     * to the list of epochs.
-     */
-    protected boolean isValidEpoch(final String y1, final String y2) {
-        // First check that both are integer
-        int iY1;
-        int iY2;
-        final List<String> errors = new ArrayList<String>();
-        try {
-            iY1 = Integer.parseInt(y1);
-        }
-        catch (final NumberFormatException e) {
-            errors.add(this.MESSAGES.wrongFormat() + ": " + y1);
-        }
-        try {
-            iY2 = Integer.parseInt(y2);
-        }
-        catch (final NumberFormatException e) {
-            errors.add(this.MESSAGES.wrongFormat() + ": " + y2);
-        }
-        if (!errors.isEmpty()) {
-            showErrors(errors);
-            return false;
-        }
-        boolean startIsGood = false;
-        boolean endIsGood = false;
-        for (final String validYear : this.validYears) {
-            if (startIsGood || y1.equals(validYear)) {
-                startIsGood = true;
-            }
-            if (endIsGood || y2.equals(validYear)) {
-                endIsGood = true;
-            }
-            if (startIsGood && endIsGood) {
-                break;
-            }
-            /*
-             * alternative check if data lies in between
-             * int aYear = Integer.parseInt(validYear);
-             * if (aYear >= iY1 && aYear <= iY2) {
-             * isGood = true;
-             * break;
-             * }
-             */
-        }
-        if (!startIsGood) {
-            String tmp = this.MESSAGES.no_data_for_year();
-            tmp = tmp.replace("$1", y1);
-            errors.add(tmp);
-        }
-        if (!endIsGood) {
-            String tmp = this.MESSAGES.no_data_for_year();
-            tmp = tmp.replace("$1", y2);
-            errors.add(tmp);
-        }
-        if (!errors.isEmpty()) {
-            showErrors(errors);
-            return false;
-        }
-        return true;
-    }
-}
diff -r fc02833dbcc1 -r aafae1ab25f0 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleYearPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleYearPanel.java	Tue May 22 17:44:05 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleYearPanel.java	Wed May 23 17:30:24 2018 +0200
@@ -9,29 +9,46 @@
 package org.dive4elements.river.client.client.ui.uinfo;
 
 import org.dive4elements.river.client.client.ui.AbstractSingleItemPanel;
+import org.dive4elements.river.client.shared.model.DataList;
+
+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.TextItem;
+import com.smartgwt.client.widgets.layout.VLayout;
 
 public class LoadSingleYearPanel extends AbstractSingleItemPanel {
 
+    public LoadSingleYearPanel() {
+        super(Type.single);
+    }
+
     @Override
     protected String getDatakey() {
         return "singleyear";
     }
 
-    public LoadSingleYearPanel() {
-    }
-
-    @Override
-    protected void appendValue(final String year) { // SINGLE-Input
-        this.inputItem.setValue(year);
-    }
-
-    @Override
-    protected boolean getTitleVisible() {
-        return false;
-    }
-
     @Override
     protected String errorForItemMsg() {
         return this.MSG.no_data_for_year();
     }
-}
+
+    @Override
+    public Canvas createWidget(final DataList data) {
+        final VLayout layout = new VLayout();
+
+        final Label title = new Label(data.get(0).getDescription());
+        title.setHeight("25px");
+
+        final DynamicForm form = new DynamicForm();
+        form.setNumCols(4);
+
+        final TextItem inputItem = createInputItem("");
+        form.setFields(inputItem);
+
+        layout.addMember(title);
+        layout.addMember(form);
+
+        return layout;
+    }
+}
\ No newline at end of file


More information about the Dive4Elements-commits mailing list