[PATCH] klasse vergessen

Wald Commits scm-commit at wald.intevation.org
Tue Jul 17 17:51:49 CEST 2018


# HG changeset patch
# User gernotbelger
# Date 1531842703 -7200
# Node ID 22a3999fd536f0f8abd9aa7e4ed9302251b6f262
# Parent  b570b6fcc052e3eda222f92cc71967b73a113f23
klasse vergessen

diff -r b570b6fcc052 -r 22a3999fd536 gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java	Tue Jul 17 10:59:27 2018 +0200
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java	Tue Jul 17 17:51:43 2018 +0200
@@ -10,12 +10,14 @@
 
 import org.dive4elements.river.client.client.ui.PanelHelper;
 import org.dive4elements.river.client.shared.model.DataList;
+import org.dive4elements.river.client.shared.model.VegetationZone;
 
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.user.client.ui.Button;
 import com.smartgwt.client.util.SC;
-import com.smartgwt.client.widgets.Button;
-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.ColorItem;
 import com.smartgwt.client.widgets.form.fields.TextItem;
 import com.smartgwt.client.widgets.grid.ListGrid;
 import com.smartgwt.client.widgets.grid.ListGridRecord;
@@ -34,21 +36,32 @@
     @Override
     public void createWidget(final Layout root, final DataList data) {
 
-        final ListGrid elements = super.createTable(root, data, "450", true);
+        final ListGrid elements = super.createTable(root, data, "420", true);
 
-        this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), "*");// 450);
+        this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), "*");
         this.vegzone.setColSpan(4);
         this.start = PanelHelper.createIntegerItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), "*");
         this.end = PanelHelper.createIntegerItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), "*");
         final VLayout fields = new VLayout();
 
+        final ColorItem colorPicker = new ColorItem();
+        colorPicker.setTitle(this.MSG.uinfo_vegetation_zone_color());
+
+        colorPicker.setShowTitle(true);
+        colorPicker.setShowValueIconOnly(false);
+        colorPicker.setShowPickerIcon(true);
+        colorPicker.setColSpan(2);
+        colorPicker.setWidth(110);
+
         final Button add = new Button(this.MSG.add_date()); // TODO: make key more generic or change to more specific
 
         final DynamicForm form1 = new DynamicForm();
 
         form1.setNumCols(4); // für Layout untereinander muss 2 eingestellt werden
-
-        form1.setFields(this.vegzone, this.start, this.end);
+        if (VegetationZone.HAS_COLORS_EDITABLE)
+            form1.setFields(this.vegzone, this.start, this.end, colorPicker);
+        else
+            form1.setFields(this.vegzone, this.start, this.end);
 
         add.addClickHandler(new ClickHandler() {
             @Override
@@ -56,7 +69,8 @@
                 final String v1 = VegetationzonesTableEditPanel.this.start.getValueAsString();
                 final String v2 = VegetationzonesTableEditPanel.this.end.getValueAsString();
                 final String v3 = VegetationzonesTableEditPanel.this.vegzone.getValueAsString();
-                final String message = validate(v1, v2, v3);
+                final String v4 = VegetationZone.HAS_COLORS_EDITABLE ? colorPicker.getValueAsString() : "#ffffff";
+                final String message = validate(v1, v2, v3, v4);
                 if (message != null) {
                     SC.warn(message);
                     return;
@@ -66,7 +80,9 @@
                 r.setAttribute("vegzone", v3);
                 r.setAttribute("from", v1);
                 r.setAttribute("to", v2);
+                r.setAttribute("color", v4);
                 elements.addData(r);
+                validateRangeOverlap();
                 final String sortField = elements.getSortField();
                 if (sortField != null) {
                     elements.toggleSort(sortField);
@@ -80,31 +96,7 @@
         root.addMember(fields);
         root.addMember(PanelHelper.getSpacer(10));
         root.addMember(add);
-        root.addMember(PanelHelper.getSpacer(20));
+
     }
 
-    protected String validate(final String v1, final String v2, final String v3) {
-
-        if (v1 == null || v2 == null || v3 == null || v1.trim().isEmpty() || v2.trim().isEmpty() || v3.trim().isEmpty())
-            return this.MSG.uinfo_vegetation_zones_validation_empty();
-
-        try {
-            final Integer from = Integer.valueOf(v1);
-            final Integer to = Integer.valueOf(v2);
-
-            if (from < 0 || from > 365)
-                return this.MSG.uinfo_vegetation_zones_validation_range();
-
-            if (to < 0 || to > 365)
-                return this.MSG.uinfo_vegetation_zones_validation_range();
-
-            if (from > to)
-                return this.MSG.uinfo_vegetation_zones_validation_from_greater_to();
-
-            return null;
-        }
-        catch (final NumberFormatException e) {
-            return this.MSG.uinfo_vegetation_zones_invalid_integer();
-        }
-    }
 }
\ No newline at end of file


More information about the Dive4Elements-commits mailing list