1
|
package eu.etaxonomy.taxeditor.navigation.navigator.dnd;
|
2
|
|
3
|
import java.util.ArrayList;
|
4
|
import java.util.List;
|
5
|
|
6
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
7
|
import org.eclipse.swt.dnd.DragSourceEvent;
|
8
|
import org.eclipse.swt.dnd.Transfer;
|
9
|
import org.eclipse.ui.navigator.CommonDragAdapterAssistant;
|
10
|
|
11
|
import eu.etaxonomy.cdm.model.taxon.TaxonNode;
|
12
|
import eu.etaxonomy.taxeditor.dnd.transfer.TaxonNodeTransfer;
|
13
|
|
14
|
public class TaxonNavigatorDragAdapterAssistant extends
|
15
|
CommonDragAdapterAssistant {
|
16
|
|
17
|
@Override
|
18
|
public Transfer[] getSupportedTransferTypes() {
|
19
|
return new Transfer[] { TaxonNodeTransfer.getInstance() };
|
20
|
}
|
21
|
|
22
|
@Override
|
23
|
public boolean setDragData(DragSourceEvent event,
|
24
|
IStructuredSelection selection) {
|
25
|
boolean setDataSuccess = false;
|
26
|
List<TaxonNode> taxonNodes = new ArrayList<TaxonNode>();
|
27
|
for (Object object : selection.toList()){
|
28
|
if(object instanceof TaxonNode){
|
29
|
taxonNodes.add(((TaxonNode) object));
|
30
|
setDataSuccess = true;
|
31
|
}
|
32
|
|
33
|
}
|
34
|
if (TaxonNodeTransfer.getInstance().isSupportedType(
|
35
|
event.dataType)) {
|
36
|
event.data = taxonNodes.toArray(new TaxonNode[taxonNodes.size()]);
|
37
|
}
|
38
|
return setDataSuccess;
|
39
|
}
|
40
|
|
41
|
}
|