KickJava   Java API By Example, From Geeks To Geeks.

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


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.IType;
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 types that are excluded from instrumentation.
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.isExcluded
23  */

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