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

Show top level folder icons only if node has no factory If you have an empty folder the folder icon is still shown. This makes it possible to add functional "Top Level" entries in the Datacage
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 26 Mar 2013 18:29:13 +0100
parents 65e369ac4f99
children
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
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
14 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
15 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
16 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
17 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
18 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
19 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
20 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
21
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
22 import java.util.ArrayList;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
23 import java.util.Date;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
24 import java.util.List;
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
25
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
26 /**
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
27 * 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
28 *
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
29 * @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
30 */
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
31 public class FixPeriodPanel
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
32 extends FixationPanel
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
33 {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
34 /** 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
35 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
36
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
37 DateRangeItem inputPanel;
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 long start;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
40 long end;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
41
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
42 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
43 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
44
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
45 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
46 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
47 }
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 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
50 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
51 this.endName = endName;
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
52 htmlOverview = "";
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
53 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
54
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
55 @Override
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
56 public Canvas createWidget(DataList data) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
57 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
58
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
59 VLayout layout = new VLayout();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
60
2537
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
61 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
62 title.setHeight("25px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
63
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
64 DynamicForm form = new DynamicForm();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
65 inputPanel = new DateRangeItem();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
66 inputPanel.setToTitle(MESSAGES.to());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
67 inputPanel.setFromTitle(MESSAGES.from());
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
68 inputPanel.setShowTitle(false);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
69 form.setFields(inputPanel);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
70
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
71 layout.addMember(title);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
72 layout.addMember(form);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
73
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
74 return layout;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
75 }
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 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
78 public Canvas createOld(DataList dataList) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
79 List<Data> items = dataList.getAll();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
80
2538
c7da05282644 FixPeriodPanel: Make the names of state parameters configurable by constructor.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2537
diff changeset
81 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
82 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
83 DataItem[] startItem = start.getItems();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
84 DataItem[] endItem = end.getItems();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
85
2537
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
86 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
87 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
88
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
89 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
90 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
91 try {
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
92 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
93 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
94 }
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
95 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
96 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
97 }
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
98 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
99 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
100
cc5969df0490 New methods in UI providers for fixings states and minor protocol changes.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2526
diff changeset
101 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
102 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
103 DateTimeFormat.PredefinedFormat.DATE_MEDIUM);
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
104 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
105 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
106 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
107
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
108 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
109 old.setWidth(130);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
110
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
111 HLayout layout = new HLayout();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
112 layout.setWidth("400px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
113
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
114 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
115 label.setWidth("200px");
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
116
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
117 Canvas back = getBackButton(dataList.getState());
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 layout.addMember(label);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
120 layout.addMember(old);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
121 layout.addMember(back);
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
122
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
123 return layout;
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
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 * 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
129 *
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
130 * @return the selected/inserted data.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
131 */
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
132 @Override
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
133 public Data[] getData() {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
134 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
135
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
136 boolean valid = saveDateValues();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
137 if(valid) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
138 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
139 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
140 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
141 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
142 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
143 startName,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
144 null,
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 new DataItem[] { startItem }));
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
147 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
148 endName,
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
149 null,
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 new DataItem[] { endItem }));
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
152 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
153
3379
0de61fc9d281 Removed some superfluous casts.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents: 2892
diff changeset
154 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
155 }
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 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
159 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
160 // No user interaction, do nothing.
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
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 @Override
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
165 public boolean renderCheckboxes() {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
166 // No selection, return false.
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
167 return false;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
168 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
169
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
170 @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
171 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
172 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
173
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
174 // 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
175 DateTimeFormat df = DateTimeFormat.getFormat("yy.MM.yyyy");
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
176
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
177 if (!setFromAndToDate(list, df)) {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
178 // or perhaps "en"?
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
179 df = DateTimeFormat.getFormat("MM/dd/yyyy");
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
180
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
181 if (!setFromAndToDate(list, df)) {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
182 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
183 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
184 }
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
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
187 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
188 try {
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
189 setFromDate(list.get(0).getDate(), df);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
190 setToDate(list.get(list.size() - 1).getDate(), df);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
191 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
192 }
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
193 catch(IllegalArgumentException ex) {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
194 GWT.log("FixPeriodPanel::setFromAndToDate(): " + ex.toString());
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
195 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
196 }
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 }
2517
8f528f5ae137 Added filter object class and scrollable chart to helper panel.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 2505
diff changeset
198
3855
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
199 protected void setFromDate(String date, DateTimeFormat df)
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
200 throws IllegalArgumentException
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
201 {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
202 Date from = df.parse(date);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
203 this.inputPanel.setFromDate(from);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
204 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
205
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
206 protected void setToDate(String date, DateTimeFormat df)
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
207 throws IllegalArgumentException
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
208 {
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
209 Date to = df.parse(date);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
210 this.inputPanel.setToDate(to);
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
211 }
b6b2d9aad95d Fix for #854
Christian Lins <christian.lins@intevation.de>
parents: 3379
diff changeset
212
2505
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
213 protected boolean saveDateValues() {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
214 Date st = inputPanel.getFromDate();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
215 Date en = inputPanel.getToDate();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
216 if (st == null || en == null) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
217 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
218 return false;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
219 }
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
220
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
221 long start = st.getTime();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
222 long end = en.getTime();
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
223
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
224 if (start <= end) {
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
225 this.start = start;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
226 this.end = end;
87ac5c532523 First part of the UI for fixing analysis parameter.
Raimund Renkert <raimund.renkert@intevation.de>
parents:
diff changeset
227 return true;
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 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 }

http://dive4elements.wald.intevation.org