KickJava   Java API By Example, From Geeks To Geeks.

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


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.IField;
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 fields that are not to be included in a shared object graph.
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.TcPlugin.hasTerracottaNature
23  * @see org.terracotta.dso.ServerTracker.isRunning
24  */

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