1 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 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 34 DECORATOR_ID = "org.terracotta.dso.excludedTypeDecorator"; 35 36 public void decorate(Object 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 |