Mercurial > dive4elements > river
comparison gwt-client/src/main/java/org/dive4elements/river/client/client/ui/ParameterMatrix.java @ 7826:982382d9ea8b minfo-opt
Display the additional information extracted from multiattribute data.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Thu, 20 Mar 2014 13:36:59 +0100 |
parents | b4b8764ee90d |
children | 5e38e2924c07 |
comparison
equal
deleted
inserted
replaced
7825:b9decb8bfb21 | 7826:982382d9ea8b |
---|---|
23 import com.smartgwt.client.widgets.grid.ListGridRecord; | 23 import com.smartgwt.client.widgets.grid.ListGridRecord; |
24 | 24 |
25 import org.dive4elements.river.client.client.FLYSConstants; | 25 import org.dive4elements.river.client.client.FLYSConstants; |
26 import org.dive4elements.river.client.shared.model.DataItem; | 26 import org.dive4elements.river.client.shared.model.DataItem; |
27 import org.dive4elements.river.client.shared.model.IntegerOptionsData; | 27 import org.dive4elements.river.client.shared.model.IntegerOptionsData; |
28 import org.dive4elements.river.client.shared.model.MultiAttributeData; | |
29 import org.dive4elements.river.client.shared.model.MultiDataItem; | |
28 import org.dive4elements.river.client.shared.model.StringOptionsData; | 30 import org.dive4elements.river.client.shared.model.StringOptionsData; |
29 | 31 |
30 import java.io.Serializable; | 32 import java.io.Serializable; |
31 import java.util.ArrayList; | 33 import java.util.ArrayList; |
32 import java.util.HashMap; | 34 import java.util.HashMap; |
77 public static final int CELL_HEIGHT = 25; | 79 public static final int CELL_HEIGHT = 25; |
78 | 80 |
79 private Map<String, Column> columns; | 81 private Map<String, Column> columns; |
80 private List<String> columnNames; | 82 private List<String> columnNames; |
81 private List<String> valueNames; | 83 private List<String> valueNames; |
84 private Map<String, List<String>> attributes; | |
82 | 85 |
83 /** Maps column names to list of rows' first fields. */ | 86 /** Maps column names to list of rows' first fields. */ |
84 private Map<String, List<String>> selected; | 87 private Map<String, List<String>> selected; |
85 | 88 |
86 public ParameterMatrix() { | 89 public ParameterMatrix() { |
87 super(); | 90 super(); |
88 this.columns = new HashMap<String, Column>(); | 91 this.columns = new HashMap<String, Column>(); |
89 this.columnNames = new ArrayList<String>(); | 92 this.columnNames = new ArrayList<String>(); |
90 this.valueNames = new ArrayList<String>(); | 93 this.valueNames = new ArrayList<String>(); |
91 this.selected = new HashMap<String, List<String>>(); | 94 this.selected = new HashMap<String, List<String>>(); |
95 this.attributes = new HashMap<String, List<String>>(); | |
92 } | 96 } |
93 | 97 |
94 | 98 |
95 public void addColumn(IntegerOptionsData group) { | 99 public void addColumn(IntegerOptionsData group) { |
96 String groupTitle = group.getLabel(); | 100 String groupTitle = group.getLabel(); |
146 | 150 |
147 columnNames.add(groupTitle); | 151 columnNames.add(groupTitle); |
148 columns.put(groupTitle, col); | 152 columns.put(groupTitle, col); |
149 } | 153 } |
150 | 154 |
155 public void addColumn(MultiAttributeData options) { | |
156 GWT.log("Add Columns for MultiAttribute data"); | |
157 String groupTitle = options.getLabel(); | |
158 | |
159 Column col = new Column(groupTitle); | |
160 DataItem[] items = options.getItems(); | |
161 | |
162 if (items == null) { | |
163 GWT.log("No items found in StringOptionsData '" + groupTitle + "'"); | |
164 return; | |
165 } | |
166 | |
167 MultiDataItem mItem = (MultiDataItem)items[0]; | |
168 for (Map.Entry<String, String> entry: mItem.getValue().entrySet()) { | |
169 if (entry.getKey().equals("art:value") || | |
170 entry.getKey().equals("art:label")) { | |
171 continue; | |
172 } | |
173 attributes.put(entry.getKey(), new ArrayList<String>()); | |
174 } | |
175 for (DataItem item: items) { | |
176 GWT.log("multidataitem: " + item.getLabel()); | |
177 String title = item.getLabel(); | |
178 | |
179 if (valueNames.indexOf(title) < 0) { | |
180 valueNames.add(title); | |
181 } | |
182 MultiDataItem mi = (MultiDataItem)item; | |
183 Map<String, String> vs = mi.getValue(); | |
184 for (Map.Entry<String, String>e: vs.entrySet()) { | |
185 if (e.getKey().equals("art:value") || | |
186 e.getKey().equals("art:label")) { | |
187 continue; | |
188 } | |
189 List<String> data = attributes.get(e.getKey()); | |
190 data.add(e.getValue()); | |
191 } | |
192 col.addValue(item.getLabel(), mi.getValue().get("art:value")); | |
193 } | |
194 | |
195 columnNames.add(groupTitle); | |
196 columns.put(groupTitle, col); | |
197 } | |
151 | 198 |
152 public Widget createParameterGrid() { | 199 public Widget createParameterGrid() { |
153 listGrid = new ListGrid(); | 200 listGrid = new ListGrid(); |
154 listGrid.setShowAllRecords(true); | 201 listGrid.setShowAllRecords(true); |
155 listGrid.setWrapCells(true); | 202 listGrid.setWrapCells(true); |
156 listGrid.setShowHeaderContextMenu(false); | 203 listGrid.setShowHeaderContextMenu(false); |
157 listGrid.setCanReorderFields(false); | 204 listGrid.setCanReorderFields(false); |
158 listGrid.setCanSort(false); | 205 // listGrid.setCanSort(false); |
159 //listGrid.setAutoFitData(Autofit.VERTICAL); | 206 //listGrid.setAutoFitData(Autofit.VERTICAL); |
160 listGrid.setFixedRecordHeights(false); | 207 listGrid.setFixedRecordHeights(false); |
161 // TODO: Then also need "autofit" (when wrapping) | 208 // TODO: Then also need "autofit" (when wrapping) |
162 | 209 |
163 ListGridField itemNameField = new ListGridField("itemname", " "); | 210 ListGridField itemNameField = new ListGridField("itemname", " "); |
164 ArrayList<ListGridField> fields = new ArrayList<ListGridField>(); | 211 ArrayList<ListGridField> fields = new ArrayList<ListGridField>(); |
165 fields.add(itemNameField); | 212 fields.add(itemNameField); |
213 | |
214 for (Map.Entry<String, List<String>> entry: attributes.entrySet()) { | |
215 ListGridField attrField = new ListGridField( | |
216 entry.getKey(), MESSAGE.getString(entry.getKey())); | |
217 fields.add(attrField); | |
218 } | |
166 | 219 |
167 for (int i = 0, n = columnNames.size(); i < n; i++) { | 220 for (int i = 0, n = columnNames.size(); i < n; i++) { |
168 ListGridField field = new ListGridField(columnNames.get(i), MESSAGE.getString(columnNames.get(i))); | 221 ListGridField field = new ListGridField(columnNames.get(i), MESSAGE.getString(columnNames.get(i))); |
169 field.setType(ListGridFieldType.BOOLEAN); | 222 field.setType(ListGridFieldType.BOOLEAN); |
170 field.setCanEdit(true); | 223 field.setCanEdit(true); |
186 String columnName = columnNames.get(i); | 239 String columnName = columnNames.get(i); |
187 Column col = columns.get(columnName); | 240 Column col = columns.get(columnName); |
188 String value = col.getValue(valueName); | 241 String value = col.getValue(valueName); |
189 record.setAttribute(columnName, false); | 242 record.setAttribute(columnName, false); |
190 record.setAttribute(columnName+"-value", value); | 243 record.setAttribute(columnName+"-value", value); |
244 } | |
245 for (Map.Entry<String, List<String>> entry: attributes.entrySet()) { | |
246 record.setAttribute(entry.getKey(), entry.getValue().get(j)); | |
191 } | 247 } |
192 records.add(record); | 248 records.add(record); |
193 } | 249 } |
194 | 250 |
195 listGrid.setData(records.toArray(new ListGridRecord[records.size()])); | 251 listGrid.setData(records.toArray(new ListGridRecord[records.size()])); |