1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package pl.edu.agh.cast.ui.outline;
19
20 import java.util.Collection;
21
22 import org.eclipse.jface.viewers.LabelProvider;
23 import org.eclipse.swt.graphics.Image;
24
25 import pl.edu.agh.cast.model.visual.backward.Node;
26 import pl.edu.agh.cast.util.Images;
27 import pl.edu.agh.cast.util.Messages;
28
29
30
31
32
33
34 public class OutlineLabelProvider extends LabelProvider {
35
36 private static OutlineLabelProvider instance = new OutlineLabelProvider();
37
38
39
40
41 protected OutlineLabelProvider() {
42 }
43
44
45
46
47
48
49 public static OutlineLabelProvider getInstance() {
50 return instance;
51 }
52
53
54
55
56
57
58 @Override
59 public String getText(Object element) {
60 if (element instanceof Collection<?>) {
61 return Messages.OutlineLabelProvider_0;
62 }
63 if (element instanceof Node) {
64 return ((Node)element).getId();
65 }
66 if (element instanceof ConnectionGroupWrapper) {
67 return ((ConnectionGroupWrapper)element).getTargetNode().getId();
68 }
69 return element.toString();
70 }
71
72
73
74
75
76
77 @Override
78 public Image getImage(Object element) {
79 if (element instanceof Collection<?>) {
80 return Images.getInstance().get(Images.FILE);
81 }
82 if (element instanceof ConnectionGroupWrapper) {
83 return Images.getInstance().get(Images.CONNECTION);
84 }
85 if (element instanceof Node) {
86 return Images.getInstance().get(Images.NODE);
87 }
88 return null;
89 }
90
91 }