1
|
package eu.etaxonomy.taxeditor.navigation.navigator;
|
2
|
|
3
|
import org.eclipse.swt.dnd.DND;
|
4
|
import org.eclipse.swt.dnd.Transfer;
|
5
|
import org.eclipse.swt.widgets.Composite;
|
6
|
import org.eclipse.ui.internal.navigator.NavigatorContentService;
|
7
|
import org.eclipse.ui.internal.navigator.dnd.NavigatorDnDService;
|
8
|
import org.eclipse.ui.navigator.CommonDragAdapter;
|
9
|
import org.eclipse.ui.navigator.CommonDropAdapter;
|
10
|
import org.eclipse.ui.navigator.CommonViewer;
|
11
|
import org.eclipse.ui.navigator.INavigatorContentService;
|
12
|
|
13
|
import eu.etaxonomy.taxeditor.dnd.transfer.TaxonNodeTransfer;
|
14
|
|
15
|
public class TaxonNavigatorViewer extends CommonViewer {
|
16
|
|
17
|
private NavigatorContentService contentService;
|
18
|
String viewerId;
|
19
|
|
20
|
public TaxonNavigatorViewer(String aViewerId, Composite aParent, int aStyle) {
|
21
|
super(aViewerId, aParent, aStyle);
|
22
|
contentService = new TaxonNavigatorContentService(aViewerId, this);
|
23
|
viewerId = aViewerId;
|
24
|
}
|
25
|
|
26
|
@Override
|
27
|
protected void initDragAndDrop() {
|
28
|
|
29
|
int operations = DND.DROP_MOVE ;
|
30
|
|
31
|
CommonDragAdapter dragAdapter = createDragAdapter();
|
32
|
addDragSupport(operations, dragAdapter.getSupportedDragTransfers(),
|
33
|
dragAdapter);
|
34
|
Transfer[] transfers = new Transfer[] { TaxonNodeTransfer.getInstance() };
|
35
|
TreeNodeDropAdapter dropAdapter = createTreeNodeDropAdapter();
|
36
|
addDropSupport(operations, transfers, dropAdapter);
|
37
|
|
38
|
TaxonNavigatorDnDService dnd = (TaxonNavigatorDnDService)getNavigatorContentService().getDnDService();
|
39
|
dnd.setDropAdaptor(dropAdapter);
|
40
|
}
|
41
|
|
42
|
|
43
|
protected TreeNodeDropAdapter createTreeNodeDropAdapter() {
|
44
|
return new TreeNodeDropAdapter(this);
|
45
|
}
|
46
|
|
47
|
public NavigatorContentService getNavigatorContentService(){
|
48
|
if (contentService == null){
|
49
|
contentService = new TaxonNavigatorContentService(viewerId);
|
50
|
}
|
51
|
return contentService;
|
52
|
}
|
53
|
|
54
|
}
|