Project

General

Profile

Download (3.2 KB) Statistics
| Branch: | Tag: | Revision:
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.cdm.model.common.CdmBase;
24
import eu.etaxonomy.taxeditor.editor.l10n.Messages;
25
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDragListener;
26
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementDropAdapter;
27
import eu.etaxonomy.taxeditor.editor.view.descriptive.DescriptionElementTransfer;
28
import eu.etaxonomy.taxeditor.editor.view.descriptive.e4.FactualDataPartE4;
29
import eu.etaxonomy.taxeditor.editor.view.uses.UsesContentProvider;
30
import eu.etaxonomy.taxeditor.editor.view.uses.UsesLabelProvider;
31
import eu.etaxonomy.taxeditor.model.AbstractUtility;
32

    
33

    
34
/**
35
 *
36
 * @author pplitzner
37
 * @since Sep 8, 2017
38
 *
39
 */
40
public class UsesViewPartE4 extends FactualDataPartE4 {
41

    
42
    //FIXME E4 implement delete handler
43

    
44
    @Override
45
    @PostConstruct
46
    public void create(Composite parent, EMenuService menuService, MPart thisPart,
47
            IEclipseContext context) {
48

    
49
        this.thisPart = thisPart;
50

    
51
        TreeViewer treeViewer = new TreeViewer(new Tree(parent, SWT.H_SCROLL
52
                | SWT.V_SCROLL | SWT.FULL_SELECTION));
53
        treeViewer.setContentProvider(new UsesContentProvider(featureNodeContainerCache));
54
        treeViewer.setLabelProvider(new UsesLabelProvider());
55
        treeViewer.setAutoExpandLevel(2);
56

    
57
        Transfer[] transfers = new Transfer[] { DescriptionElementTransfer.getInstance() };
58
        treeViewer.addDragSupport(dndOperations, transfers, new DescriptionElementDragListener(
59
                this));
60
        DescriptionElementDropAdapter dropListener = new DescriptionElementDropAdapter(treeViewer);
61
        ContextInjectionFactory.inject(dropListener, context);
62
        treeViewer.addDropSupport(dndOperations, transfers,
63
                dropListener);
64

    
65

    
66

    
67
        // Propagate selection from viewer
68
        selectionChangedListener = (event -> selService.setSelection(AbstractUtility.getElementsFromSelectionChangedEvent(event)));
69
        treeViewer.addSelectionChangedListener(selectionChangedListener);
70

    
71
        //create context menu
72
        menuService.registerContextMenu(treeViewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.usesView");
73

    
74
        viewer = treeViewer;
75
    }
76

    
77
    @Override
78
    protected String getViewName(){
79
        return Messages.UsesViewPart_VIEWER_NAME;
80
    }
81

    
82
    /** {@inheritDoc} */
83
    @Override
84
    public boolean postOperation(CdmBase objectAffectedByOperation) {
85
        viewer.refresh();
86
        return super.postOperation(objectAffectedByOperation);
87
    }
88

    
89
}
    (1-1/1)