1
|
/**
|
2
|
* Copyright (C) 2007 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.key.polytomous.e4;
|
10
|
|
11
|
import javax.annotation.PostConstruct;
|
12
|
import javax.inject.Inject;
|
13
|
import javax.inject.Named;
|
14
|
|
15
|
import org.eclipse.e4.ui.services.EMenuService;
|
16
|
import org.eclipse.e4.ui.services.IServiceConstants;
|
17
|
import org.eclipse.jface.viewers.IBaseLabelProvider;
|
18
|
import org.eclipse.jface.viewers.IContentProvider;
|
19
|
import org.eclipse.swt.SWT;
|
20
|
import org.eclipse.swt.events.ControlEvent;
|
21
|
import org.eclipse.swt.events.ControlListener;
|
22
|
import org.eclipse.swt.layout.FillLayout;
|
23
|
import org.eclipse.swt.widgets.Composite;
|
24
|
import org.eclipse.swt.widgets.Shell;
|
25
|
import org.eclipse.zest.core.viewers.GraphViewer;
|
26
|
import org.eclipse.zest.core.widgets.ZestStyles;
|
27
|
|
28
|
import eu.etaxonomy.cdm.model.description.PolytomousKey;
|
29
|
import eu.etaxonomy.taxeditor.editor.key.e4.AbstractGraphKeyEditorE4;
|
30
|
import eu.etaxonomy.taxeditor.editor.key.polytomous.IPolytomousKeyEditorPage;
|
31
|
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyGraphContentProvider;
|
32
|
import eu.etaxonomy.taxeditor.editor.key.polytomous.PolytomousKeyLabelProvider;
|
33
|
import eu.etaxonomy.taxeditor.model.IPartContentHasDetails;
|
34
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
35
|
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
|
36
|
|
37
|
/**
|
38
|
* @author n.hoffmann
|
39
|
*/
|
40
|
public class PolytomousKeyGraphEditorE4
|
41
|
extends AbstractGraphKeyEditorE4<PolytomousKey>
|
42
|
implements IPolytomousKeyEditorPage, IPartContentHasDetails {
|
43
|
|
44
|
public static final String ID = "eu.etaxonomy.taxeditor.editor.key.polytomous.graph"; //$NON-NLS-1$
|
45
|
|
46
|
@Inject
|
47
|
public PolytomousKeyGraphEditorE4() {
|
48
|
}
|
49
|
|
50
|
@PostConstruct
|
51
|
public void createPartControl(Composite parent, EMenuService menuService,
|
52
|
@Named(IServiceConstants.ACTIVE_SHELL)Shell shell) {
|
53
|
if(!CdmStore.isActive()){
|
54
|
return;
|
55
|
}
|
56
|
|
57
|
formFactory = new CdmFormFactory(shell.getDisplay());
|
58
|
container = formFactory.createComposite(parent);
|
59
|
|
60
|
container.setLayout(new FillLayout());
|
61
|
viewer = new GraphViewer(container, SWT.NONE);
|
62
|
|
63
|
viewer.setContentProvider(getContentProvider());
|
64
|
viewer.setLabelProvider(getLabelProvider());
|
65
|
|
66
|
viewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
|
67
|
|
68
|
viewer.setLayoutAlgorithm(getLayoutAlgoritm(), false);
|
69
|
|
70
|
//propagate selection
|
71
|
selectionChangedListener = (event -> selService.setSelection(event.getSelection()));
|
72
|
viewer.addSelectionChangedListener(selectionChangedListener);
|
73
|
|
74
|
//create context menu
|
75
|
menuService.registerContextMenu(viewer.getControl(), "eu.etaxonomy.taxeditor.editor.popupmenu.polytomouskeygrapheditor");
|
76
|
|
77
|
//FIXME E4 migrate
|
78
|
// createToolbar();
|
79
|
|
80
|
container.addControlListener(new ControlListener() {
|
81
|
|
82
|
@Override
|
83
|
public void controlResized(ControlEvent e) {
|
84
|
// applyLayout();
|
85
|
}
|
86
|
|
87
|
@Override
|
88
|
public void controlMoved(ControlEvent e) {
|
89
|
|
90
|
}
|
91
|
});
|
92
|
}
|
93
|
|
94
|
|
95
|
@Override
|
96
|
public PolytomousKey getKey() {
|
97
|
return getEditorInput().getKey();
|
98
|
}
|
99
|
|
100
|
@Override
|
101
|
protected IBaseLabelProvider getLabelProvider() {
|
102
|
return new PolytomousKeyLabelProvider();
|
103
|
}
|
104
|
|
105
|
@Override
|
106
|
protected IContentProvider getContentProvider() {
|
107
|
return new PolytomousKeyGraphContentProvider();
|
108
|
}
|
109
|
}
|