3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
;
13 import java
.util
.ArrayList
;
14 import java
.util
.List
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.swt
.dnd
.DND
;
18 import org
.eclipse
.swt
.dnd
.DragSourceAdapter
;
19 import org
.eclipse
.swt
.dnd
.DragSourceEvent
;
21 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
22 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
23 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
27 * @created Feb 8, 2011
30 public class DescriptionElementDragListener
extends DragSourceAdapter
{
32 private DescriptiveViewPart part
;
34 public DescriptionElementDragListener(DescriptiveViewPart part
){
39 * Method declared on DragSourceListener
41 public void dragFinished(DragSourceEvent event
) {
44 // FIXME what to do here?
45 if (event
.detail
!= DND
.DROP_NONE
) {
46 IStructuredSelection selection
= (IStructuredSelection
) part
.getViewer()
53 * Method declared on DragSourceListener
55 public void dragSetData(DragSourceEvent event
) {
56 IStructuredSelection selection
= (IStructuredSelection
) part
.getViewer()
58 List
<DescriptionElementBase
> descriptionElements
= new ArrayList
<DescriptionElementBase
>();
59 for (Object object
: selection
.toList()){
60 if(object
instanceof DescriptionBase
){
61 descriptionElements
.addAll(((DescriptionBase
) object
).getElements());
62 }else if(object
instanceof FeatureNodeContainer
){
63 descriptionElements
.addAll(((FeatureNodeContainer
) object
).getDescriptionElements());
64 }else if(object
instanceof DescriptionElementBase
){
65 descriptionElements
.add((DescriptionElementBase
)object
);
69 if (DescriptionElementTransfer
.getInstance().isSupportedType(
71 event
.data
= descriptionElements
.toArray(new DescriptionElementBase
[descriptionElements
.size()]);
76 * Method declared on DragSourceListener
78 public void dragStart(DragSourceEvent event
) {
79 event
.doit
= !part
.getViewer().getSelection().isEmpty();