1
|
/**
|
2
|
* Copyright (C) 2011 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.editor.view.uses.e4;
|
10
|
|
11
|
import javax.annotation.PostConstruct;
|
12
|
|
13
|
import org.eclipse.e4.core.contexts.ContextInjectionFactory;
|
14
|
import org.eclipse.e4.core.contexts.IEclipseContext;
|
15
|
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
|
16
|
import org.eclipse.e4.ui.services.EMenuService;
|
17
|
import org.eclipse.jface.viewers.TreeViewer;
|
18
|
import org.eclipse.swt.SWT;
|
19
|
import org.eclipse.swt.dnd.Transfer;
|
20
|
import org.eclipse.swt.widgets.Composite;
|
21
|
import org.eclipse.swt.widgets.Tree;
|
22
|
|
23
|
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
|
24
|
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;
|
25
|
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;
|
26
|
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;
|
27
|
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
|
28
|
import eu.etaxonomy.taxeditor.editor.view.uses.UsesContentProvider;
|
29
|
import eu.etaxonomy.taxeditor.editor.view.uses.UsesLabelProvider;
|
30
|
|
31
|
|
32
|
/**
|
33
|
* @author pplitzner
|
34
|
* @since Sep 8, 2017
|
35
|
*/
|
36
|
public class UsesViewPartE4 extends FactualDataPartE4 {
|
37
|
|
38
|
//FIXME E4 implement delete handler
|
39
|
|
40
|
@Override
|
41
|
@PostConstruct
|
42
|
public void create(Composite parent, EMenuService menuService, MPart thisPart,
|
43
|
IEclipseContext context) {
|
44
|
|
45
|
this.thisPart = thisPart;
|
46
|
|
47
|
TreeViewer treeViewer = new TreeViewer(new Tree(parent, SWT.H_SCROLL
|
48
|
| SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.MULTI));
|
49
|
treeViewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));
|
50
|
treeViewer.setLabelProvider(new UsesLabelProvider());
|
51
|
treeViewer.setAutoExpandLevel(2);
|
52
|
|
53
|
Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
|
54
|
treeViewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
|
55
|
this));
|
56
|
DescriptionElementDropAdapter dropListener = new DescriptionElementDropAdapter(treeViewer);
|
57
|
ContextInjectionFactory.inject(dropListener, context);
|
58
|
treeViewer.addDropSupport(dndOperations, transfers,
|
59
|
dropListener);
|
60
|
|
61
|
// Propagate selection from viewer
|
62
|
selectionChangedListener = (event -> selService.setSelection(event.getSelection()));
|
63
|
treeViewer.addSelectionChangedListener(selectionChangedListener);
|
64
|
|
65
|
//create context menu
|
66
|
menuService.registerContextMenu(treeViewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.usesView");
|
67
|
|
68
|
viewer = treeViewer;
|
69
|
}
|
70
|
|
71
|
@Override
|
72
|
protected String getViewName(){
|
73
|
return Messages.UsesViewPart_VIEWER_NAME;
|
74
|
}
|
75
|
|
76
|
@Override
|
77
|
public boolean postOperation(Object objectAffectedByOperation) {
|
78
|
viewer.refresh();
|
79
|
return super.postOperation(objectAffectedByOperation);
|
80
|
}
|
81
|
}
|