[PATCH] salix.supraregional better error- + advance-handling

Wald Commits scm-commit at wald.intevation.org
Tue Jul 10 14:45:48 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1531226740 -7200
# Node ID 4e3757202d5c71707f49e7923a4808de0bee1eb4
# Parent  1c756bfee472f2a8a7f1b48ac0838c7d8cd69d0a
salix.supraregional better error- + advance-handling

diff -r 1c756bfee472 -r 4e3757202d5c gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Tue Jul 10 13:27:17 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java	Tue Jul 10 14:45:40 2018 +0200
@@ -1568,4 +1568,6 @@
     String uinfo_salix_km_has_gaps();
 
     String uinfo_salix_km_anschluss();
+
+    String uinfo_salix_input_complete();
 }
\ No newline at end of file
diff -r 1c756bfee472 -r 4e3757202d5c gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Tue Jul 10 13:27:17 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties	Tue Jul 10 14:45:40 2018 +0200
@@ -832,9 +832,10 @@
 uinfo_vegetation_zones_invalid_integer = Nur Ganzzahlen erlaubt.
 uinfo_salix_invalid_double = Nur Zahlen erlaubt.
 uinfo_salix_km_limit_exceed = Die Zahl ist au\u00dferhalb des g\u00fcltigen km-Bereichs.
-uinfo_salix_km_overlap = Km-Bereiche \u00fcperlappen.
+uinfo_salix_km_overlap = Km-Bereiche \u00fcberlappen.
 uinfo_salix_km_has_gaps = Der Km-Bereich ist nicht vollst. belegt.
 uinfo_salix_km_anschluss = Der eingegebene Bereich schlie\u00dft nicht an den letzten Wert an.
+uinfo_salix_input_complete = Die gesamte Strecke ist bereits mit Werten belegt.
 
 bundu = Betrieb und Unterhaltung 
 
diff -r 1c756bfee472 -r 4e3757202d5c gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Tue Jul 10 13:27:17 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties	Tue Jul 10 14:45:40 2018 +0200
@@ -832,9 +832,10 @@
 uinfo_vegetation_zones_invalid_integer = Nur Ganzzahlen erlaubt.
 uinfo_salix_invalid_double = Nur Zahlen erlaubt.
 uinfo_salix_km_limit_exceed = Die Zahl ist au\u00dferhalb des g\u00fcltigen km-Bereichs.
-uinfo_salix_km_overlap = Km-Bereiche \u00fcperlappen.
+uinfo_salix_km_overlap = Km-Bereiche \u00fcberlappen.
 uinfo_salix_km_has_gaps = Der Km-Bereich ist nicht vollst. belegt.
 uinfo_salix_km_anschluss = Der eingegebene Bereich schlie\u00dft nicht an den letzten Wert an.
+uinfo_salix_input_complete = Die gesamte Strecke ist bereits mit Werten belegt.
 
 bundu = Betrieb und Unterhaltung
 
diff -r 1c756bfee472 -r 4e3757202d5c gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SupraRegionalTablePanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SupraRegionalTablePanel.java	Tue Jul 10 13:27:17 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SupraRegionalTablePanel.java	Tue Jul 10 14:45:40 2018 +0200
@@ -110,6 +110,21 @@
 
         final VLayout layout = new VLayout();
         final Canvas submit = getNextButton();
+        //
+        // new Button(this.MSG.buttonNext());
+        // final HandlerRegistration reg = submit.addClickHandler(new ClickHandler() {
+        //
+        // @Override
+        // public void onClick(final ClickEvent event) {
+        // final String msg = getErrorMsg();
+        // if (!msg.equals("")) {
+        // SC.warn(msg);
+        // } else {
+        // // continue, forward, advance
+        //
+        // }
+        // }
+        // });
 
         final VLayout root = new VLayout();
         root.setWidth(420);
@@ -149,13 +164,9 @@
     public Canvas createWidget(final Layout root, final DataList data, final String tableData) {
 
         this.table = createTable(root, data, tableData);
-
         final TextItem dwspl = PanelHelper.createItem("_label_dwspl", this.MSG.uinfo_salix_dmwspl_short(), "50");
-        // this.dwspl.setColSpan(3);
         final TextItem start = PanelHelper.createIntegerItem("_from_dwspl", getLabelFromTo(this.MSG.from()), "50");
-        // this.start.setColSpan(3);
         final TextItem end = PanelHelper.createIntegerItem("_to_dwspl", getLabelFromTo(this.MSG.to()), "50");
-        // this.end.setColSpan(3);
 
         final HLayout fields = new HLayout();
 
@@ -383,6 +394,8 @@
 
     private String validate(final String fromInput, final String toInput, final String dmwspl) {
 
+        final List<SalixZone> zones = getSalixZones(this.table.getRecords());
+
         if (fromInput == null || toInput == null || dmwspl == null || fromInput.trim().isEmpty() || toInput.trim().isEmpty() || dmwspl.trim().isEmpty())
             return this.MSG.uinfo_vegetation_zones_validation_empty();
 
@@ -391,11 +404,14 @@
             final Double to = this.format.parse(toInput);
             Integer.valueOf(dmwspl);
 
+            if (!SalixZone.hasGaps(zones, this.minKm, this.maxKm))
+                return this.MSG.uinfo_salix_input_complete();
+
             if (from < this.minKm || from > this.maxKm || to > this.maxKm || to < this.minKm)
                 return this.MSG.uinfo_salix_km_limit_exceed();
 
             // range anschluss
-            if (!SalixZone.isValidAnschlussRange(from, to, getSalixZones(this.table.getRecords()), this.minKm)) {
+            if (!SalixZone.isValidAnschlussRange(from, to, zones, this.minKm)) {
                 return this.MSG.uinfo_salix_km_anschluss();
             }
             return null;
@@ -405,13 +421,18 @@
         }
     }
 
+    @Override
+    public List<String> validate() {
+        final List<String> errors = new ArrayList<String>();
+
+        if (SalixZone.zonesAreOverlapping(this.getSalixZones(this.table.getRecords())))
+            errors.add(this.MSG.uinfo_salix_km_overlap());
+        if (SalixZone.hasGaps(this.getSalixZones(this.table.getRecords()), this.minKm, this.maxKm))
+            errors.add(this.MSG.uinfo_salix_km_has_gaps());// "Der Km-Bereich wird nicht vollst. abgedeckt.";
+        return errors;
+    }
+
     private void validateRangeOverlap() {
-        final StringBuilder builder = new StringBuilder();
-        if (SalixZone.zonesAreOverlapping(this.getSalixZones(this.table.getRecords())))
-            builder.append(this.MSG.uinfo_salix_km_overlap()).append(" ");
-        if (SalixZone.hasGaps(this.getSalixZones(this.table.getRecords()), this.minKm, this.maxKm))
-            builder.append(this.MSG.uinfo_salix_km_has_gaps());// "Der Km-Bereich wird nicht vollst. abgedeckt.";
-
-        this.validationLabel.setText(builder.toString());
+        this.validationLabel.setText(validate().toString().replace("[", "").replace("]", "").replace(",", ""));
     }
 }
\ No newline at end of file


More information about the Dive4Elements-commits mailing list