Mercurial > hg > STI-GWT
comparison src/econnect/wp3_3/client/widgets/table/DynamicStiTable.java @ 68:8b58d9bc0bb6 trimmed_data
add functionality for additional tabular data from the description field (work in progress)
author | Sebastian Kruse <skruse@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 03 Jan 2013 18:43:28 +0100 |
parents | aa1808d94d80 |
children | ea856995abac |
comparison
equal
deleted
inserted
replaced
67:5b049141a26e | 68:8b58d9bc0bb6 |
---|---|
23 import com.google.gwt.view.client.CellPreviewEvent.Handler; | 23 import com.google.gwt.view.client.CellPreviewEvent.Handler; |
24 import com.google.gwt.view.client.ListDataProvider; | 24 import com.google.gwt.view.client.ListDataProvider; |
25 import com.google.gwt.view.client.Range; | 25 import com.google.gwt.view.client.Range; |
26 import com.google.gwt.view.client.RangeChangeEvent; | 26 import com.google.gwt.view.client.RangeChangeEvent; |
27 import com.google.gwt.core.client.GWT; | 27 import com.google.gwt.core.client.GWT; |
28 import com.google.gwt.core.client.JsArrayString; | |
28 import com.google.gwt.dom.client.NodeList; | 29 import com.google.gwt.dom.client.NodeList; |
29 import com.google.gwt.dom.client.Style.BorderStyle; | 30 import com.google.gwt.dom.client.Style.BorderStyle; |
30 import com.google.gwt.dom.client.Style.Unit; | 31 import com.google.gwt.dom.client.Style.Unit; |
31 import com.google.gwt.dom.client.TableCellElement; | 32 import com.google.gwt.dom.client.TableCellElement; |
32 import com.google.gwt.event.dom.client.ClickHandler; | 33 import com.google.gwt.event.dom.client.ClickHandler; |
300 return object.getDescription(); | 301 return object.getDescription(); |
301 } | 302 } |
302 }; | 303 }; |
303 descriptionColumn.setSortable(true); | 304 descriptionColumn.setSortable(true); |
304 this.elementsTable.addColumn(descriptionColumn, "Description"); | 305 this.elementsTable.addColumn(descriptionColumn, "Description"); |
305 | 306 |
306 SimplePager pager = new SimplePager(); | 307 SimplePager pager = new SimplePager(); |
307 pager.setDisplay(this.elementsTable); | 308 pager.setDisplay(this.elementsTable); |
308 | 309 |
309 dataProvider.setList(this.actualObjectSet); | 310 dataProvider.setList(this.actualObjectSet); |
310 | 311 |
311 //The actual (at this time lexicographical) sorting routine. | 312 //The actual (at this time lexicographical) sorting routine. |
312 //TODO: remove redundant code, make this more abstract | 313 //TODO: remove redundant code, make this more abstract |
313 ListHandler<DataObject> columnSortHandler = new ListHandler<econnect.wp3_3.client.core.DataObject>(dataProvider.getList()); | 314 ListHandler<DataObject> columnSortHandler = new ListHandler<econnect.wp3_3.client.core.DataObject>(dataProvider.getList()); |
315 | |
316 JsArrayString descriptionDataColumns = this.dataSet.getDescriptionDataColumns(); | |
317 for (int i = 0; i < descriptionDataColumns.length(); i++) { | |
318 final String columnName = descriptionDataColumns.get(i); | |
319 | |
320 TextColumn<DataObject> column = new TextColumn<DataObject>() { | |
321 @Override | |
322 public String getValue(DataObject object) { | |
323 return object.getDescriptionData(columnName); | |
324 } | |
325 }; | |
326 | |
327 column.setSortable(true); | |
328 | |
329 columnSortHandler.setComparator(column, | |
330 new Comparator<econnect.wp3_3.client.core.DataObject>() { | |
331 public int compare(econnect.wp3_3.client.core.DataObject o1, econnect.wp3_3.client.core.DataObject o2) { | |
332 if (o1 == o2) | |
333 return 0; | |
334 | |
335 if (o1 != null) | |
336 return (o2 != null) ? o1.getDescriptionData(columnName).compareTo(o2.getDescriptionData(columnName)) : 1; | |
337 | |
338 return -1; | |
339 } | |
340 }); | |
341 | |
342 this.elementsTable.addColumn(column, columnName); | |
343 } | |
344 | |
314 columnSortHandler.setComparator(nameColumn, | 345 columnSortHandler.setComparator(nameColumn, |
315 new Comparator<econnect.wp3_3.client.core.DataObject>() { | 346 new Comparator<econnect.wp3_3.client.core.DataObject>() { |
316 public int compare(econnect.wp3_3.client.core.DataObject o1, econnect.wp3_3.client.core.DataObject o2) { | 347 public int compare(econnect.wp3_3.client.core.DataObject o1, econnect.wp3_3.client.core.DataObject o2) { |
317 if (o1 == o2) | 348 if (o1 == o2) |
318 return 0; | 349 return 0; |
321 return (o2 != null) ? o1.getName().compareTo(o2.getName()) : 1; | 352 return (o2 != null) ? o1.getName().compareTo(o2.getName()) : 1; |
322 | 353 |
323 return -1; | 354 return -1; |
324 } | 355 } |
325 }); | 356 }); |
357 | |
326 columnSortHandler.setComparator(placeColumn, | 358 columnSortHandler.setComparator(placeColumn, |
327 new Comparator<econnect.wp3_3.client.core.DataObject>() { | 359 new Comparator<econnect.wp3_3.client.core.DataObject>() { |
328 public int compare(econnect.wp3_3.client.core.DataObject o1, econnect.wp3_3.client.core.DataObject o2) { | 360 public int compare(econnect.wp3_3.client.core.DataObject o1, econnect.wp3_3.client.core.DataObject o2) { |
329 if (o1 == o2) | 361 if (o1 == o2) |
330 return 0; | 362 return 0; |