2 * Copyright (C) 2018 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.checklist
.e4
;
11 import java
.util
.Comparator
;
12 import java
.util
.List
;
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
;
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
;
33 public class BodyLayerStack
<T
> extends AbstractLayerTransform
{
34 private final FilterList
<T
> filterList
;
36 private final ListDataProvider
<T
> bodyDataProvider
;
38 private final SelectionLayer selectionLayer
;
39 private final ViewportLayer viewportLayer
;
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
);
50 this.bodyDataProvider
=
51 new ListDataProvider
<>(this.filterList
, columnPropertyAccessor
);
53 DataLayer bodyDataLayer
= new DataLayer(bodyDataProvider
);
54 bodyDataLayer
.setConfigLabelAccumulator(labelAccumulator
);
56 // // layer for event handling of GlazedLists and PropertyChanges
57 // GlazedListsEventLayer<T> glazedListsEventLayer =
58 // new GlazedListsEventLayer<>(bodyDataLayer, this.filterList);
60 this.selectionLayer
= new SelectionLayer(bodyDataLayer
);
61 viewportLayer
= new ViewportLayer(getSelectionLayer());
63 setUnderlyingLayer(viewportLayer
);
66 public SelectionLayer
getSelectionLayer() {
67 return this.selectionLayer
;
70 public ViewportLayer
getViewPortLayer() {
71 return this.viewportLayer
;
74 public FilterList
<T
> getFilterList() {
75 return this.filterList
;
78 public ListDataProvider
<T
> getBodyDataProvider() {
79 return this.bodyDataProvider
;