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.selection.SelectionLayer;
|
24
|
import org.eclipse.nebula.widgets.nattable.util.IClientAreaProvider;
|
25
|
import org.eclipse.nebula.widgets.nattable.viewport.ViewportLayer;
|
26
|
|
27
|
/**
|
28
|
* @author pplitzner
|
29
|
* @since Aug 20, 2019
|
30
|
*
|
31
|
*/
|
32
|
public class MatrixBodyLayerStack extends AbstractIndexLayerTransform {
|
33
|
|
34
|
private final ColumnHideShowLayer columnHideShowLayer;
|
35
|
private final SelectionLayer selectionLayer;
|
36
|
private final ViewportLayer viewportLayer;
|
37
|
|
38
|
public MatrixBodyLayerStack(IUniqueIndexLayer underlyingLayer, LinkedList<ColumnGroupWrapper> columnGroups) {
|
39
|
if(columnGroups.isEmpty()){
|
40
|
this.columnHideShowLayer = new ColumnHideShowLayer(underlyingLayer);
|
41
|
this.selectionLayer = new SelectionLayer(this.columnHideShowLayer);
|
42
|
}
|
43
|
else{
|
44
|
ColumnGroupModel bottomModel = columnGroups.getLast().getModel();
|
45
|
ColumnGroupReorderLayer columnGroupReorderLayer = new ColumnGroupReorderLayer(underlyingLayer, bottomModel);
|
46
|
this.columnHideShowLayer = new ColumnHideShowLayer(columnGroupReorderLayer);
|
47
|
List<ColumnGroupModel> columnGroupModels = new ArrayList<>();
|
48
|
for(ColumnGroupWrapper columnGroup:columnGroups){
|
49
|
columnGroupModels.add(columnGroup.getModel());
|
50
|
}
|
51
|
Collections.reverse(columnGroupModels);
|
52
|
ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer = new ColumnGroupExpandCollapseLayer(this.columnHideShowLayer, columnGroupModels.toArray(new ColumnGroupModel[columnGroups.size()]));
|
53
|
this.selectionLayer = new SelectionLayer(columnGroupExpandCollapseLayer);
|
54
|
}
|
55
|
this.viewportLayer = new ViewportLayer(this.selectionLayer);
|
56
|
setUnderlyingLayer(this.viewportLayer);
|
57
|
|
58
|
registerCommandHandler(new CopyDataCommandHandler(this.selectionLayer));
|
59
|
}
|
60
|
|
61
|
@Override
|
62
|
public void setClientAreaProvider(IClientAreaProvider clientAreaProvider) {
|
63
|
super.setClientAreaProvider(clientAreaProvider);
|
64
|
}
|
65
|
|
66
|
public ColumnHideShowLayer getColumnHideShowLayer() {
|
67
|
return this.columnHideShowLayer;
|
68
|
}
|
69
|
|
70
|
public SelectionLayer getSelectionLayer() {
|
71
|
return this.selectionLayer;
|
72
|
}
|
73
|
|
74
|
public ViewportLayer getViewportLayer() {
|
75
|
return this.viewportLayer;
|
76
|
}
|
77
|
|
78
|
}
|