Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java @ 9391:2da486c7c05f
salix historical sounding workflow changed
author | gernotbelger |
---|---|
date | Thu, 09 Aug 2018 17:25:13 +0200 |
parents | f575ff573cbb |
children |
comparison
equal
deleted
inserted
replaced
9390:f575ff573cbb | 9391:2da486c7c05f |
---|---|
13 import java.util.HashMap; | 13 import java.util.HashMap; |
14 import java.util.List; | 14 import java.util.List; |
15 import java.util.Map; | 15 import java.util.Map; |
16 | 16 |
17 import org.dive4elements.river.client.client.FLYSConstants; | 17 import org.dive4elements.river.client.client.FLYSConstants; |
18 import org.dive4elements.river.client.client.ui.ParameterMatrix.Column.SelectionMode; | |
18 import org.dive4elements.river.client.shared.model.DataItem; | 19 import org.dive4elements.river.client.shared.model.DataItem; |
19 import org.dive4elements.river.client.shared.model.IntegerOptionsData; | 20 import org.dive4elements.river.client.shared.model.IntegerOptionsData; |
20 import org.dive4elements.river.client.shared.model.MultiAttributeData; | 21 import org.dive4elements.river.client.shared.model.MultiAttributeData; |
21 import org.dive4elements.river.client.shared.model.MultiDataItem; | 22 import org.dive4elements.river.client.shared.model.MultiDataItem; |
22 import org.dive4elements.river.client.shared.model.StringOptionsData; | 23 import org.dive4elements.river.client.shared.model.StringOptionsData; |
31 import com.smartgwt.client.widgets.Canvas; | 32 import com.smartgwt.client.widgets.Canvas; |
32 import com.smartgwt.client.widgets.Label; | 33 import com.smartgwt.client.widgets.Label; |
33 import com.smartgwt.client.widgets.grid.ListGrid; | 34 import com.smartgwt.client.widgets.grid.ListGrid; |
34 import com.smartgwt.client.widgets.grid.ListGridField; | 35 import com.smartgwt.client.widgets.grid.ListGridField; |
35 import com.smartgwt.client.widgets.grid.ListGridRecord; | 36 import com.smartgwt.client.widgets.grid.ListGridRecord; |
37 import com.smartgwt.client.widgets.grid.events.ChangedHandler; | |
36 | 38 |
37 /** | 39 /** |
38 * Some parameters take the form of on/off options that can also be seen | 40 * Some parameters take the form of on/off options that can also be seen |
39 * as a matrix. | 41 * as a matrix. |
40 * | 42 * |
42 * representation of this matrix. Later can happen in two ways to overcome | 44 * representation of this matrix. Later can happen in two ways to overcome |
43 * shortcomings of GWT/SmartGWT combination. | 45 * shortcomings of GWT/SmartGWT combination. |
44 */ | 46 */ |
45 public class ParameterMatrix { | 47 public class ParameterMatrix { |
46 | 48 |
47 protected ListGrid listGrid = null; | 49 protected static ListGrid listGrid = null; |
48 | 50 |
49 public static class Column implements Serializable { | 51 public static class Column implements Serializable { |
50 | 52 |
51 private static final long serialVersionUID = -3493426383086860118L; | 53 private static final long serialVersionUID = -3493426383086860118L; |
54 | |
55 public static enum SelectionMode { | |
56 single, multi | |
57 } | |
52 | 58 |
53 protected String name; | 59 protected String name; |
54 protected Map<String, String> values; | 60 protected Map<String, String> values; |
55 | 61 |
56 private Column() { | 62 private Column() { |
82 private final Map<String, List<String>> attributes; | 88 private final Map<String, List<String>> attributes; |
83 | 89 |
84 /** Maps column names to list of rows' first fields. */ | 90 /** Maps column names to list of rows' first fields. */ |
85 private final Map<String, List<String>> selected; | 91 private final Map<String, List<String>> selected; |
86 private final String itemname; | 92 private final String itemname; |
87 | 93 private final SelectionMode mode; |
88 public ParameterMatrix(final String itemnameColTitle) { | 94 |
95 public ParameterMatrix(final String itemnameColTitle, final SelectionMode mode) { | |
89 super(); | 96 super(); |
97 this.mode = mode; | |
90 this.itemname = itemnameColTitle; | 98 this.itemname = itemnameColTitle; |
91 this.columns = new HashMap<String, Column>(); | 99 this.columns = new HashMap<String, Column>(); |
92 this.columnNames = new ArrayList<String>(); | 100 this.columnNames = new ArrayList<String>(); |
93 this.valueNames = new ArrayList<String>(); | 101 this.valueNames = new ArrayList<String>(); |
94 this.selected = new HashMap<String, List<String>>(); | 102 this.selected = new HashMap<String, List<String>>(); |
213 | 221 |
214 for (int i = 0, n = this.columnNames.size(); i < n; i++) { | 222 for (int i = 0, n = this.columnNames.size(); i < n; i++) { |
215 final ListGridField field = new ListGridField(this.columnNames.get(i), this.MESSAGE.getString(this.columnNames.get(i))); | 223 final ListGridField field = new ListGridField(this.columnNames.get(i), this.MESSAGE.getString(this.columnNames.get(i))); |
216 field.setType(ListGridFieldType.BOOLEAN); | 224 field.setType(ListGridFieldType.BOOLEAN); |
217 field.setCanEdit(true); | 225 field.setCanEdit(true); |
226 if (this.mode == SelectionMode.single) { | |
227 field.addChangedHandler(new ChangedHandler() { | |
228 @Override | |
229 public void onChanged(final com.smartgwt.client.widgets.grid.events.ChangedEvent event) { | |
230 final int rowNumber = event.getRowNum(); | |
231 final Boolean value = (Boolean) event.getValue(); | |
232 final int colNr = event.getColNum(); | |
233 final String attr = ParameterMatrix.listGrid.getFieldName(colNr); | |
234 if (value) { | |
235 final ListGridRecord[] records = ParameterMatrix.listGrid.getRecords(); | |
236 for (int i = 0; i < records.length; i++) { | |
237 final ListGridRecord r = records[i]; | |
238 if (i != rowNumber) { | |
239 if (r.getAttributeAsBoolean(attr)) | |
240 r.setAttribute(attr, false); | |
241 } | |
242 } | |
243 } | |
244 } | |
245 }); | |
246 } | |
218 fields.add(field); | 247 fields.add(field); |
219 this.selected.put(this.columnNames.get(i), new ArrayList<String>()); | 248 this.selected.put(this.columnNames.get(i), new ArrayList<String>()); |
220 } | 249 } |
221 | 250 |
222 final ListGridField[] fieldsArray = fields.toArray(new ListGridField[fields.size()]); | 251 final ListGridField[] fieldsArray = fields.toArray(new ListGridField[fields.size()]); |