Revision 63d2e106
Added by Patrick Plitzner about 6 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/dnd/CdmAuthorityTableDropTargetListener.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.dnd; |
10 | 10 |
|
11 |
import java.util.Collection; |
|
11 | 12 |
import java.util.Iterator; |
12 | 13 |
|
13 |
import org.eclipse.jface.util.LocalSelectionTransfer; |
|
14 |
import org.eclipse.jface.viewers.ISelection; |
|
15 |
import org.eclipse.jface.viewers.TreeSelection; |
|
14 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
16 | 15 |
import org.eclipse.swt.dnd.DropTargetEvent; |
17 | 16 |
import org.eclipse.swt.dnd.DropTargetListener; |
18 | 17 |
|
... | ... | |
54 | 53 |
|
55 | 54 |
@Override |
56 | 55 |
public void drop(DropTargetEvent dtevent) { |
57 |
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection(); |
|
58 |
if (selection instanceof TreeSelection) { |
|
59 |
|
|
60 |
Iterator<?> selectionIterator = ((TreeSelection) selection).iterator(); |
|
56 |
Object data = dtevent.data; |
|
57 |
if (data instanceof IStructuredSelection) { |
|
58 |
Iterator<?> selectionIterator = ((IStructuredSelection) dtevent.data).iterator(); |
|
59 |
while (selectionIterator.hasNext()){ |
|
60 |
addAuthority(selectionIterator.next()); |
|
61 |
} |
|
62 |
} |
|
63 |
else if(data instanceof Object[]) { |
|
64 |
for(int i=0;i<((Object[])data).length;i++){ |
|
65 |
addAuthority(((Object[])data)[i]); |
|
66 |
} |
|
67 |
} |
|
68 |
else if(data instanceof Collection) { |
|
69 |
((Collection) data).forEach(d->addAuthority(d)); |
|
70 |
} |
|
71 |
else{ |
|
72 |
addAuthority(data); |
|
73 |
} |
|
74 |
} |
|
61 | 75 |
|
62 |
while (selectionIterator.hasNext()){ |
|
63 |
Object next = selectionIterator.next(); |
|
64 |
if(CdmBase.class.isAssignableFrom(next.getClass()) ) { |
|
65 |
viewer.addCdmAuthority((CdmBase)next); |
|
66 |
} |
|
67 |
} |
|
68 |
} |
|
76 |
private void addAuthority(Object authority){ |
|
77 |
if(CdmBase.class.isAssignableFrom(authority.getClass()) ) { |
|
78 |
viewer.addCdmAuthority((CdmBase)authority); |
|
79 |
} |
|
69 | 80 |
} |
70 | 81 |
|
71 | 82 |
@Override |
Also available in: Unified diff
ref #6779 Allow dragging of features into authority editor