3 * Copyright (C) 2018 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.editor
.descriptiveDataSet
.matrix
;
12 import java
.util
.Collection
;
14 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
15 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.ILayerListener
;
16 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.cell
.ILayerCell
;
17 import org
.eclipse
.nebula
.widgets
.nattable
.layer
.event
.ILayerEvent
;
18 import org
.eclipse
.nebula
.widgets
.nattable
.selection
.event
.CellSelectionEvent
;
25 final class CellSelectionListener
implements ILayerListener
{
27 private CharacterMatrixPart part
;
29 public CellSelectionListener(CharacterMatrixPart part
) {
35 public void handleLayerEvent(ILayerEvent event
) {
36 if(event
instanceof CellSelectionEvent
){
37 CellSelectionEvent cellSelectionEvent
= (CellSelectionEvent
)event
;
38 int columnPosition
= cellSelectionEvent
.getColumnPosition();
39 if(columnPosition
>CharacterMatrix
.LEADING_COLUMN_COUNT
){
40 Collection
<ILayerCell
> selectedCells
= cellSelectionEvent
.getSelectionLayer().getSelectedCells();
41 StructuredSelection selection
= new StructuredSelection();
42 if(selectedCells
.size()==1){
43 ILayerCell cell
= selectedCells
.iterator().next();
44 Object dataValue
= cell
.getDataValue();
46 selection
= new StructuredSelection(dataValue
);
49 part
.getSelectionService().setSelection(selection
);