01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package org.terracotta.dso;
05:
06: import org.eclipse.jface.resource.ImageDescriptor;
07: import org.eclipse.jface.resource.ImageRegistry;
08: import org.eclipse.jface.text.source.Annotation;
09: import org.eclipse.swt.graphics.Image;
10: import org.eclipse.swt.widgets.Display;
11: import org.eclipse.ui.texteditor.IAnnotationImageProvider;
12:
13: import java.net.URL;
14:
15: /**
16: * A provider of images for our annotations.
17: *
18: * @see org.eclipse.ui.texteditor.IAnnotationImageProvider
19: */
20:
21: public class AnnotationImageProvider implements
22: IAnnotationImageProvider {
23: private ImageRegistry m_imageRegistry;
24:
25: private static final Object[] DEFAULT_IMAGES = {
26: new String[] { "org.terracotta.dso.adaptedTypeAnnotation",
27: "/com/tc/admin/icons/installed_ovr.gif" },
28: new String[] {
29: "org.terracotta.dso.adaptedTypeReferenceAnnotation",
30: "/com/tc/admin/icons/blank.gif" },
31: new String[] { "org.terracotta.dso.bootJarTypeAnnotation",
32: "/com/tc/admin/icons/blank.gif" },
33: new String[] { "org.terracotta.dso.excludedTypeAnnotation",
34: "/com/tc/admin/icons/error_obj.gif" },
35: new String[] { "org.terracotta.dso.nameLockedAnnotation",
36: "/com/tc/admin/icons/namelocked_view.gif" },
37: new String[] { "org.terracotta.dso.autolockedAnnotation",
38: "/com/tc/admin/icons/autolocked_view.gif" },
39: new String[] { "org.terracotta.dso.rootAnnotation",
40: "/com/tc/admin/icons/hierarchicalLayout.gif" },
41: new String[] {
42: "org.terracotta.dso.distributedMethodAnnotation",
43: "/com/tc/admin/icons/jspbrkpt_obj.gif" },
44: new String[] {
45: "org.terracotta.dso.transientFieldAnnotation",
46: "/com/tc/admin/icons/transient.gif" }, };
47:
48: public AnnotationImageProvider() {
49: m_imageRegistry = new ImageRegistry(Display.getDefault());
50:
51: String[] mapping;
52: for (int i = 0; i < DEFAULT_IMAGES.length; i++) {
53: mapping = (String[]) DEFAULT_IMAGES[i];
54: addDescriptor(mapping[0], mapping[1]);
55: }
56: }
57:
58: public Image getManagedImage(Annotation annotation) {
59: return null;
60: }
61:
62: public String getImageDescriptorId(Annotation annotation) {
63: return annotation.getType();
64: }
65:
66: public ImageDescriptor getImageDescriptor(String id) {
67: return m_imageRegistry.getDescriptor(id);
68: }
69:
70: public ImageDescriptor addDescriptor(String id, String uri) {
71: ImageDescriptor imageDesc = null;
72: URL url = AnnotationImageProvider.class.getResource(uri);
73:
74: if (url != null) {
75: m_imageRegistry.put(id, imageDesc = ImageDescriptor
76: .createFromURL(url));
77: }
78:
79: return imageDesc;
80: }
81: }
|