Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixationPanel.java @ 9256:6c24c857ccf9
fixation refactoring and inputItem behaviour to interfaces
author | gernotbelger |
---|---|
date | Fri, 13 Jul 2018 12:04:21 +0200 |
parents | 9be51f776798 |
children | 1a7cfeb1ff89 |
comparison
equal
deleted
inserted
replaced
9255:9be51f776798 | 9256:6c24c857ccf9 |
---|---|
15 import org.dive4elements.river.client.client.FLYSConstants; | 15 import org.dive4elements.river.client.client.FLYSConstants; |
16 import org.dive4elements.river.client.client.services.FixingsOverviewService; | 16 import org.dive4elements.river.client.client.services.FixingsOverviewService; |
17 import org.dive4elements.river.client.client.services.FixingsOverviewServiceAsync; | 17 import org.dive4elements.river.client.client.services.FixingsOverviewServiceAsync; |
18 import org.dive4elements.river.client.client.ui.AbstractUIProvider; | 18 import org.dive4elements.river.client.client.ui.AbstractUIProvider; |
19 import org.dive4elements.river.client.shared.model.AbstractFixBunduArtifact; | 19 import org.dive4elements.river.client.shared.model.AbstractFixBunduArtifact; |
20 import org.dive4elements.river.client.shared.model.Data; | |
21 import org.dive4elements.river.client.shared.model.DataList; | 20 import org.dive4elements.river.client.shared.model.DataList; |
22 import org.dive4elements.river.client.shared.model.FixFilter; | 21 import org.dive4elements.river.client.shared.model.FixFilter; |
23 import org.dive4elements.river.client.shared.model.FixingsOverviewInfo; | 22 import org.dive4elements.river.client.shared.model.FixingsOverviewInfo; |
24 | 23 |
25 import com.google.gwt.core.client.GWT; | 24 import com.google.gwt.core.client.GWT; |
59 private static final long serialVersionUID = -3667553404493415619L; | 58 private static final long serialVersionUID = -3667553404493415619L; |
60 | 59 |
61 protected static HashMap<String, FixationPanel> instances = new HashMap<String, FixationPanel>(); | 60 protected static HashMap<String, FixationPanel> instances = new HashMap<String, FixationPanel>(); |
62 | 61 |
63 /** The message class that provides i18n strings. */ | 62 /** The message class that provides i18n strings. */ |
64 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); | 63 private final FLYSConstants MESSAGES = GWT.create(FLYSConstants.class); |
65 | 64 |
66 protected FixingsOverviewServiceAsync overviewService = GWT.create(FixingsOverviewService.class); | 65 private final FixingsOverviewServiceAsync overviewService = GWT.create(FixingsOverviewService.class); |
67 | 66 |
68 protected String htmlOverview; | 67 private String htmlOverview; |
69 protected FixingsOverviewInfo fixInfo; | 68 private FixingsOverviewInfo fixInfo; |
70 protected TabSet tabs; | 69 private TabSet tabs; |
71 protected Tab events; | 70 private Tab events; |
72 protected Tab chart; | 71 private Tab chart; |
73 protected VLayout chartContainer; | 72 private VLayout chartContainer; |
74 protected Img chartImg; | 73 private Img chartImg; |
75 protected TextItem kmText; | 74 private TextItem kmText; |
76 | 75 |
77 public static final DateTimeFormat DTF = DateTimeFormat.getFormat("dd.MM.yyyy"); | 76 private static final DateTimeFormat DTF = DateTimeFormat.getFormat("dd.MM.yyyy"); |
78 | 77 |
79 public FixationPanel() { | 78 public FixationPanel() { |
80 this.chartImg = new Img(); | 79 this.chartImg = new Img(); |
81 this.htmlOverview = ""; | 80 this.htmlOverview = ""; |
82 } | 81 } |
83 | 82 |
84 /** Get the (master) artifact UUID. */ | 83 /** Get the (master) artifact UUID. */ |
85 protected String getArtifactUuid() { | 84 private String getArtifactUuid() { |
86 return this.artifact.getUuid(); | 85 return this.artifact.getUuid(); |
87 } | 86 } |
88 | 87 |
89 protected void init() { | |
90 } | |
91 | |
92 @Override | 88 @Override |
93 public Data[] getData() { | 89 public final Canvas create(final DataList list) { |
94 return null; | |
95 } | |
96 | |
97 @Override | |
98 public Canvas create(final DataList list) { | |
99 final VLayout layout = new VLayout(); | 90 final VLayout layout = new VLayout(); |
100 | 91 |
101 final Canvas helper = createHelper(); | 92 final Canvas helper = createHelper(); |
102 this.helperContainer.addMember(helper); | 93 this.helperContainer.addMember(helper); |
103 | 94 |
107 layout.addMember(widget); | 98 layout.addMember(widget); |
108 layout.addMember(submit); | 99 layout.addMember(submit); |
109 return layout; | 100 return layout; |
110 } | 101 } |
111 | 102 |
112 @Override | 103 private Canvas createHelper() { |
113 public Canvas createOld(final DataList list) { | |
114 return new DynamicForm(); | |
115 } | |
116 | |
117 protected Canvas createHelper() { | |
118 final Config config = Config.getInstance(); | 104 final Config config = Config.getInstance(); |
119 final String locale = config.getLocale(); | 105 final String locale = config.getLocale(); |
120 | 106 |
121 this.tabs = new TabSet(); | 107 this.tabs = new TabSet(); |
122 this.events = new Tab(this.MESSAGES.events()); | 108 this.events = new Tab(this.MESSAGES.events()); |
132 layout.setAlign(Alignment.CENTER); | 118 layout.setAlign(Alignment.CENTER); |
133 this.chart.setPane(layout); | 119 this.chart.setPane(layout); |
134 | 120 |
135 final HTMLPane eventPane = new HTMLPane(); | 121 final HTMLPane eventPane = new HTMLPane(); |
136 | 122 |
137 final String river = this.artifact.getArtifactDescription().getRiver(); | 123 // final String river = this.artifact.getArtifactDescription().getRiver(); |
138 createCallback(); | 124 createCallback(); |
139 | 125 |
140 final String callBack = "fixationCallback(this.checked, this.name)"; | 126 final String callBack = "fixationCallback(this.checked, this.name)"; |
141 | 127 |
142 if (this.artifact instanceof AbstractFixBunduArtifact == false) | 128 if (this.artifact instanceof AbstractFixBunduArtifact == false) |
175 } | 161 } |
176 } | 162 } |
177 eventPane.setContents(FixationPanel.this.htmlOverview); | 163 eventPane.setContents(FixationPanel.this.htmlOverview); |
178 updateChartTab(FixationPanel.this.fixInfo.getLowerKm()); | 164 updateChartTab(FixationPanel.this.fixInfo.getLowerKm()); |
179 FixationPanel.this.events.setPane(eventPane); | 165 FixationPanel.this.events.setPane(eventPane); |
180 success(); | 166 success(FixationPanel.this.fixInfo); |
181 } | 167 } |
182 }); | 168 }); |
183 | 169 |
184 this.tabs.addTab(this.events); | 170 this.tabs.addTab(this.events); |
185 this.tabs.addTab(this.chart); | 171 this.tabs.addTab(this.chart); |
186 | 172 |
187 return this.tabs; | 173 return this.tabs; |
188 } | 174 } |
189 | 175 |
190 protected Canvas createChartHelper() { | 176 private Canvas createChartHelper() { |
191 final DynamicForm form = new DynamicForm(); | 177 final DynamicForm form = new DynamicForm(); |
192 final Button lower = new Button("<<"); | 178 final Button lower = new Button("<<"); |
193 lower.setWidth(30); | 179 lower.setWidth(30); |
194 final Button upper = new Button(">>"); | 180 final Button upper = new Button(">>"); |
195 upper.setWidth(30); | 181 upper.setWidth(30); |
253 layout.addMember(form); | 239 layout.addMember(form); |
254 layout.addMember(upper); | 240 layout.addMember(upper); |
255 return layout; | 241 return layout; |
256 } | 242 } |
257 | 243 |
258 protected void updateChartTab(double km) { | 244 private void updateChartTab(double km) { |
259 final Config config = Config.getInstance(); | 245 final Config config = Config.getInstance(); |
260 final String locale = config.getLocale(); | 246 final String locale = config.getLocale(); |
261 | 247 |
262 final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; | 248 final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; |
263 | 249 |
300 this.chartImg = new Img(imgUrl, hWidth, hHeight); | 286 this.chartImg = new Img(imgUrl, hWidth, hHeight); |
301 this.chartContainer.addMember(this.chartImg); | 287 this.chartContainer.addMember(this.chartImg); |
302 } | 288 } |
303 } | 289 } |
304 | 290 |
305 protected FixFilter updateChartTabLow() { | 291 private FixFilter updateChartTabLow() { |
306 final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; | 292 final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; |
307 | 293 |
308 final FixFilter filter = art.getFilter(); | 294 final FixFilter filter = art.getFilter(); |
309 | 295 |
310 final double curr = filter.getCurrentKm(); | 296 final double curr = filter.getCurrentKm(); |
314 updateChartTab(((double) round) / 10); | 300 updateChartTab(((double) round) / 10); |
315 } | 301 } |
316 return filter; | 302 return filter; |
317 } | 303 } |
318 | 304 |
319 protected FixFilter updateChartTabUp() { | 305 private FixFilter updateChartTabUp() { |
320 final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; | 306 final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; |
321 | 307 |
322 final FixFilter filter = art.getFilter(); | 308 final FixFilter filter = art.getFilter(); |
323 | 309 |
324 final double curr = filter.getCurrentKm(); | 310 final double curr = filter.getCurrentKm(); |
329 } | 315 } |
330 return filter; | 316 return filter; |
331 } | 317 } |
332 | 318 |
333 @Override | 319 @Override |
334 public void onResized(final ResizedEvent re) { | 320 public final void onResized(final ResizedEvent re) { |
335 final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; | 321 final AbstractFixBunduArtifact art = (AbstractFixBunduArtifact) this.artifact; |
336 | 322 |
337 updateChartTab(art.getFilter().getCurrentKm()); | 323 updateChartTab(art.getFilter().getCurrentKm()); |
338 } | 324 } |
339 | 325 |
354 | 340 |
355 private static FixationPanel getInstance(final String uuid) { | 341 private static FixationPanel getInstance(final String uuid) { |
356 return instances.get(uuid); | 342 return instances.get(uuid); |
357 } | 343 } |
358 | 344 |
359 public abstract Canvas createWidget(DataList data); | 345 protected abstract Canvas createWidget(DataList data); |
360 | 346 |
361 public abstract void setValues(String cid, boolean checked); | 347 protected abstract void setValues(String cid, boolean checked); |
362 | 348 |
363 public abstract boolean renderCheckboxes(); | 349 protected abstract boolean renderCheckboxes(); |
364 | 350 |
365 public abstract void success(); | 351 protected abstract void success(FixingsOverviewInfo fixInfo); |
366 | 352 |
367 /** Creates JSON string from filter. */ | 353 /** Creates JSON string from filter. */ |
368 public static String getOverviewFilter(final FixFilter filter) { | 354 private static String getOverviewFilter(final FixFilter filter) { |
369 final String river = filter.getRiver(); | 355 final String river = filter.getRiver(); |
370 | 356 |
371 if (river != null && river.length() > 0) { | 357 if (river != null && river.length() > 0) { |
372 final JSONObject jfix = new JSONObject(); | 358 final JSONObject jfix = new JSONObject(); |
373 final JSONObject jfilter = new JSONObject(); | 359 final JSONObject jfilter = new JSONObject(); |
379 return jfix.toString(); | 365 return jfix.toString(); |
380 } | 366 } |
381 return ""; | 367 return ""; |
382 } | 368 } |
383 | 369 |
384 public String getChartFilter(final FixFilter filter, final int width, final int height) { | 370 private String getChartFilter(final FixFilter filter, final int width, final int height) { |
385 final String river = filter.getRiver(); | 371 final String river = filter.getRiver(); |
386 final double currentKm = filter.getCurrentKm(); | 372 final double currentKm = filter.getCurrentKm(); |
387 final double fromKm = filter.getLowerKm(); | 373 final double fromKm = filter.getLowerKm(); |
388 final double toKm = filter.getUpperKm(); | 374 final double toKm = filter.getUpperKm(); |
389 | 375 |
409 return jfix.toString(); | 395 return jfix.toString(); |
410 } | 396 } |
411 return ""; | 397 return ""; |
412 } | 398 } |
413 | 399 |
414 protected static JSONObject createFilter(final FixFilter filter, final JSONObject root) { | 400 private static JSONObject createFilter(final FixFilter filter, final JSONObject root) { |
415 final double fromKm = filter.getLowerKm(); | 401 final double fromKm = filter.getLowerKm(); |
416 final double toKm = filter.getUpperKm(); | 402 final double toKm = filter.getUpperKm(); |
417 final boolean hasDate = filter.hasDate(); | 403 final boolean hasDate = filter.hasDate(); |
418 | 404 |
419 if (fromKm >= 0 && toKm >= 0 && fromKm <= toKm) { | 405 if (fromKm >= 0 && toKm >= 0 && fromKm <= toKm) { |
476 root.put("filter", jFilter); | 462 root.put("filter", jFilter); |
477 } | 463 } |
478 return root; | 464 return root; |
479 } | 465 } |
480 } | 466 } |
481 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |