[PATCH] multiple whitespace input fix

Wald Commits scm-commit at wald.intevation.org
Thu Jul 19 13:36:47 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1532000198 -7200
# Node ID 7337034eb5d56817a44d85763fa75cce8c9debb4
# Parent  83ebeb620b5a88d4f17158e470818cb2ffccb438
multiple whitespace input fix

diff -r 83ebeb620b5a -r 7337034eb5d5 artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/bundu/bezugswst/FixationChoice.java	Thu Jul 19 13:36:38 2018 +0200
@@ -48,8 +48,7 @@
         for (int i = 0; i < elements.length; i++) {
             elementsAndYear[i] = elements[i];
         }
-        // add Bezugsjahr
-        // REMEBER: we need it for getLabelFor later
+
         final BunduAccess access = new BunduAccess((D4EArtifact) artifact);
         final int[] eventsTemp = access.getEventsTemp();
         final StringBuilder builder = new StringBuilder();
diff -r 83ebeb620b5a -r 7337034eb5d5 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	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/AbstractSingleItemPanel.java	Thu Jul 19 13:36:38 2018 +0200
@@ -12,7 +12,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import org.dive4elements.river.client.client.FLYSConstants;
 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;
@@ -43,12 +42,12 @@
 
         void setErrorForItemMsg(String errorForItemMsg);
 
-        void setMSG(FLYSConstants msg);
+        // void setMSG(FLYSConstants msg);
     }
 
     private TextItem inputItem;
 
-    private List<String> validInputs = new ArrayList<String>();
+    protected List<String> validInputs = new ArrayList<String>();
 
     private final IMultiSingleBehaviour behaviour;
 
@@ -75,8 +74,7 @@
         final Canvas table = helper.getTable();
         this.validInputs = helper.getKeycolEntries();
         this.behaviour.setValidInputs(this.validInputs);
-        this.behaviour.setErrorForItemMsg(this.errorForItemMsg());
-        this.behaviour.setMSG(this.MSG);
+        this.behaviour.setErrorForItemMsg(this.errorForItemMsg());// , this.MSG);
 
         this.helperContainer.addMember(table);
 
@@ -122,7 +120,7 @@
         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());
+            final DataItem yearsdata = new DefaultDataItem(getDatakey(), getDatakey(), StringArrayParseHelper.trimRawString(this.inputItem.getValueAsString()));
             data.add(new DefaultData(getDatakey(), null, null, new DataItem[] { yearsdata }));
 
             return data.toArray(new Data[data.size()]);
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DoubleRangePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DoubleRangePanel.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/DoubleRangePanel.java	Thu Jul 19 13:36:38 2018 +0200
@@ -8,9 +8,12 @@
 
 package org.dive4elements.river.client.client.ui;
 
+import java.util.Map;
+
+import org.dive4elements.river.client.client.FLYSConstants;
+
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.i18n.client.NumberFormat;
-
 import com.smartgwt.client.types.Alignment;
 import com.smartgwt.client.widgets.form.DynamicForm;
 import com.smartgwt.client.widgets.form.fields.FloatItem;
@@ -18,31 +21,25 @@
 import com.smartgwt.client.widgets.form.fields.StaticTextItem;
 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
 
-import org.dive4elements.river.client.client.FLYSConstants;
-
-import java.util.Map;
-
-
 /**
  * This class creates a DynamicForm with three input fields.
  *
  * @author <a href="mailto:ingo.weinzierl at intevation.de">Ingo Weinzierl</a>
  */
