Your plug-in can use decorators to annotate the images for resources and other objects that appear in the workbench views. Decorators are useful when your plug-in adds functionality for existing resource types. Many of the standard workbench views participate in showing decorations.
For example, PDE contributes decorators that allow you to distinguish between binary and source projects.
The com.example.sourceProject project is the only source project shown in the navigator. Note how all of the other binary projects show the binary decorator at the top left of the Java project icon. This decorator is contributed by PDE using the org.eclipse.ui.decorators extension point.
<extension point="org.eclipse.ui.decorators"> <decorator objectClass="org.eclipse.core.resources.IResource" adaptable="true" label="%decorator.label" state="false" class="org.eclipse.pde.internal.ui.wizards.imports.BinaryProjectDecorator" id="org.eclipse.pde.ui.binaryProjectDecorator"> <description> %decorator.desc </description> </decorator> </extension>
The class attribute should name a class that implements ILabelDecorator. This class allows you to decorate the original label's image and text with your own annotations. The label and description attributes designate the text that is used to name and describe the decorator in the preferences dialog. The objectClass names the class of objects to which the decorator should be applied. The adaptable flag indicates whether objects that adapt to the class should also be decorated. The state flag controls whether the decorator is visible by default.
Decorators are ultimately controlled by the user via the workbench Label Decorations preferences page. Individual decorators can be turned on and off. Even so, it is a good idea to design your decorators so that they do not overlap or conflict with existing platform SDK decorators. If your decorators include information that is expensive to compute or potentially distracting, you may want to contribute your own preferences that allow the user to further fine-tune the decorator once it is on. This technique is used by the CVS client.