comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/SingleLocationPanel.java @ 1593:ff9d71469b7c

Adjusted to be able to feed data to reference curves. flys-client/trunk@3902 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Fri, 03 Feb 2012 13:57:27 +0000
parents 8ab010967f78
children ddf43791244c
comparison
equal deleted inserted replaced
1592:f34bbb5fb6d2 1593:ff9d71469b7c
50 GWT.create(DistanceInfoService.class); 50 GWT.create(DistanceInfoService.class);
51 51
52 /** The table data. */ 52 /** The table data. */
53 protected DistanceInfoObject[] tableData; 53 protected DistanceInfoObject[] tableData;
54 54
55 /** Name of the data item that keeps locations. */
56 protected String DATA_ITEM_NAME = "ld_locations";
57
58 /** The input helper (usually right side, table to click on, values are 55 /** The input helper (usually right side, table to click on, values are
59 * then entered in the texfield. */ 56 * then entered in the texfield. */
60 protected LocationPicker picker; 57 protected LocationPicker picker;
61 58
62 /** 59 /**
76 * 73 *
77 * @return a panel. 74 * @return a panel.
78 */ 75 */
79 @Override 76 @Override
80 public Canvas create(DataList data) { 77 public Canvas create(DataList data) {
78 findDataItemName(data);
79
81 VLayout layout = new VLayout(); 80 VLayout layout = new VLayout();
82 layout.setMembersMargin(10); 81 layout.setMembersMargin(10);
83 82
84 Label label = new Label(MSG.location ()); 83 Label label = new Label(MSG.location ());
85 Canvas widget = createWidget(data); 84 Canvas widget = createWidget(data);
107 * @param list The DataList container that stores the Data objects. 106 * @param list The DataList container that stores the Data objects.
108 */ 107 */
109 protected void initDefaults(DataList list) { 108 protected void initDefaults(DataList list) {
110 Data data = list.get(0); 109 Data data = list.get(0);
111 110
112 /*
113 // Compatibility with MinMax- DataItems: 111 // Compatibility with MinMax- DataItems:
114 RangeData rangeData = null; 112 RangeData rangeData = null;
115 113
116 for (int i = 0, n = list.size(); i < n; i++) { 114 for (int i = 0, n = list.size(); i < n; i++) {
117 Data tmp = list.get(i); 115 Data tmp = list.get(i);
124 if (rangeData != null) { 122 if (rangeData != null) {
125 min = Double.parseDouble(rangeData.getDefaultLower().toString()); 123 min = Double.parseDouble(rangeData.getDefaultLower().toString());
126 max = Double.parseDouble(rangeData.getDefaultUpper().toString()); 124 max = Double.parseDouble(rangeData.getDefaultUpper().toString());
127 // catch ..? 125 // catch ..?
128 } 126 }
129 */
130
131 if (false) {}
132 else { 127 else {
133 DataItem[] items = data.getItems(); 128 DataItem[] items = data.getItems();
134 DataItem iMin = getDataItem(items, "min"); 129 DataItem iMin = getDataItem(items, "min");
135 DataItem iMax = getDataItem(items, "max"); 130 DataItem iMax = getDataItem(items, "max");
136 131
143 min = -Double.MAX_VALUE; 138 min = -Double.MAX_VALUE;
144 max = Double.MAX_VALUE; 139 max = Double.MAX_VALUE;
145 } 140 }
146 } 141 }
147 142
148 DataItem def = data.getDefault(); 143 DataItem def = data.getDefault();
149 String value = def.getStringValue(); 144 if (def != null) {
150 145 String value = def.getStringValue();
151 try { 146
152 double d = Double.parseDouble(value); 147 try {
153 setLocationValues(new double[] { d } ); 148 double d = Double.parseDouble(value);
154 } 149 setLocationValues(new double[] { d } );
155 catch (NumberFormatException nfe) { 150 }
156 // could not parse, dont know what to do else 151 catch (NumberFormatException nfe) {
152 // could not parse, dont know what to do else
153 }
157 } 154 }
158 } 155 }
159 156
160 157
161 protected Canvas createWidget(DataList data) { 158 protected Canvas createWidget(DataList data) {
162 VLayout layout = new VLayout(); 159 VLayout layout = new VLayout();
163 inputLayout = new HLayout(); 160 inputLayout = new HLayout();
164 161
165 // The initial view will display the location input mode. 162 // The initial view will display the location input mode.
166 locationPanel = new DoubleArrayPanel( 163 locationPanel = new DoubleArrayPanel(
167 MSG.unitLocation(), 164 MSG.unitLocation(),
168 getLocationValues(), 165 getLocationValues(),
185 return layout; 182 return layout;
186 } 183 }
187 184
188 185
189 /** 186 /**
190 * This method grabs the Data with name <i>name</i> from the list and
191 * returns it.
192 *
193 * @param items A list of Data.
194 * @param name The name of the Data that we are searching for.
195 *
196 * @return the Data with the name <i>name</i>.
197 */
198 @Override
199 protected Data getData(List<Data> data, String name) {
200 for (Data d: data) {
201 if (name.equals(d.getLabel())) {
202 return d;
203 }
204 }
205
206 return null;
207 }
208
209
210 /**
211 * This method returns the selected data. 187 * This method returns the selected data.
212 * 188 *
213 * @return the selected/inserted data. 189 * @return the selected/inserted data.
214 */ 190 */
215 public Data[] getData() { 191 public Data[] getData() {
216 saveLocationValues(locationPanel); 192 saveLocationValues(locationPanel);
217 double[] values = getLocationValues(); 193 double[] values = getLocationValues();
218 Data[] data = new Data[values.length+1]; 194 Data[] data = new Data[values.length+1];
219 195
220 for (int i = 0; i < values.length; i++) { 196 for (int i = 0; i < values.length; i++) {
221 data[i] = createDataArray(DATA_ITEM_NAME, 197 data[i] = createDataArray(getDataItemName(),
222 Double.valueOf(values[i]).toString()); 198 Double.valueOf(values[i]).toString());
223 } 199 }
224 data[values.length] = createDataArray("ld_mode", "locations"); 200 data[values.length] = createDataArray("ld_mode", "locations");
225 201
226 return data; 202 return data;

http://dive4elements.wald.intevation.org