KickJava   Java API By Example, From Geeks To Geeks.

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


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.IMethod;
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 methods that are invoked on all instances within a shared
18  * root hierarchy.
19  *
20  * The adornment appears in the Package Explorer amd Outline view.
21  *
22  * @see org.eclipse.jface.viewers.LabelProvider
23  * @see org.terracotta.dso.ConfigurationHelper.isDistributed
24  */

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