changeset 9261:22a3999fd536

klasse vergessen
author gernotbelger
date Tue, 17 Jul 2018 17:51:43 +0200
parents b570b6fcc052
children fee5fa18361c
files gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java
diffstat 1 files changed, 25 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- 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

http://dive4elements.wald.intevation.org