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
.editor
.workingSet
;
11 import org
.eclipse
.jface
.util
.LocalSelectionTransfer
;
12 import org
.eclipse
.jface
.viewers
.ISelection
;
13 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
14 import org
.eclipse
.jface
.viewers
.ITreeSelection
;
15 import org
.eclipse
.jface
.viewers
.ViewerDropAdapter
;
16 import org
.eclipse
.swt
.dnd
.TransferData
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonNode
;
25 public class TaxonNodeDropAdapter
extends ViewerDropAdapter
{
27 private WorkingSetEditor workingSetEditor
;
29 public TaxonNodeDropAdapter(WorkingSetEditor workingSetEditor
) {
30 super(workingSetEditor
.getTaxonTreeViewer());
31 this.workingSetEditor
= workingSetEditor
;
38 public boolean performDrop(Object data
) {
39 TaxonNode taxonNode
= (TaxonNode
) ((ITreeSelection
) data
).getFirstElement();
40 workingSetEditor
.addTaxonNode(taxonNode
);
48 public boolean validateDrop(Object target
, int operation
, TransferData transferType
) {
49 ISelection selection
= LocalSelectionTransfer
.getTransfer().getSelection();
50 if(selection
instanceof ITreeSelection
51 && ((IStructuredSelection
) selection
).size()==1
52 && ((IStructuredSelection
) selection
).getFirstElement() instanceof TaxonNode
){