2 * Copyright (C) 2017 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
.featuretree
.e4
;
11 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
12 import org
.eclipse
.jface
.viewers
.TreeViewer
;
13 import org
.eclipse
.swt
.dnd
.DragSourceAdapter
;
14 import org
.eclipse
.swt
.dnd
.DragSourceEvent
;
16 import eu
.etaxonomy
.cdm
.model
.description
.FeatureNode
;
17 import eu
.etaxonomy
.taxeditor
.featuretree
.FeatureNodeTransfer
;
19 public class FeatureNodeDragListener
extends DragSourceAdapter
{
21 private final TreeViewer viewer
;
23 public FeatureNodeDragListener(TreeViewer viewer
) {
28 * Method declared on DragSourceListener
31 public void dragSetData(DragSourceEvent event
) {
32 IStructuredSelection selection
= (IStructuredSelection
) viewer
.getSelection();
33 FeatureNode
[] featureNodes
= (FeatureNode
[]) selection
.toList().toArray(new FeatureNode
[selection
.size()]);
34 if (FeatureNodeTransfer
.getInstance().isSupportedType(event
.dataType
)) {
35 event
.data
= featureNodes
;
40 * Method declared on DragSourceListener
43 public void dragStart(DragSourceEvent event
) {
44 event
.doit
= !viewer
.getSelection().isEmpty();