E4/EAS/Label Decoration
From Eclipsepedia
Components should be able to provide decorations to labels and icons for conveying information to the user. This allows a view to provide information about the model objects in question that it originally did not provide since third-party bundles can now contribute information to this view via the decoration mechanism.
Contents |
Eclipse 3.x API
In Eclipse 3.x, the IDecorationManager and ILightweightLabelDecorator can be used by bundles to decorate objects.
Extension definition
<extension point="org.eclipse.ui.decorators"> <decorator adaptable="true" class="org.eclipse.e4.internal.ui.decorators.ResourceDecorator" id="org.eclipse.e4.internal.ui.decorators.ResourceDecorator" label="Resource Decorator" lightweight="true" state="true"> <enablement> <and> <objectClass name="org.eclipse.core.resources.IResource"> </objectClass> <or> <objectClass name="org.eclipse.core.resources.IFolder"> </objectClass> <objectClass name="org.eclipse.core.resources.IFile"> </objectClass> </or> </and> </enablement> </decorator> </extension>
Implementation
public class ResourceDecorator implements ILightweightLabelDecorator { public void decorate(Object element, IDecoration decoration) { if (element instanceof IFolder) { decoration.addOverlay(getFolderImageDescriptor(), IDecoration.TOP_LEFT); } else if (element instanceof IFile) { decoration.addOverlay(getFileImageDescriptor(), IDecoration.TOP_LEFT); } } }
Decoration request
PlatformUI.getWorkbench().getDecoratorManager().update("org.eclipse.e4.internal.ui.decorators.ResourceDecorator");

