Revision 51308344
Added by Patrick Plitzner over 5 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/descriptiveDataSet/matrix/CellSelectionListener.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
import java.util.Collection; |
13 | 13 |
|
14 |
import org.eclipse.e4.ui.workbench.modeling.ESelectionService; |
|
14 | 15 |
import org.eclipse.jface.viewers.StructuredSelection; |
15 |
import org.eclipse.nebula.widgets.nattable.layer.ILayerListener; |
|
16 |
import org.eclipse.nebula.widgets.nattable.data.IRowDataProvider; |
|
17 |
import org.eclipse.nebula.widgets.nattable.extension.e4.selection.E4SelectionListener; |
|
16 | 18 |
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell; |
17 | 19 |
import org.eclipse.nebula.widgets.nattable.layer.event.ILayerEvent; |
20 |
import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; |
|
18 | 21 |
import org.eclipse.nebula.widgets.nattable.selection.event.CellSelectionEvent; |
22 |
import org.eclipse.nebula.widgets.nattable.selection.event.RowSelectionEvent; |
|
23 |
|
|
24 |
import eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO; |
|
19 | 25 |
|
20 | 26 |
/** |
21 | 27 |
* @author pplitzner |
22 | 28 |
* @date 09.07.2018 |
23 | 29 |
* |
24 | 30 |
*/ |
25 |
final class CellSelectionListener implements ILayerListener {
|
|
31 |
final class CellSelectionListener extends E4SelectionListener<Object> {
|
|
26 | 32 |
|
27 | 33 |
private CharacterMatrixPart part; |
28 | 34 |
|
29 |
public CellSelectionListener(CharacterMatrixPart part) { |
|
30 |
super(); |
|
35 |
public CellSelectionListener( |
|
36 |
ESelectionService service, |
|
37 |
SelectionLayer selectionLayer, |
|
38 |
IRowDataProvider<Object> rowDataProvider, |
|
39 |
CharacterMatrixPart part) { |
|
40 |
super(service, selectionLayer, rowDataProvider); |
|
31 | 41 |
this.part = part; |
32 | 42 |
} |
33 | 43 |
|
... | ... | |
36 | 46 |
if(event instanceof CellSelectionEvent){ |
37 | 47 |
CellSelectionEvent cellSelectionEvent = (CellSelectionEvent)event; |
38 | 48 |
int columnPosition = cellSelectionEvent.getColumnPosition(); |
39 |
if(columnPosition>CharacterMatrix.LEADING_COLUMN_COUNT){ |
|
49 |
if(columnPosition>=CharacterMatrix.LEADING_COLUMN_COUNT){
|
|
40 | 50 |
Collection<ILayerCell> selectedCells = cellSelectionEvent.getSelectionLayer().getSelectedCells(); |
41 |
StructuredSelection selection = new StructuredSelection(); |
|
42 | 51 |
if(selectedCells.size()==1){ |
43 | 52 |
ILayerCell cell = selectedCells.iterator().next(); |
44 | 53 |
Object dataValue = cell.getDataValue(); |
45 | 54 |
if(dataValue!=null){ |
46 |
selection = new StructuredSelection(dataValue);
|
|
55 |
part.getSelectionService().setSelection(new StructuredSelection(dataValue));
|
|
47 | 56 |
} |
48 | 57 |
} |
49 |
part.getSelectionService().setSelection(selection); |
|
50 | 58 |
} |
51 | 59 |
} |
60 |
else if(event instanceof RowSelectionEvent){ |
|
61 |
RowSelectionEvent rowSelectionEvent = (RowSelectionEvent) event; |
|
62 |
int[] fullySelectedRowPositions = rowSelectionEvent.getSelectionLayer().getFullySelectedRowPositions(); |
|
63 |
if(fullySelectedRowPositions.length==1){ |
|
64 |
Object rowObject = part.getMatrix().getBodyDataProvider().getRowObject(fullySelectedRowPositions[0]); |
|
65 |
if(rowObject instanceof RowWrapperDTO){ |
|
66 |
part.getSelectionService().setSelection(new StructuredSelection(((RowWrapperDTO) rowObject).getDescription())); |
|
67 |
} |
|
68 |
} |
|
69 |
} |
|
70 |
else{ |
|
71 |
super.handleLayerEvent(event); |
|
72 |
} |
|
52 | 73 |
} |
53 | 74 |
} |
Also available in: Unified diff
ref #7674 Allow editing descriptions in details view