comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/ParameterMatrix.java @ 4184:03de5c424f95

Fix warnings and minor TODOs in flys-client.
author Christian Lins <christian.lins@intevation.de>
date Fri, 19 Oct 2012 09:29:57 +0200
parents 7d056b7a50d8
children d5821c6f0ab0
comparison
equal deleted inserted replaced
4183:1755a1bfe5ce 4184:03de5c424f95
1 package de.intevation.flys.client.client.ui; 1 package de.intevation.flys.client.client.ui;
2 2
3 import java.io.Serializable;
4
5 import java.util.ArrayList;
6 import java.util.HashMap;
7 import java.util.List;
8 import java.util.Map;
9
10 import com.google.gwt.core.client.GWT; 3 import com.google.gwt.core.client.GWT;
4 import com.google.gwt.event.dom.client.ClickEvent;
5 import com.google.gwt.event.dom.client.ClickHandler;
11 import com.google.gwt.user.client.ui.CheckBox; 6 import com.google.gwt.user.client.ui.CheckBox;
12 import com.google.gwt.user.client.ui.Grid; 7 import com.google.gwt.user.client.ui.Grid;
13 import com.google.gwt.user.client.ui.Widget; 8 import com.google.gwt.user.client.ui.Widget;
14 import com.google.gwt.user.client.ui.ClickListener; 9
15
16 import com.smartgwt.client.types.Autofit;
17 import com.smartgwt.client.types.ListGridFieldType; 10 import com.smartgwt.client.types.ListGridFieldType;
18 import com.smartgwt.client.widgets.Canvas; 11 import com.smartgwt.client.widgets.Canvas;
19 import com.smartgwt.client.widgets.Label; 12 import com.smartgwt.client.widgets.Label;
20 import com.smartgwt.client.widgets.grid.ListGrid; 13 import com.smartgwt.client.widgets.grid.ListGrid;
21 import com.smartgwt.client.widgets.grid.ListGridField; 14 import com.smartgwt.client.widgets.grid.ListGridField;
23 16
24 import de.intevation.flys.client.client.FLYSConstants; 17 import de.intevation.flys.client.client.FLYSConstants;
25 import de.intevation.flys.client.shared.model.DataItem; 18 import de.intevation.flys.client.shared.model.DataItem;
26 import de.intevation.flys.client.shared.model.IntegerOptionsData; 19 import de.intevation.flys.client.shared.model.IntegerOptionsData;
27 import de.intevation.flys.client.shared.model.StringOptionsData; 20 import de.intevation.flys.client.shared.model.StringOptionsData;
21
22 import java.io.Serializable;
23 import java.util.ArrayList;
24 import java.util.HashMap;
25 import java.util.List;
26 import java.util.Map;
28 27
29 28
30 /** 29 /**
31 * Some parameters take the form of on/off options that can also be seen 30 * Some parameters take the form of on/off options that can also be seen
32 * as a matrix. 31 * as a matrix.
38 public class ParameterMatrix { 37 public class ParameterMatrix {
39 38
40 protected ListGrid listGrid = null; 39 protected ListGrid listGrid = null;
41 40
42 public static class Column implements Serializable { 41 public static class Column implements Serializable {
42
43 private static final long serialVersionUID = -3493426383086860118L;
44
43 protected String name; 45 protected String name;
44 protected Map<String, String> values; 46 protected Map<String, String> values;
45 47
46 private Column() { 48 private Column() {
47 this.values = new HashMap<String, String>(); 49 this.values = new HashMap<String, String>();
231 233
232 234
233 /** Create Checkbox for column/value. */ 235 /** Create Checkbox for column/value. */
234 protected Canvas createCheckBox(final String colName, final String value) { 236 protected Canvas createCheckBox(final String colName, final String value) {
235 CheckBox box = new CheckBox(); 237 CheckBox box = new CheckBox();
236 box.addClickListener(new ClickListener() { 238 box.addClickHandler(new ClickHandler() {
239
237 @Override 240 @Override
238 public void onClick(Widget sender) { 241 public void onClick(ClickEvent event) {
239 CheckBox box = (CheckBox) sender;
240 Map<String, List<String>> selection = getSelection(); 242 Map<String, List<String>> selection = getSelection();
241 243
242 List<String> values = selection.get(colName); 244 List<String> values = selection.get(colName);
243 if (values.indexOf(value) >= 0) { 245 if (values.indexOf(value) >= 0) {
244 values.remove(value); 246 values.remove(value);
257 259
258 public Map<String, List<String>> getSelection() { 260 public Map<String, List<String>> getSelection() {
259 if (listGrid == null) { 261 if (listGrid == null) {
260 return selected; 262 return selected;
261 } 263 }
262 264
263 ListGridRecord[] records = listGrid.getRecords(); 265 ListGridRecord[] records = listGrid.getRecords();
264 for (ListGridRecord record: records) { 266 for (ListGridRecord record: records) {
265 for (int i = 0, n = columnNames.size(); i < n; i++) { 267 for (int i = 0, n = columnNames.size(); i < n; i++) {
266 String columnName = columnNames.get(i); 268 String columnName = columnNames.get(i);
267 Column col = columns.get(columnName);
268 List<String> chosenItems = selected.get(columnName); 269 List<String> chosenItems = selected.get(columnName);
269 if (Boolean.valueOf(record.getAttribute(columnName)) == true) { 270 if (Boolean.valueOf(record.getAttribute(columnName)) == true) {
270 chosenItems.add(record.getAttribute(columnName + "-value")); 271 chosenItems.add(record.getAttribute(columnName + "-value"));
271 } 272 }
272 } 273 }

http://dive4elements.wald.intevation.org