Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

E4/EAS/Label Decoration

< E4‎ | EAS
Revision as of 14:31, 24 October 2009 by Remysuen.ca.ibm.com (Talk | contribs) (New page: 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 th...)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.

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");

Back to the top