Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java @ 9108:f5b55b383ef9
VegZones Layout Nachtrag
author | gernotbelger |
---|---|
date | Tue, 29 May 2018 18:17:55 +0200 |
parents | 41f4bc83aa7a |
children | 31b3cae5de0d |
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; |
13 | |
9107 | 14 import com.smartgwt.client.util.SC; |
9064 | 15 import com.smartgwt.client.widgets.Button; |
16 import com.smartgwt.client.widgets.events.ClickEvent; | |
17 import com.smartgwt.client.widgets.events.ClickHandler; | |
18 import com.smartgwt.client.widgets.form.DynamicForm; | |
9107 | 19 import com.smartgwt.client.widgets.form.fields.TextItem; |
20 import com.smartgwt.client.widgets.grid.ListGrid; | |
9064 | 21 import com.smartgwt.client.widgets.grid.ListGridRecord; |
9107 | 22 import com.smartgwt.client.widgets.layout.Layout; |
9108 | 23 import com.smartgwt.client.widgets.layout.VLayout; |
9064 | 24 |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
25 public class VegetationzonesTableEditPanel extends AbstractVegZonesTablePanel { |
9064 | 26 private static final long serialVersionUID = 1L; |
27 | |
9107 | 28 private TextItem vegzone; |
29 | |
30 private TextItem start; | |
31 | |
32 private TextItem end; | |
33 | |
9068
a5cf8d7bff3c
access uinfo.salx; tablePanel edit/non-edit merge
gernotbelger
parents:
9066
diff
changeset
|
34 @Override |
9107 | 35 public void createWidget(final Layout root, final DataList data) { |
36 | |
37 final ListGrid elements = super.createTable(root, data, 450, true); | |
38 | |
39 this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), 200); | |
9108 | 40 this.vegzone.setColSpan(4); |
41 this.start = PanelHelper.createIntegerItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), 50); | |
42 this.end = PanelHelper.createIntegerItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), 50); | |
43 final VLayout fields = new VLayout(); | |
9064 | 44 |
45 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
|
46 |
9064 | 47 final DynamicForm form1 = new DynamicForm(); |
9108 | 48 form1.setNumCols(4); // für Layout untereinander muss 2 eingestellt werden |
49 | |
50 form1.setFields(this.vegzone, this.start, this.end); | |
9064 | 51 |
52 add.addClickHandler(new ClickHandler() { | |
53 @Override | |
54 public void onClick(final ClickEvent ce) { | |
9066 | 55 final String v1 = VegetationzonesTableEditPanel.this.start.getValueAsString(); |
56 final String v2 = VegetationzonesTableEditPanel.this.end.getValueAsString(); | |
57 final String v3 = VegetationzonesTableEditPanel.this.vegzone.getValueAsString(); | |
9107 | 58 final String message = validate(v1, v2, v3); |
59 if (message != null) { | |
60 SC.warn(message); | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
61 return; |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
62 } |
9064 | 63 |
64 final ListGridRecord r = new ListGridRecord(); | |
65 r.setAttribute("vegzone", v3); | |
66 r.setAttribute("from", v1); | |
67 r.setAttribute("to", v2); | |
9107 | 68 elements.addData(r); |
9064 | 69 } |
70 }); | |
71 | |
72 fields.addMember(form1); | |
9107 | 73 root.addMember(fields); |
74 root.addMember(PanelHelper.getSpacer(10)); | |
75 root.addMember(add); | |
76 root.addMember(PanelHelper.getSpacer(20)); | |
9064 | 77 } |
78 | |
9107 | 79 protected String validate(final String v1, final String v2, final String v3) { |
80 | |
81 if (v1 == null || v2 == null || v3 == null || v1.trim().isEmpty() || v2.trim().isEmpty() || v3.trim().isEmpty()) | |
82 return this.MSG.uinfo_vegetation_zones_validation_empty(); | |
83 | |
84 try { | |
85 final Integer from = Integer.valueOf(v1); | |
86 final Integer to = Integer.valueOf(v2); | |
87 | |
88 if (from < 0 || from > 365) | |
89 return this.MSG.uinfo_vegetation_zones_validation_range(); | |
90 | |
91 if (to < 0 || to > 365) | |
92 return this.MSG.uinfo_vegetation_zones_validation_range(); | |
93 | |
94 if (from > to) | |
95 return this.MSG.uinfo_vegetation_zones_validation_from_greater_to(); | |
96 | |
97 return null; | |
98 } | |
99 catch (final NumberFormatException e) { | |
100 return this.MSG.uinfo_vegetation_zones_invalid_integer(); | |
101 } | |
102 } | |
103 } |