annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/fixation/FixPeriodPanel.java @ 3855:b6b2d9aad95d

Fix for #854 flys-client/trunk@5596 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Christian Lins <christian.lins@intevation.de>
date Tue, 25 Sep 2012 13:24:23 +0000
parents 0de61fc9d281
children 65e369ac4f99
rev   line source
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui.fixation;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
2
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
3 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
4 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
5
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
6 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
7 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
8 import com.smartgwt.client.widgets.Label;
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
9 import com.smartgwt.client.widgets.form.DynamicForm;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
10 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
11 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
12 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
13
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
14 import de.intevation.flys.client.client.Config;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
15 import de.intevation.flys.client.client.FLYSConstants;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
16 import de.intevation.flys.client.shared.model.Data;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
17 import de.intevation.flys.client.shared.model.DataItem;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
18 import de.intevation.flys.client.shared.model.DataList;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.client.shared.model.DefaultData;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.client.shared.model.DefaultDataItem;
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
21 import de.intevation.flys.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
22
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
23 import java.util.ArrayList;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
24 import java.util.Date;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
25 import java.util.List;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
26
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 /**
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
28 * 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
29 *
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
30 * @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
31 */
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 public class FixPeriodPanel
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 extends FixationPanel
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 /** 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
36 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
37
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
38 DateRangeItem inputPanel;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
39
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 long start;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41 long end;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
42
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
43 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
44 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
45
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
46 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
47 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
48 }
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
49
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
50 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
51 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
52 this.endName = endName;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 htmlOverview = "";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
55
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
56 @Override
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 public Canvas createWidget(DataList data) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
58 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
59
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60 VLayout layout = new VLayout();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
61
2537
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
62 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
63 title.setHeight("25px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 DynamicForm form = new DynamicForm();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 inputPanel = new DateRangeItem();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 inputPanel.setToTitle(MESSAGES.to());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 inputPanel.setFromTitle(MESSAGES.from());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 inputPanel.setShowTitle(false);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70 form.setFields(inputPanel);
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 layout.addMember(title);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73 layout.addMember(form);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 return layout;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
76 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
77
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 public Canvas createOld(DataList dataList) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80 List<Data> items = dataList.getAll();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
81
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
82 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
83 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
84 DataItem[] startItem = start.getItems();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85 DataItem[] endItem = end.getItems();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
86
2537
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
87 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
88 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
89
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
90 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
91 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
92 try {
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
93 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
94 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
95 }
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
96 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
97 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
98 }
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
99 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
100 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
101
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
102 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
103 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
104 DateTimeFormat.PredefinedFormat.DATE_MEDIUM);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
105 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
106 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
107 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
108
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
109 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
110 old.setWidth(130);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 HLayout layout = new HLayout();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113 layout.setWidth("400px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
115 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
116 label.setWidth("200px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
118 Canvas back = getBackButton(dataList.getState());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
119
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 layout.addMember(label);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 layout.addMember(old);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122 layout.addMember(back);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
124 return layout;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
125 }
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
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
128 /**
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
129 * 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
130 *
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 * @return the selected/inserted data.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
132 */
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
133 @Override
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 public Data[] getData() {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
135 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
136
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 boolean valid = saveDateValues();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 if(valid) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
139 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
140 String end = Long.valueOf(this.end).toString();
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
141 DataItem startItem = new DefaultDataItem(startName, startName, start);
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
142 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
143 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
144 startName,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
145 null,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
146 null,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 new DataItem[] { startItem }));
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
148 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
149 endName,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
150 null,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
151 null,
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 new DataItem[] { endItem }));
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
154
3379
0de61fc9d281 Removed some superfluous casts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2892
diff changeset
155 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
156 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
157
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
158
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
160 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
161 // No user interaction, do nothing.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
162 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
163
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 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 public boolean renderCheckboxes() {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 // No selection, return false.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 return false;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
170
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
171 protected String getLocaleDateFormat() {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
172 String loc = Config.getInstance().getLocale();
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
173 if ("de".equals(loc)) {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
174 return "yy.MM.yyyy";
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
175 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
176 else {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
177 return "MM/dd/yyyy";
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
178 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
179 }
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
180
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
181 @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
182 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
183 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
184
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
185 // The date in FixEvent is always "de" locale, so it seems...
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
186 DateTimeFormat df = DateTimeFormat.getFormat("yy.MM.yyyy");
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
187
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
188 if (!setFromAndToDate(list, df)) {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
189 // or perhaps "en"?
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
190 df = DateTimeFormat.getFormat("MM/dd/yyyy");
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 if (!setFromAndToDate(list, df)) {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
193 GWT.log("FixPeriodPanel::success(): could not set from and to dates!");
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
194 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
195 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
196 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
197
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
198 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
199 try {
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
200 setFromDate(list.get(0).getDate(), df);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
201 setToDate(list.get(list.size() - 1).getDate(), df);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
202 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
203 }
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
204 catch(IllegalArgumentException ex) {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
205 GWT.log("FixPeriodPanel::setFromAndToDate(): " + ex.toString());
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
206 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
207 }
bd16493cc0da Set initial values for start and end date in fix analysis date panels.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2884
diff changeset
208 }
2517
8f528f5ae137 Added filter object class and scrollable chart to helper panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2505
diff changeset
209
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
210 protected void setFromDate(String date, DateTimeFormat df)
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
211 throws IllegalArgumentException
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
212 {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
213 Date from = df.parse(date);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
214 this.inputPanel.setFromDate(from);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
215 }
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 protected void setToDate(String date, DateTimeFormat df)
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
218 throws IllegalArgumentException
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
219 {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
220 Date to = df.parse(date);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
221 this.inputPanel.setToDate(to);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
222 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
223
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 protected boolean saveDateValues() {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225 Date st = inputPanel.getFromDate();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226 Date en = inputPanel.getToDate();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 if (st == null || en == null) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
228 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
229 return false;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
230 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
231
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
232 long start = st.getTime();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
233 long end = en.getTime();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
234
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
235 if (start <= end) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
236 this.start = start;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
237 this.end = end;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
238 return true;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
239 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
240 return false;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
241 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
242 }

http://dive4elements.wald.intevation.org