1 11 package org.eclipse.ui.internal.decorators; 12 13 import java.net.URL ; 14 15 import org.eclipse.core.runtime.IConfigurationElement; 16 import org.eclipse.jface.resource.ImageDescriptor; 17 import org.eclipse.jface.viewers.IDecoration; 18 import org.eclipse.jface.viewers.ILabelProviderListener; 19 import org.eclipse.jface.viewers.ILightweightLabelDecorator; 20 import org.eclipse.ui.internal.util.BundleUtility; 21 22 26 public class DeclarativeDecorator implements ILightweightLabelDecorator { 27 28 private String iconLocation; 29 30 private IConfigurationElement configElement; 31 32 private ImageDescriptor descriptor; 33 34 DeclarativeDecorator(IConfigurationElement definingElement, String iconPath) { 35 this.iconLocation = iconPath; 36 this.configElement = definingElement; 37 } 38 39 42 public void addListener(ILabelProviderListener listener) { 43 } 44 45 48 public void dispose() { 49 } 51 52 56 public boolean isLabelProperty(Object element, String property) { 57 return false; 58 } 59 60 63 public void removeListener(ILabelProviderListener listener) { 64 } 65 66 70 public void decorate(Object element, IDecoration decoration) { 71 if (descriptor == null) { 72 URL url = BundleUtility.find(configElement.getDeclaringExtension() 73 .getNamespace(), iconLocation); 74 if (url == null) { 75 return; 76 } 77 descriptor = ImageDescriptor.createFromURL(url); 78 } 79 decoration.addOverlay(descriptor); 80 } 81 } 82 | Popular Tags |