2 * Copyright (C) 2011 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.taxeditor
.editor
.view
.uses
.e4
;
11 import javax
.annotation
.PostConstruct
;
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
;
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
;
35 public class UsesViewPartE4
extends FactualDataPartE4
{
37 //FIXME E4 implement delete handler
41 public void create(Composite parent
, EMenuService menuService
, MPart thisPart
,
42 IEclipseContext context
) {
44 this.thisPart
= thisPart
;
46 TreeViewer treeViewer
= new TreeViewer(new Tree(parent
, SWT
.H_SCROLL
47 | SWT
.V_SCROLL
| SWT
.FULL_SELECTION
| SWT
.MULTI
));
48 treeViewer
.setContentProvider(new UsesContentProvider(featureNodeContainerCache
));
49 treeViewer
.setLabelProvider(new UsesLabelProvider());
50 treeViewer
.setAutoExpandLevel(2);
52 Transfer
[] transfers
= new Transfer
[] { DescriptionElementTransfer
.getInstance() };
53 treeViewer
.addDragSupport(dndOperations
, transfers
, new DescriptionElementDragListener(
55 DescriptionElementDropAdapter dropListener
= new DescriptionElementDropAdapter(treeViewer
);
56 ContextInjectionFactory
.inject(dropListener
, context
);
57 treeViewer
.addDropSupport(dndOperations
, transfers
,
60 // Propagate selection from viewer
61 selectionChangedListener
= (event
-> selService
.setSelection(event
.getSelection()));
62 treeViewer
.addSelectionChangedListener(selectionChangedListener
);
65 menuService
.registerContextMenu(treeViewer
.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.usesView");
71 protected String
getViewName(){
72 return Messages
.UsesViewPart_VIEWER_NAME
;
76 public boolean postOperation(Object objectAffectedByOperation
) {
78 return super.postOperation(objectAffectedByOperation
);