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
.descriptiveDataSet
;
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
.persistence
.dto
.TaxonNodeDto
;
25 public class TaxonNodeDropAdapter
extends ViewerDropAdapter
{
27 private DescriptiveDataSetEditor descriptiveDataSetEditor
;
29 public TaxonNodeDropAdapter(DescriptiveDataSetEditor descriptiveDataSetEditor
) {
30 super(descriptiveDataSetEditor
.getTaxonTreeViewer());
31 this.descriptiveDataSetEditor
= descriptiveDataSetEditor
;
38 public boolean performDrop(Object data
) {
39 TaxonNodeDto taxonNodeDto
= (TaxonNodeDto
) ((ITreeSelection
) data
).getFirstElement();
40 descriptiveDataSetEditor
.addTaxonNode(taxonNodeDto
);
41 descriptiveDataSetEditor
.setFocus();
49 public boolean validateDrop(Object target
, int operation
, TransferData transferType
) {
50 ISelection selection
= LocalSelectionTransfer
.getTransfer().getSelection();
51 if(selection
instanceof ITreeSelection
52 && ((IStructuredSelection
) selection
).size()==1
53 && ((IStructuredSelection
) selection
).getFirstElement() instanceof TaxonNodeDto
){