1
|
/**
|
2
|
* Copyright (C) 2019 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.descriptiveDataSet.matrix;
|
10
|
|
11
|
import java.util.ArrayList;
|
12
|
import java.util.Collections;
|
13
|
import java.util.LinkedList;
|
14
|
import java.util.List;
|
15
|
|
16
|
import org.eclipse.nebula.widgets.nattable.copy.command.CopyDataCommandHandler;
|
17
|
import org.eclipse.nebula.widgets.nattable.group.ColumnGroupExpandCollapseLayer;
|
18
|
import org.eclipse.nebula.widgets.nattable.group.ColumnGroupModel;
|
19
|
import org.eclipse.nebula.widgets.nattable.group.ColumnGroupReorderLayer;
|
20
|
import org.eclipse.nebula.widgets.nattable.hideshow.ColumnHideShowLayer;
|
21
|
import org.eclipse.nebula.widgets.nattable.layer.AbstractIndexLayerTransform;
|
22
|
import org.eclipse.nebula.widgets.nattable.layer.IUniqueIndexLayer;
|
23
|
import org.eclipse.nebula.widgets.nattable.reorder.ColumnReorderLayer;
|
24
|
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer;
|
25
|
import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider;
|
26
|
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
|
27
|
|
28
|
/**
|
29
|
* @author pplitzner
|
30
|
* @since Aug 20, 2019
|
31
|
*
|
32
|
*/
|
33
|
public class MatrixBodyLayerStack extends AbstractIndexLayerTransform {
|
34
|
|
35
|
private final ColumnReorderLayer columnReorderLayer;
|
36
|
private final ColumnHideShowLayer columnHideShowLayer;
|
37
|
private final ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer;
|
38
|
private final SelectionLayer selectionLayer;
|
39
|
private final ViewportLayer viewportLayer;
|
40
|
|
41
|
public MatrixBodyLayerStack(IUniqueIndexLayer underlyingLayer, LinkedList<ColumnGroupWrapper> columnGroups) {
|
42
|
this.columnReorderLayer = new ColumnReorderLayer(underlyingLayer);
|
43
|
ColumnGroupModel bottomModel = columnGroups.getLast().getModel();
|
44
|
ColumnGroupReorderLayer columnGroupReorderLayer = new ColumnGroupReorderLayer(this.columnReorderLayer, bottomModel);
|
45
|
this.columnHideShowLayer = new ColumnHideShowLayer(columnGroupReorderLayer);
|
46
|
List<ColumnGroupModel> columnGroupModels = new ArrayList<>();
|
47
|
for(ColumnGroupWrapper columnGroup:columnGroups){
|
48
|
columnGroupModels.add(columnGroup.getModel());
|
49
|
}
|
50
|
Collections.reverse(columnGroupModels);
|
51
|
this.columnGroupExpandCollapseLayer = new ColumnGroupExpandCollapseLayer(this.columnHideShowLayer, columnGroupModels.toArray(new ColumnGroupModel[columnGroups.size()]));
|
52
|
this.selectionLayer = new SelectionLayer(this.columnGroupExpandCollapseLayer);
|
53
|
this.viewportLayer = new ViewportLayer(this.selectionLayer);
|
54
|
setUnderlyingLayer(this.viewportLayer);
|
55
|
|
56
|
registerCommandHandler(new CopyDataCommandHandler(this.selectionLayer));
|
57
|
}
|
58
|
|
59
|
@Override
|
60
|
public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) {
|
61
|
super.setClientAreaProvider(clientAreaProvider);
|
62
|
}
|
63
|
|
64
|
public ColumnReorderLayer getColumnReorderLayer() {
|
65
|
return this.columnReorderLayer;
|
66
|
}
|
67
|
|
68
|
public ColumnHideShowLayer getColumnHideShowLayer() {
|
69
|
return this.columnHideShowLayer;
|
70
|
}
|
71
|
|
72
|
public ColumnGroupExpandCollapseLayer getColumnGroupExpandCollapseLayer() {
|
73
|
return this.columnGroupExpandCollapseLayer;
|
74
|
}
|
75
|
|
76
|
public SelectionLayer getSelectionLayer() {
|
77
|
return this.selectionLayer;
|
78
|
}
|
79
|
|
80
|
public ViewportLayer getViewportLayer() {
|
81
|
return this.viewportLayer;
|
82
|
}
|
83
|
|
84
|
}
|