Mercurial > dive4elements > river
annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/VegetationzonesTableEditPanel.java @ 9329:6a7758923762
Fixed: gwt code did not compile due to ternary operator
author | gernotbelger |
---|---|
date | Fri, 27 Jul 2018 16:19:09 +0200 |
parents | 4a6cc7c6716a |
children | e2da9c8a7c57 |
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; |
9299 | 19 import com.smartgwt.client.widgets.Canvas; |
9064 | 20 import com.smartgwt.client.widgets.form.DynamicForm; |
9261 | 21 import com.smartgwt.client.widgets.form.fields.ColorItem; |
9107 | 22 import com.smartgwt.client.widgets.form.fields.TextItem; |
23 import com.smartgwt.client.widgets.grid.ListGrid; | |
9064 | 24 import com.smartgwt.client.widgets.grid.ListGridRecord; |
9107 | 25 import com.smartgwt.client.widgets.layout.Layout; |
9108 | 26 import com.smartgwt.client.widgets.layout.VLayout; |
9064 | 27 |
9070
611a523fc42f
VegetationZoneAccessHelper, VegetationTablePanels verbessert
gernotbelger
parents:
9069
diff
changeset
|
28 public class VegetationzonesTableEditPanel extends AbstractVegZonesTablePanel { |
9064 | 29 private static final long serialVersionUID = 1L; |
30 | |
9107 | 31 private TextItem vegzone; |
32 | |
33 private TextItem start; | |
34 | |
35 private TextItem end; | |
36 | |
9068
a5cf8d7bff3c
access uinfo.salx; tablePanel edit/non-edit merge
gernotbelger
parents:
9066
diff
changeset
|
37 @Override |
9107 | 38 public void createWidget(final Layout root, final DataList data) { |
39 | |
9261 | 40 final ListGrid elements = super.createTable(root, data, "420", true); |
9107 | 41 |
9261 | 42 this.vegzone = PanelHelper.createItem("uinfo_vegetation_zone_label", this.MSG.uinfo_vegetation_zone_label(), "*"); |
9108 | 43 this.vegzone.setColSpan(4); |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9114
diff
changeset
|
44 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
|
45 this.end = PanelHelper.createIntegerItem("uinfo_vegetation_zones_to", this.MSG.uinfo_vegetation_zones_to(), "*"); |
9108 | 46 final VLayout fields = new VLayout(); |
9064 | 47 |
9261 | 48 final ColorItem colorPicker = new ColorItem(); |
49 colorPicker.setTitle(this.MSG.uinfo_vegetation_zone_color()); | |
50 | |
51 colorPicker.setShowTitle(true); | |
52 colorPicker.setShowValueIconOnly(false); | |
53 colorPicker.setShowPickerIcon(true); | |
54 colorPicker.setColSpan(2); | |
55 colorPicker.setWidth(110); | |
56 | |
9064 | 57 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
|
58 |
9064 | 59 final DynamicForm form1 = new DynamicForm(); |
9118
431f1c269be5
Veg-Zone Table improved, State change data recovery;
gernotbelger
parents:
9114
diff
changeset
|
60 |
9108 | 61 form1.setNumCols(4); // für Layout untereinander muss 2 eingestellt werden |
9261 | 62 if (VegetationZone.HAS_COLORS_EDITABLE) |
63 form1.setFields(this.vegzone, this.start, this.end, colorPicker); | |
64 else | |
65 form1.setFields(this.vegzone, this.start, this.end); | |
9064 | 66 |
67 add.addClickHandler(new ClickHandler() { | |
68 @Override | |
69 public void onClick(final ClickEvent ce) { | |
9066 | 70 final String v1 = VegetationzonesTableEditPanel.this.start.getValueAsString(); |
71 final String v2 = VegetationzonesTableEditPanel.this.end.getValueAsString(); | |
72 final String v3 = VegetationzonesTableEditPanel.this.vegzone.getValueAsString(); | |
9329
6a7758923762
Fixed: gwt code did not compile due to ternary operator
gernotbelger
parents:
9299
diff
changeset
|
73 |
6a7758923762
Fixed: gwt code did not compile due to ternary operator
gernotbelger
parents:
9299
diff
changeset
|
74 // REMARK: can't use 'ternary operator' here, becuae gwt (or java 6?) doesnt like it. |
6a7758923762
Fixed: gwt code did not compile due to ternary operator
gernotbelger
parents:
9299
diff
changeset
|
75 final String v4; |
6a7758923762
Fixed: gwt code did not compile due to ternary operator
gernotbelger
parents:
9299
diff
changeset
|
76 if (VegetationZone.HAS_COLORS_EDITABLE) |
6a7758923762
Fixed: gwt code did not compile due to ternary operator
gernotbelger
parents:
9299
diff
changeset
|
77 v4 = colorPicker.getValueAsString(); |
6a7758923762
Fixed: gwt code did not compile due to ternary operator
gernotbelger
parents:
9299
diff
changeset
|
78 else |
6a7758923762
Fixed: gwt code did not compile due to ternary operator
gernotbelger
parents:
9299
diff
changeset
|
79 v4 = "#ffffff"; |
6a7758923762
Fixed: gwt code did not compile due to ternary operator
gernotbelger
parents:
9299
diff
changeset
|
80 |
9261 | 81 final String message = validate(v1, v2, v3, v4); |
9107 | 82 if (message != null) { |
83 SC.warn(message); | |
9069
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
84 return; |
1ffd38826175
access uinfo.vegetationzones+inundation_duration
gernotbelger
parents:
9068
diff
changeset
|
85 } |
9064 | 86 |
87 final ListGridRecord r = new ListGridRecord(); | |
88 r.setAttribute("vegzone", v3); | |
89 r.setAttribute("from", v1); | |
90 r.setAttribute("to", v2); | |
9261 | 91 r.setAttribute("color", v4); |
9107 | 92 elements.addData(r); |
9299 | 93 updateValidationMsgLabel(); |
9114 | 94 final String sortField = elements.getSortField(); |
95 if (sortField != null) { | |
96 elements.toggleSort(sortField); | |
97 elements.toggleSort(sortField); // HACK. has to be. otherwise normalizer won't be called :-( | |
98 } | |
9064 | 99 } |
100 }); | |
101 | |
102 fields.addMember(form1); | |
9107 | 103 root.addMember(fields); |
104 root.addMember(PanelHelper.getSpacer(10)); | |
105 root.addMember(add); | |
9299 | 106 } |
9261 | 107 |
9299 | 108 @Override |
109 protected Canvas createHelper(final DataList data) { | |
110 return null; | |
9064 | 111 } |
112 | |
9107 | 113 } |