annotate gwt-client/src/main/java/org/dive4elements/river/client/client/ui/fixation/FixPeriodPanel.java @ 8856:5e38e2924c07 3.2.x

Fix code style.
author Tom Gottfried <tom@intevation.de>
date Thu, 18 Jan 2018 20:12:01 +0100
parents 5b87aaac8447
children 6c24c857ccf9
rev   line source
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
2 * Software engineering by Intevation GmbH
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
3 *
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
4 * This file is Free Software under the GNU AGPL (>=v3)
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
5993
ea9eef426962 Removed trailing whitespace.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5861
diff changeset
6 * documentation coming with Dive4Elements River for details.
5861
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
7 */
172338b1407f GWT client: Added copyright header.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5838
diff changeset
8
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
9 package org.dive4elements.river.client.client.ui.fixation;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
10
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
11 import com.google.gwt.core.client.GWT;
2537
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
12 import com.google.gwt.i18n.client.DateTimeFormat;
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
13
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 import com.smartgwt.client.util.SC;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import com.smartgwt.client.widgets.Canvas;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import com.smartgwt.client.widgets.Label;
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
17 import com.smartgwt.client.widgets.form.DynamicForm;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
18 import com.smartgwt.client.widgets.form.fields.DateRangeItem;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 import com.smartgwt.client.widgets.layout.HLayout;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 import com.smartgwt.client.widgets.layout.VLayout;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
21
5835
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
22 import org.dive4elements.river.client.client.FLYSConstants;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
23 import org.dive4elements.river.client.shared.model.Data;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
24 import org.dive4elements.river.client.shared.model.DataItem;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
25 import org.dive4elements.river.client.shared.model.DataList;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
26 import org.dive4elements.river.client.shared.model.DefaultData;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
27 import org.dive4elements.river.client.shared.model.DefaultDataItem;
821a02bbfb4e Fixed internal java dependencies
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5834
diff changeset
28 import org.dive4elements.river.client.shared.model.FixingsOverviewInfo.FixEvent;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
30 import java.util.ArrayList;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
31 import java.util.Date;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
32 import java.util.List;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
33
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 /**
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
35 * This UIProvider creates a panel for location or distance input.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
36 *
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 * @author <a href="mailto:raimund.renkert@intevation.de">Raimund Renkert</a>
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 */
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39 public class FixPeriodPanel
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 extends FixationPanel
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42 /** The message class that provides i18n strings. */
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
43 protected FLYSConstants MESSAGES = GWT.create(FLYSConstants.class);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
44
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 DateRangeItem inputPanel;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
47 long start;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
48 long end;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
49
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
50 protected String startName;
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
51 protected String endName;
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
52
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 public FixPeriodPanel() {
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
54 this("start", "end");
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
55 }
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
56
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
57 public FixPeriodPanel(String startName, String endName) {
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
58 this.startName = startName;
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
59 this.endName = endName;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 htmlOverview = "";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
62
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
63 @Override
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 public Canvas createWidget(DataList data) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 instances.put(this.artifact.getUuid(), this);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 VLayout layout = new VLayout();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68
2537
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
69 Label title = new Label(data.get(0).getDescription());
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 title.setHeight("25px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 DynamicForm form = new DynamicForm();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 inputPanel = new DateRangeItem();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 inputPanel.setToTitle(MESSAGES.to());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 inputPanel.setFromTitle(MESSAGES.from());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 inputPanel.setShowTitle(false);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77 form.setFields(inputPanel);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 layout.addMember(title);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 layout.addMember(form);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
82 return layout;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
83 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86 public Canvas createOld(DataList dataList) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
87 List<Data> items = dataList.getAll();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
88
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
89 Data start = getData(items, startName);
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
90 Data end = getData(items, endName);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
91 DataItem[] startItem = start.getItems();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
92 DataItem[] endItem = end.getItems();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
93
2537
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
94 String v1 = startItem[0].getStringValue();
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
95 String v2 = endItem[0].getStringValue();
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
96
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
97 long v1l = 0;
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
98 long v2l = 0;
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
99 try {
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
100 v1l = Long.parseLong(v1);
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
101 v2l = Long.parseLong(v2);
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
102 }
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
103 catch(NumberFormatException nfe) {
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
104 GWT.log(nfe.toString());
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
105 }
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
106 Date d1 = new Date(v1l);
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
107 Date d2 = new Date(v2l);
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
108
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
109 DateTimeFormat f =
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
110 DateTimeFormat.getFormat(
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
111 DateTimeFormat.PredefinedFormat.DATE_MEDIUM);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 StringBuilder sb = new StringBuilder();
2537
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
113 sb.append(f.format(d1) + " - ");
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
114 sb.append(f.format(d2));
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116 Label old = new Label(sb.toString());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 old.setWidth(130);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119 HLayout layout = new HLayout();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 layout.setWidth("400px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 Label label = new Label(dataList.getLabel());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 label.setWidth("200px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 Canvas back = getBackButton(dataList.getState());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
126
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
127 layout.addMember(label);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 layout.addMember(old);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 layout.addMember(back);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 return layout;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 /**
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 * This method returns the selected data.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 *
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 * @return the selected/inserted data.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 */
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
140 @Override
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
141 public Data[] getData() {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
142 List<Data> data = new ArrayList<Data>();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
143
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 boolean valid = saveDateValues();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 if(valid) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 String start = Long.valueOf(this.start).toString();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 String end = Long.valueOf(this.end).toString();
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8256
diff changeset
148 DataItem startItem = new DefaultDataItem(
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8256
diff changeset
149 startName, startName, start);
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
150 DataItem endItem = new DefaultDataItem(endName, endName, end);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 data.add(new DefaultData(
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
152 startName,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 null,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154 null,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
155 new DataItem[] { startItem }));
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
156 data.add(new DefaultData(
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
157 endName,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158 null,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159 null,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 new DataItem[] { endItem }));
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
161 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162
3379
0de61fc9d281 Removed some superfluous casts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2892
diff changeset
163 return data.toArray(new Data[data.size()]);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
164 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 public void setValues(String cid, boolean checked) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 // No user interaction, do nothing.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
171
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
172
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
173 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
174 public boolean renderCheckboxes() {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
175 // No selection, return false.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
176 return false;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
177 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
178
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
179 @Override
2886
bd16493cc0da Set initial values for start and end date in fix analysis date panels.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2884
diff changeset
180 public void success() {
bd16493cc0da Set initial values for start and end date in fix analysis date panels.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2884
diff changeset
181 List<FixEvent> list = fixInfo.getEvents();
2892
ad013995e410 Fixed creation of initial date string in fixings parameters.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2886
diff changeset
182
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
183 // The date in FixEvent is always "de" locale, so it seems...
7838
c023f19a7720 Bring date format on par with server format. Hopefully fixes flys/issue1445.
Sascha L. Teichmann <teichmann@intevation.de>
parents: 5993
diff changeset
184 DateTimeFormat df = DateTimeFormat.getFormat("dd.MM.yyyy");
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
185
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
186 if (!setFromAndToDate(list, df)) {
8856
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8256
diff changeset
187 GWT.log("FixPeriodPanel::success(): could not set "
5e38e2924c07 Fix code style.
Tom Gottfried <tom@intevation.de>
parents: 8256
diff changeset
188 + "from and to dates!");
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
189 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
190 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
191
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
192 protected boolean setFromAndToDate(List<FixEvent> list, DateTimeFormat df) {
2886
bd16493cc0da Set initial values for start and end date in fix analysis date panels.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2884
diff changeset
193 try {
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
194 setFromDate(list.get(0).getDate(), df);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
195 setToDate(list.get(list.size() - 1).getDate(), df);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
196 return true;
2886
bd16493cc0da Set initial values for start and end date in fix analysis date panels.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2884
diff changeset
197 }
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
198 catch(IllegalArgumentException ex) {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
199 GWT.log("FixPeriodPanel::setFromAndToDate(): " + ex.toString());
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
200 return false;
2886
bd16493cc0da Set initial values for start and end date in fix analysis date panels.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2884
diff changeset
201 }
bd16493cc0da Set initial values for start and end date in fix analysis date panels.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2884
diff changeset
202 }
2517
8f528f5ae137 Added filter object class and scrollable chart to helper panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2505
diff changeset
203
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
204 protected void setFromDate(String date, DateTimeFormat df)
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
205 throws IllegalArgumentException
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
206 {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
207 Date from = df.parse(date);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
208 this.inputPanel.setFromDate(from);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
209 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
210
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
211 protected void setToDate(String date, DateTimeFormat df)
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
212 throws IllegalArgumentException
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
213 {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
214 Date to = df.parse(date);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
215 this.inputPanel.setToDate(to);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
216 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
217
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
218 protected boolean saveDateValues() {
8256
5b87aaac8447 Fixed date range panel in fix analysis.
Raimund Renkert <rrenkert@intevation.de>
parents: 7838
diff changeset
219 Date st = inputPanel.getValue().getStartDate();
5b87aaac8447 Fixed date range panel in fix analysis.
Raimund Renkert <rrenkert@intevation.de>
parents: 7838
diff changeset
220 Date en = inputPanel.getValue().getEndDate();
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 if (st == null || en == null) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222 SC.warn(MESSAGES.error_wrong_date());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
223 return false;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226 long start = st.getTime();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 long end = en.getTime();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
229 if (start <= end) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
230 this.start = start;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231 this.end = end;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
232 return true;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
233 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234 return false;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
235 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 }

http://dive4elements.wald.intevation.org