-public class DoubleRangePanel
-extends      DynamicForm
-{
-    /** The message class that provides i18n strings.*/
+public class DoubleRangePanel extends DynamicForm {
+    /** The message class that provides i18n strings. */
     protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
 
-
-    /** The constant name of the input field to enter the start of a distance.*/
+    /** The constant name of the input field to enter the start of a distance. */
     public static final String FIELD_FROM = "from";
 
-    /** The constant name of the input field to enter the end of a distance.*/
+    /** The constant name of the input field to enter the end of a distance. */
     public static final String FIELD_TO = "to";
 
-    /** The constant name of the input field to enter the step width of a
-     * distance.*/
+    /**
+     * The constant name of the input field to enter the step width of a
+     * distance.
+     */
     public static final String FIELD_WIDTH = "step";
 
     /** The textboxes */
@@ -50,88 +47,74 @@
     protected FloatItem toItem;
     protected FloatItem stepItem;
 
-
     public DoubleRangePanel() {
     }
 
     public FloatItem getToItem() {
-        return toItem;
+        return this.toItem;
     }
 
-
     /**
      * Creates a new form with a single input field that displays an array of
      * double values.
      *
-     * @param name The name of the TextItem.
-     * @param title The title of the TextItem.
-     * @param values The double values that should be displayed initially.
-     * @param handler The BlurHandler that is used to valide the input.
+     * @param name
+     *            The name of the TextItem.
+     * @param title
+     *            The title of the TextItem.
+     * @param values
+     *            The double values that should be displayed initially.
+     * @param handler
+     *            The BlurHandler that is used to valide the input.
      */
-    public DoubleRangePanel(
-        String titleFrom, String titleTo, String titleStep,
-        double from, double to, double step,
-        int width,
-        BlurHandler handler)
-    {
-        this(
-            titleFrom, titleTo, titleStep,
-            from, to, step,
-            width,
-            handler,
-            "right");
+    public DoubleRangePanel(final String titleFrom, final String titleTo, final String titleStep, final double from, final double to, final double step,
+            final int width, final BlurHandler handler) {
+        this(titleFrom, titleTo, titleStep, from, to, step, width, handler, "right");
     }
 
+    public DoubleRangePanel(final String titleFrom, final String titleTo, final String titleStep, final double from, final double to, final double step,
+            final int width, final BlurHandler handler, final String labelOrientation) {
+        this.fromItem = new FloatItem(FIELD_FROM);
+        this.toItem = new FloatItem(FIELD_TO);
+        this.stepItem = new FloatItem(FIELD_WIDTH);
 
-    public DoubleRangePanel(
-        String titleFrom, String titleTo, String titleStep,
-        double from, double to, double step,
-        int width,
-        BlurHandler handler,
-        String labelOrientation)
-    {
-        fromItem = new FloatItem(FIELD_FROM);
-        toItem   = new FloatItem(FIELD_TO);
-        stepItem = new FloatItem(FIELD_WIDTH);
+        this.fromItem.addBlurHandler(handler);
+        this.toItem.addBlurHandler(handler);
+        this.stepItem.addBlurHandler(handler);
 
-        fromItem.addBlurHandler(handler);
-        toItem.addBlurHandler(handler);
-        stepItem.addBlurHandler(handler);
+        final NumberFormat f = NumberFormat.getDecimalFormat();
 
-        NumberFormat f = NumberFormat.getDecimalFormat();
+        this.fromItem.setValue(f.format(from));
+        this.toItem.setValue(f.format(to));
+        this.stepItem.setValue(f.format(step));
 
-        fromItem.setValue(f.format(from));
-        toItem.setValue(f.format(to));
-        stepItem.setValue(f.format(step));
-
-        StaticTextItem fromText = new StaticTextItem("staticFrom");
+        final StaticTextItem fromText = new StaticTextItem("staticFrom");
         fromText.setValue(titleFrom);
         fromText.setShowTitle(false);
-        fromItem.setShowTitle(false);
+        this.fromItem.setShowTitle(false);
 
-        StaticTextItem toText = new StaticTextItem("staticTo");
+        final StaticTextItem toText = new StaticTextItem("staticTo");
         toText.setValue(titleTo);
         toText.setShowTitle(false);
-        toItem.setShowTitle(false);
+        this.toItem.setShowTitle(false);
 
-        StaticTextItem stepText = new StaticTextItem("staticStep");
+        final StaticTextItem stepText = new StaticTextItem("staticStep");
         stepText.setValue(titleStep);
         stepText.setShowTitle(false);
-        stepItem.setShowTitle(false);
+        this.stepItem.setShowTitle(false);
 
-        int itemWidth = width / 6;
-        fromItem.setWidth(itemWidth);
+        final int itemWidth = width / 6;
+        this.fromItem.setWidth(itemWidth);
         fromText.setWidth(itemWidth);
-        toItem.setWidth(itemWidth);
+        this.toItem.setWidth(itemWidth);
         toText.setWidth(itemWidth);
-        stepItem.setWidth(itemWidth);
+        this.stepItem.setWidth(itemWidth);
         stepText.setWidth(itemWidth);
 
         if (labelOrientation.equals("right")) {
-            setFields(fromItem, fromText, toItem, toText, stepItem, stepText);
-        }
-        else {
-            setFields(fromText, fromItem, toText, toItem, stepText, stepItem);
+            setFields(this.fromItem, fromText, this.toItem, toText, this.stepItem, stepText);
+        } else {
+            setFields(fromText, this.fromItem, toText, this.toItem, stepText, this.stepItem);
         }
 
         setFixedColWidths(false);
@@ -140,31 +123,30 @@
         setAlign(Alignment.CENTER);
     }
 
-
     /**
      * This method takes distances values and sets them to the textboxes
      * visualizied by this widget.
      *
-     * @param from  The from value.
-     * @param to    The to value.
-     * @param steps The max steps.
+     * @param from
+     *            The from value.
+     * @param to
+     *            The to value.
+     * @param steps
+     *            The max steps.
      */
-    public void setValues(double from, double to, double steps) {
-        NumberFormat f = NumberFormat.getDecimalFormat();
+    public void setValues(final double from, final double to, final double steps) {
+        final NumberFormat f = NumberFormat.getDecimalFormat();
 
-        fromItem.setValue(f.format(from));
-        toItem.setValue(f.format(to));
-        stepItem.setValue(f.format(steps));
+        this.fromItem.setValue(f.format(from));
+        this.toItem.setValue(f.format(to));
+        this.stepItem.setValue(f.format(steps));
     }
 
     public boolean validateForm() {
         try {
-            return
-                validateForm(fromItem) &&
-                validateForm(toItem) &&
-                validateForm(stepItem);
+            return validateForm(this.fromItem) && validateForm(this.toItem) && validateForm(this.stepItem);
         }
-        catch (NumberFormatException nfe) {
+        catch (final NumberFormatException nfe) {
             return false;
         }
     }
@@ -177,21 +159,22 @@
      * Also if negativeToAllowed is false, an error is registered if
      * the 'to' field contains a negative value.
      *
-     * @param item The FormItem.
+     * @param item
+     *            The FormItem.
      */
     @SuppressWarnings("unchecked")
-    protected boolean validateForm(FormItem item) {
+    protected boolean validateForm(final FormItem item) {
         if (item instanceof StaticTextItem) {
             return true;
         }
 
         boolean valid = true;
 
-        String v = (String) item.getValue();
+        final String v = (String) item.getValue();
 
-        NumberFormat f = NumberFormat.getDecimalFormat();
+        final NumberFormat f = NumberFormat.getDecimalFormat();
         @SuppressWarnings("rawtypes")
-        Map errors     = getErrors();
+        final Map errors = getErrors();
 
         try {
             if (v == null) {
@@ -202,8 +185,8 @@
 
             errors.remove(item.getFieldName());
         }
-        catch (NumberFormatException nfe) {
-            errors.put(item.getFieldName(), MESSAGES.wrongFormat());
+        catch (final NumberFormatException nfe) {
+            errors.put(item.getFieldName(), this.MESSAGES.wrongFormat());
 
             item.focusInItem();
 
@@ -215,95 +198,92 @@
         return valid;
     }
 
-
     /**
      * Returns the double value of <i>value</i>.
      *
      * @return the double value of <i>value</i>.
      */
-    protected double getDouble(String value) {
-        NumberFormat f = NumberFormat.getDecimalFormat();
+    protected double getDouble(final String value) {
+        final NumberFormat f = NumberFormat.getDecimalFormat();
 
-        String[] splitted = value.split(" ");
+        final String[] splitted = StringArrayParseHelper.getArrayFromRawString(value); // Nullpointer?
 
         return f.parse(splitted[0]);
     }
 
-
     /**
      * Returns the start value.
      *
      * @return the start value.
      */
     public double getFrom() throws NullPointerException {
-        String v = getValueAsString(FIELD_FROM);
+        final String v = getValueAsString(FIELD_FROM);
 
         return getDouble(v);
     }
 
-
     /**
      * Returns the end value.
      *
      * @return the end value.
      */
     public double getTo() throws NullPointerException {
-        String v = getValueAsString(FIELD_TO);
+        final String v = getValueAsString(FIELD_TO);
 
         return getDouble(v);
     }
 
-
     /**
      * Returns the step width.
      *
      * @return the step width.
      */
     public double getStep() throws NullPointerException {
-        String v = getValueAsString(FIELD_WIDTH);
+        final String v = getValueAsString(FIELD_WIDTH);
 
         return getDouble(v);
     }
 
-
     /**
      * Sets the value of the field with name <i>fieldname</i>.
      *
-     * @param value The new value.
-     * @param fieldname The name of the field.
+     * @param value
+     *            The new value.
+     * @param fieldname
+     *            The name of the field.
      */
-    public void setDoubleValue(double value, String fieldname) {
-        NumberFormat f = NumberFormat.getDecimalFormat();
+    public void setDoubleValue(final double value, final String fieldname) {
+        final NumberFormat f = NumberFormat.getDecimalFormat();
         setValue(fieldname, f.format(value));
     }
 
-
     /**
      * Sets a new start value.
      *
-     * @param value The new start value.
+     * @param value
+     *            The new start value.
      */
-    public void setFrom(double value) {
+    public void setFrom(final double value) {
         setDoubleValue(value, FIELD_FROM);
     }
 
-
     /**
      * Sets a new end value.
      *
-     * @param value The new end value.
+     * @param value
+     *            The new end value.
      */
-    public void setTo(double value) {
+    public void setTo(final double value) {
         setDoubleValue(value, FIELD_TO);
     }
 
-
     /**
      * Sets a new step width.
      *
-     * @param value The new step width.
+     * @param value
+     *            The new step width.
      */
-    public void setStep(double value) {
+    public void setStep(final double value) {
         setDoubleValue(value, FIELD_WIDTH);
     }
 }
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LocationDistancePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LocationDistancePanel.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/LocationDistancePanel.java	Thu Jul 19 13:36:38 2018 +0200
@@ -459,7 +459,7 @@
         final Data dLocations = getData(items, "ld_locations");
         final DataItem[] lItems = dLocations.getItems();
 
-        final String[] splitted = lItems[0].getStringValue().split(" ");
+        final String[] splitted = StringArrayParseHelper.getArrayFromRawString(lItems[0].getStringValue());
         String value = "";
         for (final String element : splitted) {
             try {
@@ -1215,8 +1215,7 @@
     }
 
     protected void setLocationValues(final String values) {
-        final String[] vs = values.split(" ");
-
+        final String[] vs = StringArrayParseHelper.getArrayFromRawString(values);
         if (vs == null) {
             return;
         }
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/StringArrayParseHelper.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/StringArrayParseHelper.java	Thu Jul 19 13:36:38 2018 +0200
@@ -0,0 +1,32 @@
+/** 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;
+
+/**
+ * @author Domenico Nardi Tironi
+ *
+ */
+public class StringArrayParseHelper {
+
+    public static final String[] getArrayFromRawString(final String raw) {
+        if (raw != null) {
+            return raw.trim().replaceAll("\\s+", " ").split(" ");
+        }
+        return new String[] {};
+    }
+
+    public static final String trimRawString(final String raw) {
+        if (raw != null) {
+            return raw.trim().replaceAll("\\s+", " ");
+        }
+        return "";
+    }
+
+}
diff -r 83ebeb620b5a -r 7337034eb5d5 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	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/UIProviderFactory.java	Thu Jul 19 13:36:38 2018 +0200
@@ -179,21 +179,21 @@
         } else if (uiProvider.equals("minfo.sedimentload_epoch_select")) {
             return new SedLoadEpochPanel();
         } else if (uiProvider.equals("sinfo.collision.load_year_select")) {
-            return new CollisionLoadYearPanel();
+            return new CollisionLoadYearPanel(getMSG());
         } else if (uiProvider.equals("sinfo.collision.load_epoch_select")) {
             return new CollisionLoadEpochPanel();
         } else if (uiProvider.equals("common.state.load_single_year_select")) {
-            return new LoadSingleYearPanel();
+            return new LoadSingleYearPanel(getMSG());
         } else if (uiProvider.equals("common.state.load_single_year_select.show_hint")) {
-            return new LoadSingleYearPanel(true);
+            return new LoadSingleYearPanel(getMSG(), true);
         } else if (uiProvider.equals("uinfo.salix.load_single_year_pseudo_epoch_select")) {
-            return new LoadSingleYearPseudoEpochPanel();
+            return new LoadSingleYearPseudoEpochPanel(getMSG());
         } else if (uiProvider.equals("minfo.sedimentload_sqti_select")) {
             return new SedLoadSQTiPanel();
         } else if (uiProvider.equals("uinfo.sedimentheight_select")) {
-            return new LoadSedimentHeightPanel(new SingleBehaviour());// Type.single);
+            return new LoadSedimentHeightPanel(new SingleBehaviour(getMSG()));// Type.single);
         } else if (uiProvider.equals("uinfo.sedimentheight_select.limit5")) {
-            return new LoadSedimentHeightPanel(new Limit5SalixBehaviour());
+            return new LoadSedimentHeightPanel(new Limit5SalixBehaviour(getMSG()));
         } else if (uiProvider.equals("hws_datacage_panel")) {
             return new HWSDatacagePanel(user);
         } else if (uiProvider.equals("user_rgd_panel")) {
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/QSeriesLengthPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/QSeriesLengthPanel.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/bundu/QSeriesLengthPanel.java	Thu Jul 19 13:36:38 2018 +0200
@@ -13,6 +13,7 @@
 
 import org.dive4elements.river.client.client.ui.AbstractUIProvider;
 import org.dive4elements.river.client.client.ui.PanelHelper;
+import org.dive4elements.river.client.client.ui.StringArrayParseHelper;
 import org.dive4elements.river.client.client.ui.ValidationHelper;
 import org.dive4elements.river.client.shared.model.Data;
 import org.dive4elements.river.client.shared.model.DataItem;
@@ -72,7 +73,7 @@
         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());
+            final DataItem yearsdata = new DefaultDataItem(getDatakey(), getDatakey(), StringArrayParseHelper.trimRawString(this.inputItem.getValueAsString()));
             data.add(new DefaultData(getDatakey(), null, null, new DataItem[] { yearsdata }));
 
             return data.toArray(new Data[data.size()]);
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/BunduFixPeriodPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/BunduFixPeriodPanel.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/BunduFixPeriodPanel.java	Thu Jul 19 13:36:38 2018 +0200
@@ -13,6 +13,7 @@
 
 import org.dive4elements.river.client.client.FLYSConstants;
 import org.dive4elements.river.client.client.ui.PanelHelper;
+import org.dive4elements.river.client.client.ui.StringArrayParseHelper;
 import org.dive4elements.river.client.client.ui.ValidationHelper;
 import org.dive4elements.river.client.shared.model.Data;
 import org.dive4elements.river.client.shared.model.DataItem;
@@ -118,7 +119,7 @@
         final DateTimeFormat df = DateTimeFormat.getFormat("dd.MM.yyyy");
         if (this.inputItem != null && !this.inputItem.getValueAsString().isEmpty()) {
             final List<Data> data = new ArrayList<Data>();
-            final String bezugsjahr = this.inputItem.getValueAsString().trim();
+            final String bezugsjahr = StringArrayParseHelper.trimRawString(this.inputItem.getValueAsString());
             final DataItem yearsdata = new DefaultDataItem(getDatakey(), getDatakey(), bezugsjahr);
             data.add(new DefaultData(getDatakey(), null, null, new DataItem[] { yearsdata }));
 
diff -r 83ebeb620b5a -r 7337034eb5d5 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	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/CollisionLoadYearPanel.java	Thu Jul 19 13:36:38 2018 +0200
@@ -8,6 +8,7 @@
 
 package org.dive4elements.river.client.client.ui.sinfo;
 
+import org.dive4elements.river.client.client.FLYSConstants;
 import org.dive4elements.river.client.client.ui.AbstractSingleItemPanel;
 import org.dive4elements.river.client.shared.model.DataList;
 
@@ -21,8 +22,8 @@
 
     private static final long serialVersionUID = 1L;
 
-    public CollisionLoadYearPanel() {
-        super(new MultiBehaviour());
+    public CollisionLoadYearPanel(final FLYSConstants msg) {
+        super(new MultiBehaviour(msg));
     }
 
     @Override
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/MultiBehaviour.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/MultiBehaviour.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/sinfo/MultiBehaviour.java	Thu Jul 19 13:36:38 2018 +0200
@@ -12,6 +12,7 @@
 import java.util.List;
 
 import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.client.ui.StringArrayParseHelper;
 import org.dive4elements.river.client.client.ui.uinfo.ValidationBehaviourSingleMultiInputItem;
 
 import com.smartgwt.client.widgets.form.fields.TextItem;
@@ -26,8 +27,8 @@
         super(validInputs, errorForItemMsg, MSG);
     }
 
-    public MultiBehaviour() {
-        super();
+    public MultiBehaviour(final FLYSConstants msg) {
+        super(msg);
     }
 
     @Override
@@ -44,7 +45,7 @@
     @Override
     public List<String> validate(final List<String> errors, final String inputValueString) {
         if (inputValueString != null) {
-            final String[] sValues = inputValueString.trim().split(" ");
+            final String[] sValues = StringArrayParseHelper.getArrayFromRawString(inputValueString);
             for (final String value : sValues) {
                 errors.addAll(this.validateSingleInput(value));
             }
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeListGrid.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeListGrid.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeListGrid.java	Thu Jul 19 13:36:38 2018 +0200
@@ -22,6 +22,7 @@
 import org.dive4elements.river.client.client.services.StepForwardService;
 import org.dive4elements.river.client.client.services.StepForwardServiceAsync;
 import org.dive4elements.river.client.client.ui.CollectionView;
+import org.dive4elements.river.client.client.ui.StringArrayParseHelper;
 import org.dive4elements.river.client.shared.model.Artifact;
 import org.dive4elements.river.client.shared.model.Collection;
 import org.dive4elements.river.client.shared.model.Data;
@@ -243,7 +244,7 @@
             if (tmp != null) {
                 if (tmp.contains(" ")) {
                     // string contains several values ...
-                    final String[] values = tmp.split(" ");
+                    final String[] values = StringArrayParseHelper.getArrayFromRawString(tmp);
                     for (final String value2 : values) {
                         final Double value = Double.valueOf(value2);
                         if (value != null) {
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/Limit5SalixBehaviour.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/Limit5SalixBehaviour.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/Limit5SalixBehaviour.java	Thu Jul 19 13:36:38 2018 +0200
@@ -12,6 +12,7 @@
 import java.util.List;
 
 import org.dive4elements.river.client.client.FLYSConstants;
+import org.dive4elements.river.client.client.ui.StringArrayParseHelper;
 
 import com.smartgwt.client.util.SC;
 import com.smartgwt.client.widgets.form.fields.TextItem;
@@ -26,8 +27,8 @@
         super(validInputs, errorForItemMsg, MSG);
     }
 
-    public Limit5SalixBehaviour() {
-        super();
+    public Limit5SalixBehaviour(final FLYSConstants msg) {
+        super(msg);
     }
 
     @Override
@@ -35,7 +36,7 @@
         // APPEND = ADD to existing -> MULTI YEAR
         final String oldValues = inputItem.getValueAsString();
         if (oldValues != null && !oldValues.isEmpty()) {
-            final String[] oldVals = oldValues.split(" ");
+            final String[] oldVals = StringArrayParseHelper.getArrayFromRawString(oldValues);
             if (oldVals.length < 5)
                 inputItem.setValue(oldValues.trim() + " " + value);
             else {
@@ -51,7 +52,7 @@
     @Override
     public List<String> validate(final List<String> errors, final String inputValueString) {
         if (inputValueString != null) {
-            final String[] values = inputValueString.trim().replace("  ", " ").split(" ");
+            final String[] values = StringArrayParseHelper.getArrayFromRawString(inputValueString);
             if (values.length > 5) {
                 errors.add(this.MSG.error_limit_exceeded_salix());
             }
diff -r 83ebeb620b5a -r 7337034eb5d5 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	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleYearPanel.java	Thu Jul 19 13:36:38 2018 +0200
@@ -8,6 +8,7 @@
 
 package org.dive4elements.river.client.client.ui.uinfo;
 
+import org.dive4elements.river.client.client.FLYSConstants;
 import org.dive4elements.river.client.client.ui.AbstractSingleItemPanel;
 import org.dive4elements.river.client.shared.model.DataList;
 
@@ -22,12 +23,12 @@
     private static final long serialVersionUID = 1L;
     private boolean showHint = false;
 
-    public LoadSingleYearPanel() {
-        super(new SingleBehaviour());
+    public LoadSingleYearPanel(final FLYSConstants msg) {
+        super(new SingleBehaviour(msg));
     }
 
-    public LoadSingleYearPanel(final boolean showHint) {
-        super(new SingleBehaviour());
+    public LoadSingleYearPanel(final FLYSConstants msg, final boolean showHint) {
+        super(new SingleBehaviour(msg));
         this.showHint = showHint;
     }
 
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleYearPseudoEpochPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleYearPseudoEpochPanel.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleYearPseudoEpochPanel.java	Thu Jul 19 13:36:38 2018 +0200
@@ -8,8 +8,14 @@
 
 package org.dive4elements.river.client.client.ui.uinfo;
 
+import org.dive4elements.river.client.client.FLYSConstants;
+
 public class LoadSingleYearPseudoEpochPanel extends LoadSingleYearPanel {
 
+    public LoadSingleYearPseudoEpochPanel(final FLYSConstants msg) {
+        super(msg);
+    }
+
     private static final long serialVersionUID = 1L;
 
     @Override
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SingleBehaviour.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SingleBehaviour.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SingleBehaviour.java	Thu Jul 19 13:36:38 2018 +0200
@@ -25,8 +25,8 @@
         super(validInputs, errorForItemMsg, MSG);
     }
 
-    public SingleBehaviour() {
-        super();
+    public SingleBehaviour(final FLYSConstants msg) {
+        super(msg);
     }
 
     @Override
diff -r 83ebeb620b5a -r 7337034eb5d5 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/ValidationBehaviourSingleMultiInputItem.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/ValidationBehaviourSingleMultiInputItem.java	Thu Jul 19 08:07:03 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/ValidationBehaviourSingleMultiInputItem.java	Thu Jul 19 13:36:38 2018 +0200
@@ -23,7 +23,7 @@
 
     private List<String> validInputs = null;
     private String errorForItemMsg = null;
-    protected FLYSConstants MSG = null;
+    protected final FLYSConstants MSG;
 
     public ValidationBehaviourSingleMultiInputItem(final List<String> validInputs, final String errorForItemMsg, final FLYSConstants MSG) {
         this.validInputs = validInputs;
@@ -31,8 +31,8 @@
         this.MSG = MSG; // etwas unglücklich...
     }
 
-    public ValidationBehaviourSingleMultiInputItem() {
-
+    public ValidationBehaviourSingleMultiInputItem(final FLYSConstants MSG) {
+        this.MSG = MSG;
     }
 
     protected final List<String> validateSingleInput(final String sValue) {
@@ -52,7 +52,6 @@
             String tmp = this.errorForItemMsg;
             tmp = tmp.replace("$1", sValue);
             errors.add(tmp);
-            // continue;
         }
 
         return errors;
@@ -84,10 +83,4 @@
 
     }
 
-    @Override
-    public void setMSG(final FLYSConstants msg) {
-        this.MSG = this.MSG;
-
-    }
-
 }


More information about the Dive4Elements-commits mailing list