4 package eu
.etaxonomy
.taxeditor
.editor
.view
.concept
.graph
;
6 import org
.eclipse
.jface
.viewers
.ISelection
;
7 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
8 import org
.eclipse
.jface
.viewers
.Viewer
;
9 import org
.eclipse
.swt
.SWT
;
10 import org
.eclipse
.swt
.widgets
.Composite
;
11 import org
.eclipse
.ui
.IEditorInput
;
12 import org
.eclipse
.ui
.IEditorPart
;
13 import org
.eclipse
.ui
.IWorkbenchPart
;
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
.EditorUtil
;
22 import eu
.etaxonomy
.taxeditor
.editor
.MultiPageTaxonEditor
;
23 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmEditorViewPart
;
29 public class ConceptGraphView
extends AbstractCdmEditorViewPart
{
31 public static final String ID
= "eu.etaxonomy.taxeditor.editor.view.concept.graph";
33 private GraphViewer viewer
;
34 private LayoutAlgorithm layoutAlgoritm
;
37 * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
40 protected void selectionChanged_internal(IWorkbenchPart part
, ISelection selection
) {
42 // if(part instanceof ConceptGraphView){
43 // // ConceptGraphView is maximized
47 if(EditorUtil
.getActiveEditor() == null){
52 if(part
instanceof BulkEditor
){
58 if(part
instanceof MultiPageTaxonEditor
){
59 if(! part
.equals(this.part
)){
60 IEditorInput input
= ((IEditorPart
) part
).getEditorInput();
61 showViewer(part
, new StructuredSelection(input
));
69 * @see eu.etaxonomy.taxeditor.operation.IPostOperationEnabled#onComplete()
72 public boolean onComplete() {
78 * @see eu.etaxonomy.taxeditor.view.AbstractCdmViewPart#getViewer()
81 public Viewer
getViewer() {
86 * @see eu.etaxonomy.taxeditor.view.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite)
89 public void createViewer(Composite parent
) {
91 viewer
= new GraphViewer(parent
, SWT
.NONE
);
92 getSite().setSelectionProvider(viewer
);
94 viewer
.setContentProvider(new ConceptGraphContentProvider());
95 viewer
.setLabelProvider(new ConceptGraphLabelProvider());
97 viewer
.setConnectionStyle(ZestStyles
.CONNECTIONS_DIRECTED
);
99 viewer
.setLayoutAlgorithm(getLayoutAlgoritm(), false);
108 private LayoutAlgorithm
getLayoutAlgoritm() {
110 if (layoutAlgoritm
== null) {
111 // layoutAlgoritm = new CompositeLayoutAlgorithm(
112 // LayoutStyles.NO_LAYOUT_NODE_RESIZING,
113 // new LayoutAlgorithm[] {
114 // new TreeLayoutAlgorithm(
115 // LayoutStyles.NO_LAYOUT_NODE_RESIZING),
116 // new HorizontalShift(
117 // LayoutStyles.NO_LAYOUT_NODE_RESIZING) });
119 layoutAlgoritm
= new TreeLayoutAlgorithm(
120 LayoutStyles
.NO_LAYOUT_NODE_RESIZING
);
121 layoutAlgoritm
.setEntityAspectRatio(0.5);
123 return layoutAlgoritm
;