1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
package eu.etaxonomy.taxeditor.dnd;
|
10
|
|
11
|
import java.util.Iterator;
|
12
|
|
13
|
import org.eclipse.jface.util.LocalSelectionTransfer;
|
14
|
import org.eclipse.jface.viewers.ISelection;
|
15
|
import org.eclipse.jface.viewers.TreeSelection;
|
16
|
import org.eclipse.swt.dnd.DropTargetEvent;
|
17
|
import org.eclipse.swt.dnd.DropTargetListener;
|
18
|
|
19
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
20
|
import eu.etaxonomy.taxeditor.ui.group.grantedauthority.CdmAuthorityComposite;
|
21
|
import eu.etaxonomy.taxeditor.ui.group.grantedauthority.CdmAuthorityCompositeViewer;
|
22
|
|
23
|
/**
|
24
|
* Drop listener for the {@link CdmAuthorityComposite}.
|
25
|
*
|
26
|
* @author cmathew
|
27
|
* @created Mar 28, 2013
|
28
|
*
|
29
|
*/
|
30
|
public class CdmAuthorityTableDropTargetListener implements DropTargetListener {
|
31
|
|
32
|
private CdmAuthorityCompositeViewer viewer;
|
33
|
|
34
|
|
35
|
public CdmAuthorityTableDropTargetListener(CdmAuthorityCompositeViewer viewer) {
|
36
|
this.viewer = viewer;
|
37
|
}
|
38
|
|
39
|
@Override
|
40
|
public void dragEnter(DropTargetEvent event) {
|
41
|
}
|
42
|
|
43
|
@Override
|
44
|
public void dragLeave(DropTargetEvent arg0) {
|
45
|
}
|
46
|
|
47
|
@Override
|
48
|
public void dragOperationChanged(DropTargetEvent arg0) {
|
49
|
}
|
50
|
|
51
|
@Override
|
52
|
public void dragOver(DropTargetEvent arg0) {
|
53
|
}
|
54
|
|
55
|
@Override
|
56
|
public void drop(DropTargetEvent dtevent) {
|
57
|
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
|
58
|
if (selection instanceof TreeSelection) {
|
59
|
|
60
|
Iterator<?> selectionIterator = ((TreeSelection) selection).iterator();
|
61
|
|
62
|
while (selectionIterator.hasNext()){
|
63
|
Object next = selectionIterator.next();
|
64
|
if(CdmBase.class.isAssignableFrom(next.getClass()) ) {
|
65
|
viewer.addCdmAuthority((CdmBase)next);
|
66
|
}
|
67
|
}
|
68
|
}
|
69
|
}
|
70
|
|
71
|
@Override
|
72
|
public void dropAccept(DropTargetEvent arg0) {
|
73
|
}
|
74
|
|
75
|
}
|