01: package org.terracotta.dso.views;
02:
03: import org.eclipse.jdt.core.IJavaElement;
04: import org.eclipse.jdt.ui.JavaElementLabelProvider;
05: import org.eclipse.jface.viewers.LabelProvider;
06: import org.eclipse.swt.graphics.Image;
07: import org.terracotta.dso.TcPlugin;
08:
09: class ConfigLabelProvider extends LabelProvider {
10: private ConfigViewer fViewer;
11: private static Image m_rootsImage;
12: private static Image m_bootClassesImage;
13: private static Image m_distributedMethodsImage;
14: private static Image m_instrumentedClassesImage;
15: private static Image m_locksImage;
16: private static Image m_transientsImage;
17: private static Image m_missingElementImage;
18:
19: private static JavaElementLabelProvider m_javaLabelProvider = new JavaElementLabelProvider(
20: JavaElementLabelProvider.SHOW_SMALL_ICONS);
21:
22: static {
23: m_rootsImage = TcPlugin
24: .createImage("/images/eclipse/roots.gif");
25: m_locksImage = TcPlugin
26: .createImage("/images/eclipse/locks.gif");
27: m_transientsImage = TcPlugin
28: .createImage("/images/eclipse/transients.gif");
29: m_bootClassesImage = TcPlugin
30: .createImage("/images/eclipse/jar_obj.gif");
31: m_distributedMethodsImage = TcPlugin
32: .createImage("/images/eclipse/jmeth_obj.gif");
33: m_instrumentedClassesImage = TcPlugin
34: .createImage("/images/eclipse/class_obj.gif");
35: m_missingElementImage = TcPlugin
36: .createImage("/images/eclipse/hprio_tsk.gif");
37: }
38:
39: ConfigLabelProvider(ConfigViewer viewer) {
40: super ();
41: fViewer = viewer;
42: }
43:
44: public String getText(Object element) {
45: if (element instanceof RootsWrapper) {
46: return "Roots";
47: } else if (element instanceof InstrumentedClassesWrapper) {
48: return "Instrumented classes";
49: } else if (element instanceof LocksWrapper) {
50: return "Locks";
51: } else if (element instanceof DistributedMethodsWrapper) {
52: return "Distributed methods";
53: } else if (element instanceof AdditionalBootJarClassesWrapper) {
54: return "Additional boot classes";
55: } else if (element instanceof TransientFieldsWrapper) {
56: return "Transient fields";
57: }
58: return super .getText(element);
59: }
60:
61: public Image getImage(Object element) {
62: if (element instanceof RootWrapper) {
63: RootWrapper wrapper = (RootWrapper) element;
64: return getJavaElementImage(fViewer.getPart().getField(
65: wrapper.getFieldName()));
66: } else if (element instanceof RootsWrapper) {
67: return m_rootsImage;
68: } else if (element instanceof LocksWrapper) {
69: return m_locksImage;
70: } else if (element instanceof DistributedMethodsWrapper) {
71: return m_distributedMethodsImage;
72: } else if (element instanceof AdditionalBootJarClassesWrapper) {
73: return m_bootClassesImage;
74: } else if (element instanceof TransientFieldsWrapper) {
75: return m_transientsImage;
76: } else if (element instanceof InstrumentedClassesWrapper) {
77: return m_instrumentedClassesImage;
78: } else if (element instanceof BootClassWrapper) {
79: String className = ((BootClassWrapper) element)
80: .getClassName();
81: return getJavaElementImage(fViewer.getPart().getType(
82: className));
83: } else if (element instanceof TransientFieldWrapper) {
84: String fieldName = ((TransientFieldWrapper) element)
85: .getFieldName();
86: return getJavaElementImage(fViewer.getPart().getField(
87: fieldName));
88: }
89:
90: return null;
91: }
92:
93: private Image getJavaElementImage(IJavaElement element) {
94: if (element != null) {
95: return m_javaLabelProvider.getImage(element);
96: }
97: return m_missingElementImage;
98: }
99: }
|