1 4 package org.terracotta.dso.decorator; 5 6 import org.eclipse.core.resources.IProject; 7 import org.eclipse.jdt.core.IClassFile; 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.BootClassHelper; 14 import org.terracotta.dso.ConfigurationHelper; 15 import org.terracotta.dso.TcPlugin; 16 17 25 26 public class ClassFileDecorator extends LabelProvider 27 implements ILightweightLabelDecorator 28 { 29 private static final ImageDescriptor 30 m_imageDesc = ImageDescriptor.createFromURL( 31 AdaptedModuleDecorator.class.getResource( 32 "/com/tc/admin/icons/installed_ovr.gif")); 33 34 public static final String 35 DECORATOR_ID = "org.terracotta.dso.adaptedClassFileDecorator"; 36 37 public void decorate(Object element, IDecoration decoration) { 38 TcPlugin plugin = TcPlugin.getDefault(); 39 IClassFile classFile = (IClassFile)element; 40 IProject project = classFile.getJavaProject().getProject(); 41 42 if(plugin.hasTerracottaNature(project)) { 43 ConfigurationHelper config = plugin.getConfigurationHelper(project); 44 BootClassHelper helper = BootClassHelper.getHelper(); 45 46 if(helper != null && config != null && 47 (config.isAdaptable(classFile) || helper.isAdaptable(classFile))) 48 { 49 decoration.addOverlay(m_imageDesc); 50 } 51 } 52 } 53 54 public static void updateDecorators() { 55 TcPlugin.getDefault().updateDecorator(DECORATOR_ID); 56 } 57 } 58 | Popular Tags |