2 * Copyright (C) 2007 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
.view
.descriptive
;
11 import java
.util
.ArrayList
;
12 import java
.util
.List
;
14 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
15 import org
.eclipse
.swt
.dnd
.DND
;
16 import org
.eclipse
.swt
.dnd
.DragSourceAdapter
;
17 import org
.eclipse
.swt
.dnd
.DragSourceEvent
;
19 import eu
.etaxonomy
.cdm
.hibernate
.HibernateProxyHelper
;
20 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionBase
;
21 import eu
.etaxonomy
.cdm
.model
.description
.DescriptionElementBase
;
22 import eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.e4
.FactualDataPartE4
;
23 import eu
.etaxonomy
.taxeditor
.model
.FeatureNodeContainer
;
27 * @created Feb 8, 2011
29 public class DescriptionElementDragListener
extends DragSourceAdapter
{
31 private FactualDataPartE4 part
;
32 private DescriptionBase
<?
> description
;
34 public DescriptionElementDragListener(FactualDataPartE4 part
){
39 * Method declared on DragSourceListener
42 public void dragFinished(DragSourceEvent event
) {
46 // FIXME what to do here?
47 if (event
.detail
!= DND
.DROP_NONE
) {
48 //IStructuredSelection selection = (IStructuredSelection) part.getViewer().getSelection();
49 part
.getViewer().refresh();
56 * Method declared on DragSourceListener
59 public void dragSetData(DragSourceEvent event
) {
60 IStructuredSelection selection
= (IStructuredSelection
) part
.getViewer()
62 List
<DescriptionElementBase
> descriptionElements
= new ArrayList
<DescriptionElementBase
>();
63 for (Object object
: selection
.toList()){
64 if(object
instanceof DescriptionBase
){
65 if (!((DescriptionBase
) object
).getElements().isEmpty()){
66 descriptionElements
.addAll(((DescriptionBase
) object
).getElements());
68 description
= HibernateProxyHelper
.deproxy(object
, DescriptionBase
.class);
70 }else if(object
instanceof FeatureNodeContainer
){
71 descriptionElements
.addAll(((FeatureNodeContainer
) object
).getDescriptionElements());
72 }else if(object
instanceof DescriptionElementBase
){
73 descriptionElements
.add((DescriptionElementBase
)object
);
77 if (DescriptionElementTransfer
.getInstance().isSupportedType(
79 if (!descriptionElements
.isEmpty()){
80 event
.data
= descriptionElements
.toArray(new DescriptionElementBase
[descriptionElements
.size()]);
87 * Method declared on DragSourceListener
90 public void dragStart(DragSourceEvent event
) {
91 event
.doit
= !part
.getViewer().getSelection().isEmpty();