annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/DistancePanel.java @ 781:6653cf54b45d

The distance panel got two tables for locations and ranges. Both do not load any data until now. flys-client/trunk@2271 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 30 Jun 2011 11:59:02 +0000
parents a39c2f531755
children 4a7ece57f44c
rev   line source
780
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.client.client.ui;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
3 import java.util.ArrayList;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
4 import java.util.List;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
5
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import com.google.gwt.core.client.GWT;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7 import com.google.gwt.i18n.client.NumberFormat;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9 import com.smartgwt.client.widgets.Canvas;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import com.smartgwt.client.widgets.Label;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import com.smartgwt.client.widgets.form.fields.events.BlurHandler;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import com.smartgwt.client.widgets.form.fields.events.BlurEvent;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13 import com.smartgwt.client.widgets.layout.HLayout;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import com.smartgwt.client.widgets.layout.VLayout;
781
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
15 import com.smartgwt.client.widgets.tab.TabSet;
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
16 import com.smartgwt.client.widgets.tab.Tab;
780
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import de.intevation.flys.client.shared.model.Data;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
19 import de.intevation.flys.client.shared.model.DataItem;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20 import de.intevation.flys.client.shared.model.DataList;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
21 import de.intevation.flys.client.shared.model.DefaultData;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.client.shared.model.DefaultDataItem;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
23
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24 import de.intevation.flys.client.client.FLYSConstants;
781
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
25 import de.intevation.flys.client.client.ui.range.RangeTable;
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
26 import de.intevation.flys.client.client.ui.range.LocationsTable;
780
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29 public class DistancePanel extends AbstractUIProvider implements BlurHandler {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 public static final int DEFAULT_STEP_WIDTH = 100;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
34 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
35
781
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
36 protected RangeTable distancesTable;
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
37 protected LocationsTable locationsTable;
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
38
780
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 protected DoubleRangePanel distancePanel;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
781
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
41 protected TabSet tabs;
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
42
780
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 protected double min;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 protected double max;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
47 public DistancePanel() {
781
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
48 distancesTable = new RangeTable();
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
49 locationsTable = new LocationsTable();
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
50 distancePanel = new DoubleRangePanel(
780
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
51 MSG.unitFrom(), MSG.unitTo(), MSG.unitWidth(),
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
52 0d, 0d, 0d, 250, this);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
53 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
55
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
56 @Override
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
57 public Canvas create(DataList data) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
58 VLayout layout = new VLayout();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
59 layout.setMembersMargin(10);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
60
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
61 Label label = new Label(MSG.distance_state());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
62
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
63 Canvas submit = getNextButton();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
64
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
65 label.setHeight(25);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
66 distancePanel.setHeight(50);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
67
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
68 layout.addMember(label);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
69 layout.addMember(distancePanel);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
70 layout.addMember(submit);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
71
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 initMinMaxValues(data);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 initDefaultValues(data);
781
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
74 initHelperPanel();
780
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 return layout;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
78
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
80 @Override
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
81 public Canvas createOld(DataList dataList) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
82 String s = getOldSelectionString(dataList);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
83 String l = dataList.getLabel();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
84
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
85 Label label = new Label(l);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
86 Label selected = new Label(s);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
87
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
88 HLayout layout = new HLayout();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
89
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
90 layout.setWidth(400);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
91 label.setWidth(200);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
92 selected.setWidth(130);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
93
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 layout.addMember(label);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
95 layout.addMember(selected);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
96
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
97 return layout;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
99
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
100
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
101 protected String getOldSelectionString(DataList dataList) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
102 List<Data> items = dataList.getAll();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
103
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
104 Data dFrom = getData(items, "ld_from");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
105 Data dTo = getData(items, "ld_to");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
106 Data dStep = getData(items, "ld_step");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108 DataItem[] from = dFrom.getItems();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109 DataItem[] to = dTo.getItems();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 DataItem[] step = dStep.getItems();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 StringBuilder sb = new StringBuilder();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 sb.append(from[0].getLabel());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114 sb.append(" " + MSG.unitFrom() + " ");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 sb.append(to[0].getLabel());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116 sb.append(" " + MSG.unitTo() + " ");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 sb.append(step[0].getLabel());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 sb.append(" " + MSG.unitWidth());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 return sb.toString();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 @Override
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
125 public List<String> validate() {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
126 List<String> errors = new ArrayList<String>();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
127
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
128 if (!distancePanel.validateForm()) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
129 errors.add(MSG.wrongFormat());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
130
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
131 return errors;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
132 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
133
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
134 validateFrom(errors);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
135 validateTo(errors);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
136
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
137 return errors;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
138 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
139
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
140
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
141 protected void validateFrom(List<String> errors) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
142 double from = distancePanel.getFrom();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
143
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
144 if (from < min || from > max) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
145 NumberFormat nf = NumberFormat.getDecimalFormat();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
146
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
147 String tmp = MSG.error_validate_lower_range();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
148 tmp = tmp.replace("$1", nf.format(from));
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
149 tmp = tmp.replace("$2", nf.format(min));
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
150
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
151 distancePanel.setFrom(min);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
152 errors.add(tmp);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
153 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
154 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
155
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
156
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
157 protected void validateTo(List<String> errors) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 double to = distancePanel.getTo();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
160 if (to < min || to > max) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
161 NumberFormat nf = NumberFormat.getDecimalFormat();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
162
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
163 String tmp = MSG.error_validate_upper_range();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
164 tmp = tmp.replace("$1", nf.format(to));
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
165 tmp = tmp.replace("$2", nf.format(max));
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
166
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
167 distancePanel.setTo(max);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
168 errors.add(tmp);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
169 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
170 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
171
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
172
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
173 @Override
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
174 public Data[] getData() {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
175 Data[] data = new Data[3];
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
176
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
177 data[0] = getDataFrom();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
178 data[1] = getDataTo();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
179 data[2] = getDataStep();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
180
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
181 return data;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
182 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
183
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
184
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
185 protected Data getDataFrom() {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
186 String value = String.valueOf(distancePanel.getFrom());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
187 DataItem item = new DefaultDataItem("ld_from", "ld_from", value);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
188 return new DefaultData(
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
189 "ld_from", null, null, new DataItem[] { item });
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
190 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
191
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
192
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
193 protected Data getDataTo() {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
194 String value = String.valueOf(distancePanel.getTo());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
195 DataItem item = new DefaultDataItem("ld_to", "ld_to", value);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
196 return new DefaultData(
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
197 "ld_to", null, null, new DataItem[] { item });
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
198 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
199
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
200
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
201 protected Data getDataStep() {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
202 String value = String.valueOf(distancePanel.getStep());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
203 DataItem item = new DefaultDataItem("ld_step","ld_step", value);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
204 return new DefaultData(
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
205 "ld_step", null, null, new DataItem[] { item });
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
206 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
207
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
208
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
209 @Override
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
210 public void onBlur(BlurEvent event) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
211 distancePanel.validateForm();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
212 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
213
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
214
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
215 protected void initMinMaxValues(DataList data) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
216 Data f = getData(data.getAll(), "ld_from");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
217 Data t = getData(data.getAll(), "ld_to");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
218
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
219 DataItem[] fItems = f.getItems();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
220 DataItem[] tItems = t.getItems();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
221
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
222 try {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
223 min = Double.valueOf(fItems[0].getStringValue());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
224 max = Double.valueOf(tItems[0].getStringValue());
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
225 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
226 catch (NumberFormatException nfe) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
227 min = -Double.MAX_VALUE;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
228 max = Double.MAX_VALUE;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
229 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
230 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
231
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
232
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
233 protected void initDefaultValues(DataList data) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
234 initDefaultFrom(data);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
235 initDefaultTo(data);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
236 initDefaultStep(data);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
237 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
238
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
239
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
240 protected void initDefaultFrom(DataList data) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
241 Data f = getData(data.getAll(), "ld_from");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
242
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
243 double from = min;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
244
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
245 try {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
246 from = getDefaultValue(f);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
247 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
248 catch (NumberFormatException nfe) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
249 // do nothing
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
250 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
251
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
252 distancePanel.setFrom(from);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
253 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
254
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
255
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
256 protected void initDefaultTo(DataList data) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
257 Data t = getData(data.getAll(), "ld_to");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
258
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
259 double to = max;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
260
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
261 try {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
262 to = getDefaultValue(t);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
263 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
264 catch (NumberFormatException nfe) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
265 // do nothing
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
266 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
267
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
268 distancePanel.setTo(to);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
269 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
270
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
271
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
272 protected void initDefaultStep(DataList data) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
273 Data s = getData(data.getAll(), "ld_step");
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
274
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
275 double step = (double) DEFAULT_STEP_WIDTH;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
276
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
277 try {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
278 step = getDefaultValue(s);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
279 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
280 catch (NumberFormatException nfe) {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
281 // do nothing
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
282 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
283
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
284 distancePanel.setStep(step);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
285 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
286
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
287
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
288 protected double getDefaultValue(Data data)
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
289 throws NumberFormatException
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
290 {
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
291 DataItem def = data.getDefault();
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
292 String defValue = def != null ? def.getStringValue() : null;
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
293
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
294 return Double.valueOf(defValue);
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
295 }
781
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
296
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
297
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
298 protected void initHelperPanel() {
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
299 tabs = new TabSet();
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
300 tabs.setWidth100();
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
301 tabs.setHeight100();
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
302
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
303 Tab locations = new Tab(MSG.locations());
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
304 Tab distances = new Tab(MSG.distance());
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
305
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
306 locations.setPane(locationsTable);
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
307 distances.setPane(distancesTable);
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
308
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
309 tabs.addTab(locations, 0);
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
310 tabs.addTab(distances, 1);
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
311
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
312 helperContainer.addChild(tabs);
6653cf54b45d The distance panel got two tables for locations and ranges. Both do not load any data until now.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 780
diff changeset
313 }
780
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
314 }
a39c2f531755 Implemented a new panel to enter kilometer ranges (with no option to insert locations).
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
315 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org