Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java @ 9107:41f4bc83aa7a
vegzones improved
author | gernotbelger |
---|---|
date | Tue, 29 May 2018 15:19:03 +0200 |
parents | 611a523fc42f |
children | f5b55b383ef9 |
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; |
22 import com.smartgwt.client.widgets.layout.HLayout; | |
9107 | 23 import com.smartgwt.client.widgets.layout.Layout; |
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); | |
40 this.start = PanelHelper.createIntegerItem("uinfo_vegetation_zones_from", this.MSG.uinfo_vegetation_zones_from(), 40); | |
41 this.end = PanelHelper.createIntegerItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), 40); | |
9064 | 42 final HLayout fields = new HLayout(); |
43 final HLayout fields2 = new HLayout(); | |
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(); |
48 final DynamicForm form2 = new DynamicForm(); | |
49 form2.setNumCols(5); | |
50 form1.setNumCols(7); | |
51 form1.setFields(this.vegzone); | |
52 form2.setFields(this.start, this.end); | |
53 | |
54 add.addClickHandler(new ClickHandler() { | |
55 @Override | |
56 public void onClick(final ClickEvent ce) { | |
9066 | 57 final String v1 = VegetationzonesTableEditPanel.this.start.getValueAsString(); |
58 final String v2 = VegetationzonesTableEditPanel.this.end.getValueAsString(); | |
59 final String v3 = VegetationzonesTableEditPanel.this.vegzone.getValueAsString(); | |
9107 | 60 final String message = validate(v1, v2, v3); |
61 if (message != null) { | |
62 SC.warn(message); | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
63 return; |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
64 } |
9064 | 65 |
66 final ListGridRecord r = new ListGridRecord(); | |
67 r.setAttribute("vegzone", v3); | |
68 r.setAttribute("from", v1); | |
69 r.setAttribute("to", v2); | |
9107 | 70 elements.addData(r); |
9064 | 71 } |
72 }); | |
73 | |
74 fields.addMember(form1); | |
75 fields2.addMember(form2); | |
76 | |
9107 | 77 root.addMember(fields); |
78 root.addMember(fields2); | |
79 root.addMember(PanelHelper.getSpacer(10)); | |
80 root.addMember(add); | |
81 root.addMember(PanelHelper.getSpacer(20)); | |
9064 | 82 } |
83 | |
9107 | 84 protected String validate(final String v1, final String v2, final String v3) { |
85 | |
86 if (v1 == null || v2 == null || v3 == null || v1.trim().isEmpty() || v2.trim().isEmpty() || v3.trim().isEmpty()) | |
87 return this.MSG.uinfo_vegetation_zones_validation_empty(); | |
88 | |
89 try { | |
90 final Integer from = Integer.valueOf(v1); | |
91 final Integer to = Integer.valueOf(v2); | |
92 | |
93 if (from < 0 || from > 365) | |
94 return this.MSG.uinfo_vegetation_zones_validation_range(); | |
95 | |
96 if (to < 0 || to > 365) | |
97 return this.MSG.uinfo_vegetation_zones_validation_range(); | |
98 | |
99 if (from > to) | |
100 return this.MSG.uinfo_vegetation_zones_validation_from_greater_to(); | |
101 | |
102 return null; | |
103 } | |
104 catch (final NumberFormatException e) { | |
105 return this.MSG.uinfo_vegetation_zones_invalid_integer(); | |
106 } | |
107 } | |
108 } |