1
|
/**
|
2
|
* Copyright (C) 2018 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.editor.view.checklist.e4;
|
10
|
|
11
|
import java.util.Comparator;
|
12
|
import java.util.List;
|
13
|
|
14
|
import org.eclipse.nebula.widgets.nattable.data.IColumnPropertyAccessor;
|
15
|
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
|
16
|
import org.eclipse.nebula.widgets.nattable.layer.AbstractLayerTransform;
|
17
|
import org.eclipse.nebula.widgets.nattable.layer.DataLayer;
|
18
|
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
|
19
|
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
|
20
|
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
|
21
|
|
22
|
import ca.odell.glazedlists.EventList;
|
23
|
import ca.odell.glazedlists.FilterList;
|
24
|
import ca.odell.glazedlists.GlazedLists;
|
25
|
import ca.odell.glazedlists.SortedList;
|
26
|
import ca.odell.glazedlists.TransformedList;
|
27
|
|
28
|
/**
|
29
|
* @author k.luther
|
30
|
* @since 13.12.2018
|
31
|
*
|
32
|
*/
|
33
|
public class BodyLayerStack<T> extends AbstractLayerTransform {
|
34
|
private final FilterList<T> filterList;
|
35
|
|
36
|
private final ListDataProvider<T> bodyDataProvider;
|
37
|
|
38
|
private final SelectionLayer selectionLayer;
|
39
|
private final ViewportLayer viewportLayer ;
|
40
|
|
41
|
public BodyLayerStack(List<T> values, IColumnPropertyAccessor<T> columnPropertyAccessor, Comparator<T> comparator, IConfigLabelAccumulator labelAccumulator) {
|
42
|
// wrapping of the list to show into GlazedLists
|
43
|
// see http://publicobject.com/glazedlists/ for further information
|
44
|
EventList<T> eventList = GlazedLists.eventList(values);
|
45
|
TransformedList<T, T> rowObjectsGlazedList = GlazedLists.threadSafeList(eventList);
|
46
|
SortedList<T> sortedList = new SortedList<>(rowObjectsGlazedList, comparator);
|
47
|
// wrap the SortedList with the FilterList
|
48
|
this.filterList = new FilterList<>(sortedList);
|
49
|
|
50
|
this.bodyDataProvider =
|
51
|
new ListDataProvider<>(this.filterList, columnPropertyAccessor);
|
52
|
|
53
|
DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);
|
54
|
bodyDataLayer.setConfigLabelAccumulator(labelAccumulator);
|
55
|
|
56
|
// // layer for event handling of GlazedLists and PropertyChanges
|
57
|
// GlazedListsEventLayer<T> glazedListsEventLayer =
|
58
|
// new GlazedListsEventLayer<>(bodyDataLayer, this.filterList);
|
59
|
|
60
|
this.selectionLayer = new SelectionLayer(bodyDataLayer);
|
61
|
viewportLayer = new ViewportLayer(getSelectionLayer());
|
62
|
|
63
|
setUnderlyingLayer(viewportLayer);
|
64
|
}
|
65
|
|
66
|
public SelectionLayer getSelectionLayer() {
|
67
|
return this.selectionLayer;
|
68
|
}
|
69
|
|
70
|
public ViewportLayer getViewPortLayer() {
|
71
|
return this.viewportLayer;
|
72
|
}
|
73
|
|
74
|
public FilterList<T> getFilterList() {
|
75
|
return this.filterList;
|
76
|
}
|
77
|
|
78
|
public ListDataProvider<T> getBodyDataProvider() {
|
79
|
return this.bodyDataProvider;
|
80
|
}
|
81
|
}
|