Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java @ 9261:22a3999fd536
klasse vergessen
author | gernotbelger |
---|---|
date | Tue, 17 Jul 2018 17:51:43 +0200 |
parents | 431f1c269be5 |
children | 4a6cc7c6716a |
rev | line source |
---|---|
9064 | 1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by Intevation GmbH | |
3 * | |
4 * This file is Free Software under the GNU AGPL (>=v3) | |
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
6 * documentation coming with Dive4Elements River for details. | |
7 */ | |
8 | |
9 package org.dive4elements.river.client.client.ui.uinfo; | |
10 | |
9066 | 11 import org.dive4elements.river.client.client.ui.PanelHelper; |
9064 | 12 import org.dive4elements.river.client.shared.model.DataList; |
9261 | 13 import org.dive4elements.river.client.shared.model.VegetationZone; |
9064 | 14 |
9261 | 15 import com.google.gwt.event.dom.client.ClickEvent; |
16 import com.google.gwt.event.dom.client.ClickHandler; | |
17 import com.google.gwt.user.client.ui.Button; | |
9107 | 18 import com.smartgwt.client.util.SC; |
9064 | 19 import com.smartgwt.client.widgets.form.DynamicForm; |
9261 | 20 import com.smartgwt.client.widgets.form.fields.ColorItem; |
9107 | 21 import com.smartgwt.client.widgets.form.fields.TextItem; |
22 import com.smartgwt.client.widgets.grid.ListGrid; | |
9064 | 23 import com.smartgwt.client.widgets.grid.ListGridRecord; |
9107 | 24 import com.smartgwt.client.widgets.layout.Layout; |
9108 | 25 import com.smartgwt.client.widgets.layout.VLayout; |
9064 | 26 |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
27 public class VegetationzonesTableEditPanel extends AbstractVegZonesTablePanel { |
9064 | 28 private static final long serialVersionUID = 1L; |
29 | |
9107 | 30 private TextItem vegzone; |
31 | |
32 private TextItem start; | |
33 | |
34 private TextItem end; | |
35 | |
9068
a5cf8d7bff3c
access uinfo.salx; tablePanel edit/non-edit merge
gernotbelger
parents:
9066
diff
changeset
|
36 @Override |
9107 | 37 public void createWidget(final Layout root, final DataList data) { |
38 | |
9261 | 39 final ListGrid elements = super.createTable(root, data, "420", true); |
9107 | 40 |
9261 | 41 this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), "*"); |
9108 | 42 this.vegzone.setColSpan(4); |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9114
diff
changeset
|
43 this.start = PanelHelper.createIntegerItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), "*"); |
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9114
diff
changeset
|
44 this.end = PanelHelper.createIntegerItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), "*"); |
9108 | 45 final VLayout fields = new VLayout(); |
9064 | 46 |
9261 | 47 final ColorItem colorPicker = new ColorItem(); |
48 colorPicker.setTitle(this.MSG.uinfo_vegetation_zone_color()); | |
49 | |
50 colorPicker.setShowTitle(true); | |
51 colorPicker.setShowValueIconOnly(false); | |
52 colorPicker.setShowPickerIcon(true); | |
53 colorPicker.setColSpan(2); | |
54 colorPicker.setWidth(110); | |
55 | |
9064 | 56 final Button add = new Button(this.MSG.add_date()); // TODO: make key more generic or change to more specific |
9068
a5cf8d7bff3c
access uinfo.salx; tablePanel edit/non-edit merge
gernotbelger
parents:
9066
diff
changeset
|
57 |
9064 | 58 final DynamicForm form1 = new DynamicForm(); |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9114
diff
changeset
|
59 |
9108 | 60 form1.setNumCols(4); // für Layout untereinander muss 2 eingestellt werden |
9261 | 61 if (VegetationZone.HAS_COLORS_EDITABLE) |
62 form1.setFields(this.vegzone, this.start, this.end, colorPicker); | |
63 else | |
64 form1.setFields(this.vegzone, this.start, this.end); | |
9064 | 65 |
66 add.addClickHandler(new ClickHandler() { | |
67 @Override | |
68 public void onClick(final ClickEvent ce) { | |
9066 | 69 final String v1 = VegetationzonesTableEditPanel.this.start.getValueAsString(); |
70 final String v2 = VegetationzonesTableEditPanel.this.end.getValueAsString(); | |
71 final String v3 = VegetationzonesTableEditPanel.this.vegzone.getValueAsString(); | |
9261 | 72 final String v4 = VegetationZone.HAS_COLORS_EDITABLE ? colorPicker.getValueAsString() : "#ffffff"; |
73 final String message = validate(v1, v2, v3, v4); | |
9107 | 74 if (message != null) { |
75 SC.warn(message); | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
76 return; |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
77 } |
9064 | 78 |
79 final ListGridRecord r = new ListGridRecord(); | |
80 r.setAttribute("vegzone", v3); | |
81 r.setAttribute("from", v1); | |
82 r.setAttribute("to", v2); | |
9261 | 83 r.setAttribute("color", v4); |
9107 | 84 elements.addData(r); |
9261 | 85 validateRangeOverlap(); |
9114 | 86 final String sortField = elements.getSortField(); |
87 if (sortField != null) { | |
88 elements.toggleSort(sortField); | |
89 elements.toggleSort(sortField); // HACK. has to be. otherwise normalizer won't be called :-( | |
90 } | |
9064 | 91 } |
92 }); | |
93 | |
94 fields.addMember(form1); | |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9114
diff
changeset
|
95 |
9107 | 96 root.addMember(fields); |
97 root.addMember(PanelHelper.getSpacer(10)); | |
98 root.addMember(add); | |
9261 | 99 |
9064 | 100 } |
101 | |
9107 | 102 } |