2 * Copyright (C) 2019 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
.descriptiveDataSet
.matrix
;
11 import java
.util
.ArrayList
;
12 import java
.util
.Collections
;
13 import java
.util
.LinkedList
;
14 import java
.util
.List
;
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
;
32 public class MatrixBodyLayerStack
extends AbstractIndexLayerTransform
{
34 private final ColumnHideShowLayer columnHideShowLayer
;
35 private final SelectionLayer selectionLayer
;
36 private final ViewportLayer viewportLayer
;
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
);
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());
51 Collections
.reverse(columnGroupModels
);
52 ColumnGroupExpandCollapseLayer columnGroupExpandCollapseLayer
= new ColumnGroupExpandCollapseLayer(this.columnHideShowLayer
, columnGroupModels
.toArray(new ColumnGroupModel
[columnGroups
.size()]));
53 this.selectionLayer
= new SelectionLayer(columnGroupExpandCollapseLayer
);
55 this.viewportLayer
= new ViewportLayer(this.selectionLayer
);
56 setUnderlyingLayer(this.viewportLayer
);
58 registerCommandHandler(new CopyDataCommandHandler(this.selectionLayer
));
62 public void setClientAreaProvider(IClientAreaProvider clientAreaProvider
) {
63 super.setClientAreaProvider(clientAreaProvider
);
66 public ColumnHideShowLayer
getColumnHideShowLayer() {
67 return this.columnHideShowLayer
;
70 public SelectionLayer
getSelectionLayer() {
71 return this.selectionLayer
;
74 public ViewportLayer
getViewportLayer() {
75 return this.viewportLayer
;