KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > decorator > AdaptedModuleDecorator


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.decorator;
5
6 import org.eclipse.core.resources.IProject;
7 import org.eclipse.jdt.core.ICompilationUnit;
8 import org.eclipse.jface.resource.ImageDescriptor;
9 import org.eclipse.jface.viewers.IDecoration;
10 import org.eclipse.jface.viewers.ILightweightLabelDecorator;
11 import org.eclipse.jface.viewers.LabelProvider;
12
13 import org.terracotta.dso.ConfigurationHelper;
14 import org.terracotta.dso.TcPlugin;
15
16 /**
17  * Adorns Java modules whose primary-type is instrumented.
18
19  * The adornment appears in the Package Explorer amd Outline view.
20  *
21  * @see org.eclipse.jface.viewers.LabelProvider
22  * @see org.terracotta.dso.ConfigurationHelper.isAdaptable
23  */

24
25 public class AdaptedModuleDecorator extends LabelProvider
26   implements ILightweightLabelDecorator
27 {
28   private static final ImageDescriptor
29     m_imageDesc = ImageDescriptor.createFromURL(
30       AdaptedModuleDecorator.class.getResource(
31         "/com/tc/admin/icons/installed_ovr.gif"));
32
33   public static final String JavaDoc
34     DECORATOR_ID = "org.terracotta.dso.adaptedModuleDecorator";
35
36   public void decorate(Object JavaDoc element, IDecoration decoration) {
37     TcPlugin plugin = TcPlugin.getDefault();
38     ICompilationUnit cu = (ICompilationUnit)element;
39     IProject project = cu.getJavaProject().getProject();
40
41     if(plugin.hasTerracottaNature(project)) {
42       ConfigurationHelper config = plugin.getConfigurationHelper(project);
43
44       if(config != null &&
45          (config.isAdaptable(cu) ||
46           TcPlugin.getDefault().isBootClass(cu)))
47       {
48         decoration.addOverlay(m_imageDesc);
49       }
50     }
51   }
52
53   public static void updateDecorators() {
54     TcPlugin.getDefault().updateDecorator(DECORATOR_ID);
55   }
56 }
57
Popular Tags