1
|
/**
|
2
|
* Copyright (C) 2017 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.character;
|
10
|
|
11
|
import java.util.List;
|
12
|
|
13
|
import org.eclipse.jface.util.LocalSelectionTransfer;
|
14
|
import org.eclipse.jface.viewers.StructuredSelection;
|
15
|
import org.eclipse.jface.viewers.TreeSelection;
|
16
|
import org.eclipse.jface.viewers.TreeViewer;
|
17
|
import org.eclipse.swt.dnd.DragSourceEvent;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.description.Character;
|
20
|
import eu.etaxonomy.taxeditor.featuretree.e4.FeatureNodeDragListener;
|
21
|
|
22
|
/**
|
23
|
* @author pplitzner
|
24
|
* @since Jun 2, 2017
|
25
|
*
|
26
|
*/
|
27
|
public class CharacterDragListener extends FeatureNodeDragListener {
|
28
|
|
29
|
private TreeViewer structureViewer;
|
30
|
private TreeViewer propertyViewer;
|
31
|
|
32
|
public CharacterDragListener(TreeViewer structureViewer, TreeViewer propertyViewer) {
|
33
|
super(propertyViewer);
|
34
|
this.structureViewer = structureViewer;
|
35
|
this.propertyViewer = propertyViewer;
|
36
|
}
|
37
|
|
38
|
@Override
|
39
|
public void dragSetData(DragSourceEvent event) {
|
40
|
TreeSelection structureSelection = (TreeSelection) structureViewer.getSelection();
|
41
|
TreeSelection propertySelection = (TreeSelection) propertyViewer.getSelection();
|
42
|
if(structureSelection!=null && propertySelection!=null
|
43
|
&& !structureSelection.isEmpty() && !propertySelection.isEmpty()){
|
44
|
//create all possible characters
|
45
|
List<Character> characters = CharacterEditor.createCharacters(structureSelection, propertySelection);
|
46
|
|
47
|
LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(characters));
|
48
|
}
|
49
|
}
|
50
|
|
51
|
}
|