1 | package de.uka.ipd.sdq.tcfmoop.views; |
2 | |
3 | import org.eclipse.jface.viewers.ITreeContentProvider; |
4 | import org.eclipse.jface.viewers.Viewer; |
5 | |
6 | import de.uka.ipd.sdq.tcfmoop.outputtree.Node; |
7 | import de.uka.ipd.sdq.tcfmoop.outputtree.Tree; |
8 | import de.uka.ipd.sdq.tcfmoop.outputtree.Node.NodeType; |
9 | |
10 | public class TerminationCriteriaViewContentProvider implements ITreeContentProvider { |
11 | |
12 | private Tree invisibleRoot = new Tree("Termination Criteria Manager Output", NodeType.NON_SPECIFIC); |
13 | |
14 | TerminationCriteriaView viewer; |
15 | |
16 | public TerminationCriteriaViewContentProvider(TerminationCriteriaView viewer) { |
17 | this.viewer = viewer; |
18 | } |
19 | |
20 | @Override |
21 | public void inputChanged(Viewer v, Object oldInput, Object newInput) { |
22 | } |
23 | |
24 | @Override |
25 | public void dispose() { |
26 | } |
27 | |
28 | @Override |
29 | public Object[] getElements(Object parent) { |
30 | if (parent.equals(viewer.getViewSite())) { |
31 | |
32 | updateContent(); |
33 | |
34 | return getChildren(invisibleRoot); |
35 | } |
36 | return getChildren(parent); |
37 | } |
38 | |
39 | @Override |
40 | public Object getParent(Object child) { |
41 | if (child instanceof Node) { |
42 | return ((Node) child).getParent(); |
43 | } |
44 | return null; |
45 | } |
46 | |
47 | @Override |
48 | public Object[] getChildren(Object parent) { |
49 | if (parent instanceof Node) { |
50 | return ((Node) parent).getChildren().toArray(); |
51 | } |
52 | return new Object[0]; |
53 | } |
54 | |
55 | @Override |
56 | public boolean hasChildren(Object parent) { |
57 | if (parent instanceof Node) { |
58 | return ((Node) parent).hasChildren(); |
59 | } |
60 | return false; |
61 | } |
62 | |
63 | private void updateContent() { |
64 | invisibleRoot.clearChildren(); |
65 | |
66 | if (viewer.terminationCriteriaManagerOutput != null) { |
67 | |
68 | this.invisibleRoot.attachSubtree(viewer.terminationCriteriaManagerOutput); |
69 | |
70 | } |
71 | |
72 | } |
73 | } |