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.bulkeditor.e4;
|
10
|
|
11
|
import org.eclipse.nebula.widgets.nattable.NatTable;
|
12
|
import org.eclipse.nebula.widgets.nattable.data.ListDataProvider;
|
13
|
import org.eclipse.nebula.widgets.nattable.grid.data.DefaultColumnHeaderDataProvider;
|
14
|
import org.eclipse.nebula.widgets.nattable.layer.LabelStack;
|
15
|
import org.eclipse.nebula.widgets.nattable.layer.cell.IConfigLabelAccumulator;
|
16
|
|
17
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
18
|
import eu.etaxonomy.taxeditor.bulkeditor.input.AbstractBulkEditorInput;
|
19
|
|
20
|
/**
|
21
|
* @author pplitzner
|
22
|
* @since Jul 6, 2018
|
23
|
*
|
24
|
*/
|
25
|
public class BulkEditorConfigLabelAccumulator implements IConfigLabelAccumulator {
|
26
|
|
27
|
public static final String BOOLEAN_COLUMN = "boolean_column";
|
28
|
|
29
|
private ListDataProvider<CdmBase> dataProvider;
|
30
|
private AbstractBulkEditorInput input;
|
31
|
private NatTable natTable;
|
32
|
private DefaultColumnHeaderDataProvider colHeaderDataProvider;
|
33
|
|
34
|
public BulkEditorConfigLabelAccumulator(NatTable natTable, ListDataProvider<CdmBase> dataProvider,
|
35
|
DefaultColumnHeaderDataProvider colHeaderDataProvider, AbstractBulkEditorInput input) {
|
36
|
super();
|
37
|
this.dataProvider = dataProvider;
|
38
|
this.colHeaderDataProvider = colHeaderDataProvider;
|
39
|
this.input = input;
|
40
|
this.natTable = natTable;
|
41
|
}
|
42
|
|
43
|
|
44
|
@Override
|
45
|
public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
|
46
|
if(rowPosition<0){
|
47
|
return;
|
48
|
}
|
49
|
if(input.isBooleanProperty(colHeaderDataProvider.getColumnHeaderLabel(columnPosition))){
|
50
|
configLabels.addLabel(BOOLEAN_COLUMN);
|
51
|
}
|
52
|
CdmBase rowObject = dataProvider.getRowObject(rowPosition);
|
53
|
if(input.getMergeCandidates().contains(rowObject)){
|
54
|
configLabels.addLabel(BulkEditorE4Composite.LABEL_CANDIDATE);
|
55
|
if(columnPosition==0){
|
56
|
configLabels.addLabel(BulkEditorE4Composite.LABEL_CANDIDATE_ICON);
|
57
|
}
|
58
|
}
|
59
|
else if(input.getMergeTarget()==rowObject){
|
60
|
configLabels.addLabel(BulkEditorE4Composite.LABEL_TARGET);
|
61
|
if(columnPosition==0){
|
62
|
configLabels.addLabel(BulkEditorE4Composite.LABEL_TARGET_ICON);
|
63
|
}
|
64
|
}
|
65
|
}
|
66
|
}
|