1
|
/**
|
2
|
*
|
3
|
*/
|
4
|
package eu.etaxonomy.taxeditor.editor.view.concept.graph;
|
5
|
|
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;
|
19
|
|
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.editor.l10n.Messages;
|
24
|
import eu.etaxonomy.taxeditor.view.AbstractCdmEditorViewPart;
|
25
|
|
26
|
/**
|
27
|
* @author andreas
|
28
|
*
|
29
|
*/
|
30
|
public class ConceptGraphView extends AbstractCdmEditorViewPart {
|
31
|
|
32
|
public static final String ID = "eu.etaxonomy.taxeditor.editor.view.concept.graph"; //$NON-NLS-1$
|
33
|
|
34
|
private GraphViewer viewer;
|
35
|
private LayoutAlgorithm layoutAlgoritm;
|
36
|
|
37
|
/* (non-Javadoc)
|
38
|
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
|
39
|
*/
|
40
|
@Override
|
41
|
protected void selectionChanged_internal(IWorkbenchPart part, ISelection selection) {
|
42
|
|
43
|
// if(part instanceof ConceptGraphView){
|
44
|
// // ConceptGraphView is maximized
|
45
|
// return;
|
46
|
// }
|
47
|
|
48
|
if(EditorUtil.getActiveEditor() == null){
|
49
|
showEmptyPage();
|
50
|
return;
|
51
|
}
|
52
|
|
53
|
if(part instanceof BulkEditor){
|
54
|
showEmptyPage();
|
55
|
return;
|
56
|
}
|
57
|
|
58
|
|
59
|
if(part instanceof MultiPageTaxonEditor){
|
60
|
if(! part.equals(this.part)){
|
61
|
IEditorInput input = ((IEditorPart) part).getEditorInput();
|
62
|
showViewer(part, new StructuredSelection(input));
|
63
|
}
|
64
|
showViewer();
|
65
|
}
|
66
|
|
67
|
}
|
68
|
|
69
|
/* (non-Javadoc)
|
70
|
* @see eu.etaxonomy.taxeditor.operation.IPostOperationEnabled#onComplete()
|
71
|
*/
|
72
|
@Override
|
73
|
public boolean onComplete() {
|
74
|
// TODO IGNORED
|
75
|
return false;
|
76
|
}
|
77
|
|
78
|
/* (non-Javadoc)
|
79
|
* @see eu.etaxonomy.taxeditor.view.AbstractCdmViewPart#getViewer()
|
80
|
*/
|
81
|
@Override
|
82
|
public Viewer getViewer() {
|
83
|
return viewer;
|
84
|
}
|
85
|
|
86
|
/* (non-Javadoc)
|
87
|
* @see eu.etaxonomy.taxeditor.view.AbstractCdmViewPart#createViewer(org.eclipse.swt.widgets.Composite)
|
88
|
*/
|
89
|
@Override
|
90
|
public void createViewer(Composite parent) {
|
91
|
|
92
|
viewer = new GraphViewer(parent, SWT.NONE);
|
93
|
getSite().setSelectionProvider(viewer);
|
94
|
|
95
|
viewer.setContentProvider(new ConceptGraphContentProvider());
|
96
|
viewer.setLabelProvider(new ConceptGraphLabelProvider());
|
97
|
|
98
|
viewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
|
99
|
|
100
|
viewer.setLayoutAlgorithm(getLayoutAlgoritm(), false);
|
101
|
|
102
|
// createMenu();
|
103
|
//
|
104
|
// createToolbar();
|
105
|
|
106
|
|
107
|
}
|
108
|
|
109
|
private LayoutAlgorithm getLayoutAlgoritm() {
|
110
|
|
111
|
if (layoutAlgoritm == null) {
|
112
|
// layoutAlgoritm = new CompositeLayoutAlgorithm(
|
113
|
// LayoutStyles.NO_LAYOUT_NODE_RESIZING,
|
114
|
// new LayoutAlgorithm[] {
|
115
|
// new TreeLayoutAlgorithm(
|
116
|
// LayoutStyles.NO_LAYOUT_NODE_RESIZING),
|
117
|
// new HorizontalShift(
|
118
|
// LayoutStyles.NO_LAYOUT_NODE_RESIZING) });
|
119
|
|
120
|
layoutAlgoritm = new TreeLayoutAlgorithm(
|
121
|
LayoutStyles.NO_LAYOUT_NODE_RESIZING);
|
122
|
layoutAlgoritm.setEntityAspectRatio(0.5);
|
123
|
}
|
124
|
return layoutAlgoritm;
|
125
|
}
|
126
|
|
127
|
@Override
|
128
|
protected String getViewName() {
|
129
|
return Messages.ConceptGraphView_VIEWER_NAME;
|
130
|
}
|
131
|
|
132
|
|
133
|
}
|