KickJava   Java API By Example, From Geeks To Geeks.

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


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.IFile;
7 import org.eclipse.core.resources.IProject;
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 import org.terracotta.dso.TcPlugin;
13
14 /**
15  * Adorns the DSO config file.
16
17  * The adornment appears in the Package Explorer amd Outline view.
18  */

19
20 public class ConfigFileDecorator extends LabelProvider
21   implements ILightweightLabelDecorator
22 {
23   private static final ImageDescriptor
24     m_imageDesc = ImageDescriptor.createFromURL(
25       ConfigFileDecorator.class.getResource(
26         "/com/tc/admin/icons/installed_ovr.gif"));
27
28   public static final String JavaDoc
29     DECORATOR_ID = "org.terracotta.dso.configFileDecorator";
30
31   public void decorate(Object JavaDoc element, IDecoration decoration) {
32     TcPlugin plugin = TcPlugin.getDefault();
33     IFile file = (IFile)element;
34     IProject project = file.getProject();
35
36     if(plugin.hasTerracottaNature(project)) {
37       IFile configFile = plugin.getConfigurationFile(project);
38       
39       if(file.equals(configFile)) {
40         decoration.addOverlay(m_imageDesc);
41       }
42     }
43   }
44
45   public static void updateDecorators() {
46     TcPlugin.getDefault().updateDecorator(DECORATOR_ID);
47   }
48 }
49
Popular Tags