Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/uinfo/LoadSingleEpochPanel.java @ 9066:b5d7a9d79837
uinfo.inundation_duration ui
author | gernotbelger |
---|---|
date | Fri, 11 May 2018 17:04:35 +0200 |
parents | b6919e3c2d86 |
children |
comparison
equal
deleted
inserted
replaced
9065:58af9b81a97b | 9066:b5d7a9d79837 |
---|---|
14 import org.dive4elements.river.client.client.Config; | 14 import org.dive4elements.river.client.client.Config; |
15 import org.dive4elements.river.client.client.FLYSConstants; | 15 import org.dive4elements.river.client.client.FLYSConstants; |
16 import org.dive4elements.river.client.client.services.SedimentLoadInfoService; | 16 import org.dive4elements.river.client.client.services.SedimentLoadInfoService; |
17 import org.dive4elements.river.client.client.services.SedimentLoadInfoServiceAsync; | 17 import org.dive4elements.river.client.client.services.SedimentLoadInfoServiceAsync; |
18 import org.dive4elements.river.client.client.ui.AbstractUIProvider; | 18 import org.dive4elements.river.client.client.ui.AbstractUIProvider; |
19 import org.dive4elements.river.client.client.ui.PanelHelper; | |
19 import org.dive4elements.river.client.shared.model.ArtifactDescription; | 20 import org.dive4elements.river.client.shared.model.ArtifactDescription; |
20 import org.dive4elements.river.client.shared.model.Data; | 21 import org.dive4elements.river.client.shared.model.Data; |
21 import org.dive4elements.river.client.shared.model.DataItem; | 22 import org.dive4elements.river.client.shared.model.DataItem; |
22 import org.dive4elements.river.client.shared.model.DataList; | 23 import org.dive4elements.river.client.shared.model.DataList; |
23 import org.dive4elements.river.client.shared.model.DefaultData; | 24 import org.dive4elements.river.client.shared.model.DefaultData; |
28 import com.google.gwt.core.client.GWT; | 29 import com.google.gwt.core.client.GWT; |
29 import com.google.gwt.user.client.rpc.AsyncCallback; | 30 import com.google.gwt.user.client.rpc.AsyncCallback; |
30 import com.smartgwt.client.data.Record; | 31 import com.smartgwt.client.data.Record; |
31 import com.smartgwt.client.types.ListGridFieldType; | 32 import com.smartgwt.client.types.ListGridFieldType; |
32 import com.smartgwt.client.util.SC; | 33 import com.smartgwt.client.util.SC; |
33 import com.smartgwt.client.widgets.Button; | |
34 import com.smartgwt.client.widgets.Canvas; | 34 import com.smartgwt.client.widgets.Canvas; |
35 import com.smartgwt.client.widgets.Label; | 35 import com.smartgwt.client.widgets.Label; |
36 import com.smartgwt.client.widgets.events.ClickEvent; | |
37 import com.smartgwt.client.widgets.events.ClickHandler; | |
38 import com.smartgwt.client.widgets.form.DynamicForm; | 36 import com.smartgwt.client.widgets.form.DynamicForm; |
39 import com.smartgwt.client.widgets.form.fields.TextItem; | 37 import com.smartgwt.client.widgets.form.fields.TextItem; |
40 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; | 38 import com.smartgwt.client.widgets.form.validator.IsIntegerValidator; |
41 import com.smartgwt.client.widgets.grid.ListGrid; | 39 import com.smartgwt.client.widgets.grid.ListGrid; |
42 import com.smartgwt.client.widgets.grid.ListGridField; | 40 import com.smartgwt.client.widgets.grid.ListGridField; |
43 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
44 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; | 41 import com.smartgwt.client.widgets.grid.events.RecordClickEvent; |
45 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; | 42 import com.smartgwt.client.widgets.grid.events.RecordClickHandler; |
46 import com.smartgwt.client.widgets.layout.HLayout; | 43 import com.smartgwt.client.widgets.layout.HLayout; |
47 import com.smartgwt.client.widgets.layout.VLayout; | 44 import com.smartgwt.client.widgets.layout.VLayout; |
48 | 45 |
49 public class LoadSingleEpochPanel extends AbstractUIProvider { | 46 public class LoadSingleEpochPanel extends AbstractUIProvider { |
47 private static final long serialVersionUID = 1L; | |
48 | |
50 protected SedimentLoadInfoServiceAsync sedLoadInfoService = GWT.create(SedimentLoadInfoService.class); | 49 protected SedimentLoadInfoServiceAsync sedLoadInfoService = GWT.create(SedimentLoadInfoService.class); |
51 | 50 |
52 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); | 51 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); |
53 | 52 |
54 protected ListGrid elements; | 53 protected ListGrid elements; |
57 private ListGrid sedLoadTable; | 56 private ListGrid sedLoadTable; |
58 | 57 |
59 protected List<String> validYears; | 58 protected List<String> validYears; |
60 | 59 |
61 public Canvas createWidget(final DataList data) { | 60 public Canvas createWidget(final DataList data) { |
62 final HLayout input = new HLayout(); | 61 // final HLayout input = new HLayout(); |
63 final VLayout root = new VLayout(); | 62 final VLayout root = new VLayout(); |
64 final VLayout grid = new VLayout(); | 63 // final VLayout intFields = new VLayout(); |
65 final VLayout intFields = new VLayout(); | |
66 final Button add = new Button(this.MSG.add_date()); | |
67 this.elements = new ListGrid(); | |
68 | 64 |
69 final Label title = new Label(data.get(0).getDescription()); | 65 final Label title = new Label(data.get(0).getDescription()); |
70 title.setHeight("25px"); | 66 title.setHeight("25px"); |
71 | 67 |
72 final DynamicForm form = new DynamicForm(); | 68 final DynamicForm form = new DynamicForm(); |
73 form.setNumCols(4); | 69 form.setNumCols(4); |
74 this.start = new TextItem(this.MSG.from()); | 70 this.start = new TextItem(this.MSG.from()); |
75 this.start.setWidth(60); | 71 this.start.setWidth(60); |
72 this.start.setValue(2000);// TODO: get minDate | |
73 this.start.setCanEdit(false); | |
76 this.start.setValidators(new IsIntegerValidator()); | 74 this.start.setValidators(new IsIntegerValidator()); |
77 this.end = new TextItem(this.MSG.to()); | 75 this.end = new TextItem(this.MSG.to()); |
78 this.end.setWidth(60); | 76 this.end.setWidth(60); |
79 this.end.setValidators(new IsIntegerValidator()); | 77 this.end.setValidators(new IsIntegerValidator()); |
78 this.end.setCanEdit(false); | |
79 this.end.setValue(2005);// TODO: get maxDate | |
80 form.setFields(this.start, this.end); | 80 form.setFields(this.start, this.end); |
81 add.addClickHandler(new ClickHandler() { | 81 |
82 @Override | 82 // intFields.addMember(form); |
83 public void onClick(final ClickEvent ce) { | 83 // input.addMember(intFields); |
84 final String v1 = LoadSingleEpochPanel.this.start.getValueAsString(); | |
85 final String v2 = LoadSingleEpochPanel.this.end.getValueAsString(); | |
86 if (v1 == null || v2 == null) { | |
87 return; | |
88 } | |
89 if (!isValidEpoch(v1, v2)) { | |
90 return; | |
91 } | |
92 final ListGridRecord r = new ListGridRecord(); | |
93 r.setAttribute("from", v1); | |
94 r.setAttribute("to", v2); | |
95 LoadSingleEpochPanel.this.elements.addData(r); | |
96 } | |
97 }); | |
98 | |
99 final Label sel = new Label(this.MSG.select()); | |
100 sel.setHeight(25); | |
101 this.elements.setWidth(185); | |
102 this.elements.setHeight(120); | |
103 this.elements.setShowHeaderContextMenu(false); | |
104 this.elements.setCanReorderFields(false); | |
105 this.elements.setCanSort(false); | |
106 this.elements.setCanEdit(false); | |
107 final ListGridField from = new ListGridField("from", this.MSG.from()); | |
108 final ListGridField to = new ListGridField("to", this.MSG.to()); | |
109 from.setWidth(70); | |
110 to.setWidth(70); | |
111 | |
112 final ListGridField removeField = new ListGridField("_removeRecord", "Remove Record") { | |
113 { | |
114 setType(ListGridFieldType.ICON); | |
115 setIcon(GWT.getHostPageBaseURL() + LoadSingleEpochPanel.this.MSG.removeFeature()); | |
116 setCanEdit(false); | |
117 setCanFilter(false); | |
118 setCanSort(false); | |
119 setCanGroupBy(false); | |
120 setCanFreeze(false); | |
121 setWidth(25); | |
122 } | |
123 }; | |
124 | |
125 this.elements.addRecordClickHandler(new RecordClickHandler() { | |
126 @Override | |
127 public void onRecordClick(final RecordClickEvent event) { | |
128 // Just handle remove-clicks | |
129 if (!event.getField().getName().equals(removeField.getName())) { | |
130 return; | |
131 } | |
132 event.getViewer().removeData(event.getRecord()); | |
133 } | |
134 }); | |
135 | |
136 this.elements.setFields(from, to, removeField); | |
137 | |
138 intFields.addMember(form); | |
139 intFields.addMember(add); | |
140 grid.addMember(sel); | |
141 grid.addMember(this.elements); | |
142 input.addMember(intFields); | |
143 input.addMember(grid); | |
144 root.addMember(title); | 84 root.addMember(title); |
145 root.addMember(input); | 85 root.addMember(PanelHelper.getSpacer(10)); |
86 root.addMember(form); | |
87 | |
88 // root.addMember(input); | |
146 | 89 |
147 return root; | 90 return root; |
148 } | 91 } |
149 | 92 |
150 @Override | 93 @Override |
156 final Label label = new Label(dataList.getLabel()); | 99 final Label label = new Label(dataList.getLabel()); |
157 label.setWidth("200px"); | 100 label.setWidth("200px"); |
158 label.setHeight(25); | 101 label.setHeight(25); |
159 | 102 |
160 final List<Data> items = dataList.getAll(); | 103 final List<Data> items = dataList.getAll(); |
161 final Data str = getData(items, "epochs"); | 104 final Data str = getData(items, "totalepoch"); |
162 final DataItem[] strItems = str.getItems(); | 105 final DataItem[] strItems = str.getItems(); |
163 | 106 |
164 final String[] pairs = strItems[0].getLabel().split(";"); | 107 final String[] pairs = strItems[0].getLabel().split(";"); |
165 for (final String pair : pairs) { | 108 for (final String pair : pairs) { |
166 final String[] vals = pair.split(","); | 109 final String[] vals = pair.split(","); |
192 | 135 |
193 return layout; | 136 return layout; |
194 } | 137 } |
195 | 138 |
196 private Canvas createHelper() { | 139 private Canvas createHelper() { |
197 this.sedLoadTable = new ListGrid(); | 140 this.sedLoadTable = new ListGrid(); // TODO: get minMax from right datasource |
198 this.sedLoadTable.setShowHeaderContextMenu(false); | 141 this.sedLoadTable.setShowHeaderContextMenu(false); |
199 this.sedLoadTable.setWidth100(); | 142 this.sedLoadTable.setWidth100(); |
200 this.sedLoadTable.setShowRecordComponents(true); | 143 this.sedLoadTable.setShowRecordComponents(true); |
201 this.sedLoadTable.setShowRecordComponentsByCell(true); | 144 this.sedLoadTable.setShowRecordComponentsByCell(true); |
202 this.sedLoadTable.setHeight100(); | 145 this.sedLoadTable.setHeight100(); |
217 | 160 |
218 pinFrom.addRecordClickHandler(new RecordClickHandler() { | 161 pinFrom.addRecordClickHandler(new RecordClickHandler() { |
219 @Override | 162 @Override |
220 public void onRecordClick(final RecordClickEvent e) { | 163 public void onRecordClick(final RecordClickEvent e) { |
221 final Record r = e.getRecord(); | 164 final Record r = e.getRecord(); |
222 LoadSingleEpochPanel.this.start.setValue(r.getAttribute("date")); | 165 LoadSingleEpochPanel.this.start.setValue("darf nicht geändert werden");// r.getAttribute("date")); |
223 } | 166 } |
224 }); | 167 }); |
225 | 168 |
226 pinTo.addRecordClickHandler(new RecordClickHandler() { | 169 pinTo.addRecordClickHandler(new RecordClickHandler() { |
227 @Override | 170 @Override |
228 public void onRecordClick(final RecordClickEvent e) { | 171 public void onRecordClick(final RecordClickEvent e) { |
229 final Record r = e.getRecord(); | 172 final Record r = e.getRecord(); |
230 LoadSingleEpochPanel.this.end.setValue(r.getAttribute("date")); | 173 LoadSingleEpochPanel.this.end.setValue("darf nicht geändert werden"); |
231 } | 174 } |
232 }); | 175 }); |
233 | 176 |
234 final ListGridField date = new ListGridField("date", this.MSG.year()); | 177 final ListGridField date = new ListGridField("date", this.MSG.year()); |
235 date.setType(ListGridFieldType.TEXT); | 178 date.setType(ListGridFieldType.TEXT); |
245 | 188 |
246 @Override | 189 @Override |
247 protected Data[] getData() { | 190 protected Data[] getData() { |
248 final List<Data> data = new ArrayList<Data>(); | 191 final List<Data> data = new ArrayList<Data>(); |
249 | 192 |
250 final ListGridRecord[] lgr = this.elements.getRecords(); | 193 // final ListGridRecord[] lgr = this.elements.getRecords(); |
251 if (lgr.length == 0) { | 194 // if (lgr.length == 0) { |
252 return new Data[0]; | 195 // return new Data[0]; |
253 } | 196 // } |
254 String d = ""; | 197 String d = ""; |
255 for (final ListGridRecord element : lgr) { | 198 // // for (final ListGridRecord element : lgr) { |
256 final Record r = element; | 199 // final Record r = element; |
257 d += r.getAttribute("from") + "," + r.getAttribute("to"); | 200 // d += r.getAttribute("from") + "," + r.getAttribute("to"); |
258 d += ";"; | 201 // d += ";"; |
259 } | 202 // } |
260 | 203 |
261 final DataItem item = new DefaultDataItem("epochs", null, d); | 204 d = this.start.getValueAsString() + "," + this.end.getValueAsString() + ";"; |
262 data.add(new DefaultData("epochs", null, null, new DataItem[] { item })); | 205 |
206 final DataItem item = new DefaultDataItem("totalepoch", null, d); | |
207 data.add(new DefaultData("totalepoch", null, null, new DataItem[] { item })); | |
263 return data.toArray(new Data[data.size()]); | 208 return data.toArray(new Data[data.size()]); |
264 } | 209 } |
265 | 210 |
266 protected void fetchSedimentLoadData() { | 211 protected void fetchSedimentLoadData() { |
267 final Config config = Config.getInstance(); | 212 final Config config = Config.getInstance(); |