changeset 9239:4e3757202d5c

salix.supraregional better error- + advance-handling
author gernotbelger
date Tue, 10 Jul 2018 14:45:40 +0200
parents 1c756bfee472
children 54173301bc34
files gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.java gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/SupraRegionalTablePanel.java
diffstat 4 files changed, 37 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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 
 
--- 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
 
--- 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 @@
         }
     }
 
-    private void validateRangeOverlap() {
-        final StringBuilder builder = new StringBuilder();
+    @Override
+    public List<String> validate() {
+        final List<String> errors = new ArrayList<String>();
+
         if (SalixZone.zonesAreOverlapping(this.getSalixZones(this.table.getRecords())))
-            builder.append(this.MSG.uinfo_salix_km_overlap()).append(" ");
+            errors.add(this.MSG.uinfo_salix_km_overlap());
         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.";
+            errors.add(this.MSG.uinfo_salix_km_has_gaps());// "Der Km-Bereich wird nicht vollst. abgedeckt.";
+        return errors;
+    }
 
-        this.validationLabel.setText(builder.toString());
+    private void validateRangeOverlap() {
+        this.validationLabel.setText(validate().toString().replace("[", "").replace("]", "").replace(",", ""));
     }
 }
\ No newline at end of file

http://dive4elements.wald.intevation.org