4 package eu
.etaxonomy
.taxeditor
.editor
.view
.concept
.graph
.e4
;
6 import javax
.annotation
.PostConstruct
;
8 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
9 import org
.eclipse
.e4
.ui
.services
.EMenuService
;
10 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
11 import org
.eclipse
.jface
.viewers
.Viewer
;
12 import org
.eclipse
.swt
.SWT
;
13 import org
.eclipse
.swt
.widgets
.Composite
;
14 import org
.eclipse
.zest
.core
.viewers
.GraphViewer
;
15 import org
.eclipse
.zest
.core
.widgets
.ZestStyles
;
16 import org
.eclipse
.zest
.layouts
.LayoutAlgorithm
;
17 import org
.eclipse
.zest
.layouts
.LayoutStyles
;
18 import org
.eclipse
.zest
.layouts
.algorithms
.TreeLayoutAlgorithm
;
20 import eu
.etaxonomy
.taxeditor
.bulkeditor
.BulkEditor
;
21 import eu
.etaxonomy
.taxeditor
.editor
.e4
.TaxonEditorInputE4
;
22 import eu
.etaxonomy
.taxeditor
.editor
.l10n
.Messages
;
23 import eu
.etaxonomy
.taxeditor
.editor
.name
.e4
.TaxonNameEditorE4
;
24 import eu
.etaxonomy
.taxeditor
.editor
.view
.concept
.graph
.ConceptGraphContentProvider
;
25 import eu
.etaxonomy
.taxeditor
.editor
.view
.concept
.graph
.ConceptGraphLabelProvider
;
26 import eu
.etaxonomy
.taxeditor
.editor
.view
.descriptive
.e4
.FactualDataPartE4
;
27 import eu
.etaxonomy
.taxeditor
.editor
.view
.media
.e4
.MediaViewPartE4
;
28 import eu
.etaxonomy
.taxeditor
.model
.AbstractUtility
;
29 import eu
.etaxonomy
.taxeditor
.view
.e4
.AbstractCdmEditorPartE4
;
30 import eu
.etaxonomy
.taxeditor
.view
.e4
.details
.DetailsPartE4
;
31 import eu
.etaxonomy
.taxeditor
.view
.e4
.supplementaldata
.SupplementalDataPartE4
;
39 public class ConceptGraphViewE4
extends AbstractCdmEditorPartE4
{
41 public static final String ID
= "eu.etaxonomy.taxeditor.editor.view.concept.graph"; //$NON-NLS-1$
43 private LayoutAlgorithm layoutAlgoritm
;
49 public void selectionChanged_internal(Object selection
, MPart activePart
, MPart thisPart
) {
50 if(activePart
==thisPart
){
54 Object partObject
= createPartObject(activePart
);
56 if (partObject
instanceof DetailsPartE4
|| partObject
instanceof SupplementalDataPartE4
57 || partObject
instanceof FactualDataPartE4
|| partObject
instanceof MediaViewPartE4
) {
58 // do not show empty page as these views are also used to edit the
59 // description selected in this view
62 if(AbstractUtility
.getActiveEditor() == null){
67 if(partObject
instanceof BulkEditor
){
73 if(partObject
instanceof TaxonNameEditorE4
){
74 if (viewer
.getControl() != null && !viewer
.getControl().isDisposed()) {
75 viewer
.getControl().setEnabled(true);
77 TaxonEditorInputE4 input
= ((TaxonNameEditorE4
) partObject
).getEditorInput();
78 showViewer(new StructuredSelection(input
), activePart
, viewer
);
84 public boolean onComplete() {
89 public Viewer
getViewer() {
94 public void create(Composite parent
, EMenuService menuService
, MPart thisPart
) {
96 this.thisPart
= thisPart
;
98 GraphViewer viewer
= new GraphViewer(parent
, SWT
.NONE
);
100 viewer
.setContentProvider(new ConceptGraphContentProvider());
101 viewer
.setLabelProvider(new ConceptGraphLabelProvider());
103 viewer
.setConnectionStyle(ZestStyles
.CONNECTIONS_DIRECTED
);
105 viewer
.setLayoutAlgorithm(getLayoutAlgoritm(), false);
107 this.viewer
= viewer
;
109 // Propagate selection from viewer
110 selectionChangedListener
= (event
-> selService
.setSelection(AbstractUtility
.getElementsFromSelectionChangedEvent(event
)));
111 viewer
.addSelectionChangedListener(selectionChangedListener
);
120 private LayoutAlgorithm
getLayoutAlgoritm() {
122 if (layoutAlgoritm
== null) {
123 // layoutAlgoritm = new CompositeLayoutAlgorithm(
124 // LayoutStyles.NO_LAYOUT_NODE_RESIZING,
125 // new LayoutAlgorithm[] {
126 // new TreeLayoutAlgorithm(
127 // LayoutStyles.NO_LAYOUT_NODE_RESIZING),
128 // new HorizontalShift(
129 // LayoutStyles.NO_LAYOUT_NODE_RESIZING) });
131 layoutAlgoritm
= new TreeLayoutAlgorithm(
132 LayoutStyles
.NO_LAYOUT_NODE_RESIZING
);
133 layoutAlgoritm
.setEntityAspectRatio(0.5);
135 return layoutAlgoritm
;
139 protected String
getViewName() {
140 return Messages
.ConceptGraphView_VIEWER_NAME
;