Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8303077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:26:19+00:00 2026-06-08T17:26:19+00:00

JDT and other plugins for Eclipse decorate the editor title image with problem status

  • 0

JDT and other plugins for Eclipse decorate the editor title image with problem status (compilation errors etc.). In my plugin I want to mimic that behaviour.

However, looking at the sources, JDT seems to do a lot of extra handling to do the decoration.

Decorators, especially lightweight ditto, is a handy way of doing decorations on icons, but I can find no way to programatically enable them for the title image of an editor. (And I don’t want to pull in all of JDT UI in my plugin…)

Is there such a way or do I need to implement my own ILabelProvider and then

public void updatedTitleImage(Image image) {
    setTitleImage(image);
}

like the JavaEditor does?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T17:26:21+00:00Added an answer on June 8, 2026 at 5:26 pm

    There seems to be no way to use decorators with the editor title image (as of 3.7 at least).

    I ended up creating a EditorLabelUpdator which implemented the IResourceChangeListener interface (to find out when markers changed), basically the resourceChanged() method. It then uses a simple decorator-type class built from the pattern of OverlayImageIcon (of which you can find a lot of examples on Google).

    The constructor is called from the initalization of the editor, sending the editor as a parameter which is saved for getting at the resource and its title icon.

    The editor also had to be amended with a callback method triggering the title icon updating (updatedTitleImage(Image image)).

    This is the core of the code I got:

    public void resourceChanged(IResourceChangeEvent event) {
        if (isMarkerChangeForResource(event, editor)) {
            /* Changes in markers on this resource, so re-decorate title image */
            decorate();
        }
    }
    
    private boolean isMarkerChangeForResource(IResourceChangeEvent event, AlanEditor editor) {
        boolean isMarkerChangeForThisResource;
        final IResource resource = ResourceUtil.getResource(editor.getEditorInput());
        final IPath path = resource.getFullPath();
        IResourceDelta delta = event.getDelta().findMember(path);
        isMarkerChangeForThisResource = (delta != null) && ((delta.getFlags() & IResourceDelta.MARKERS) != 0);
        return isMarkerChangeForThisResource;
    }
    
    public void decorate() {
        Shell shell = editor.getEditorSite().getShell();
        if (shell != null && !shell.isDisposed()) {
            shell.getDisplay().syncExec(new Runnable() {
                public void run() {
                    Image decoratedImage = decorateImage(editor.getTitleImage(), getSeverity());
                    editor.updatedTitleImage(decoratedImage);
                }
            });
        }
    }
    
    private Image decorateImage(Image titleImage, int severity) {
        final ImageRegistry registry = AlanIDEPlugin.getDefault().getImageRegistry();
        String key = createKey(severity);
        ImageDescriptor descriptor = AlanIDEPlugin.getImageDescriptor(key);
        if (descriptor != null)
            return descriptor.createImage();
    
        OverlayImageDescriptor overlayImageDescriptor = buildDecoratedImage(severity, key);
        registry.put(key, overlayImageDescriptor);
        return overlayImageDescriptor.createImage();
    }
    
    private String createKey(int severity) {
        String key;
        switch (severity) {
        case IMarker.SEVERITY_ERROR: key = EDITOR_TITLE_ICON + ".error"; break;
        case IMarker.SEVERITY_WARNING: key = EDITOR_TITLE_ICON + ".warning"; break;
        default: key = EDITOR_TITLE_ICON; break;
        }
        return key;
    }
    
    private OverlayImageDescriptor buildDecoratedImage(int severity, String key) {
        ImageDescriptor overlay = null;
        if (severity >= IMarker.SEVERITY_ERROR)
            overlay = AlanIDEPlugin.getImageDescriptor("ovr16.error_ovr");
        else if (severity == IMarker.SEVERITY_WARNING)
            overlay = AlanIDEPlugin.getImageDescriptor("ovr16.warning_ovr");
        ImageDescriptor baseImage = AlanIDEPlugin.getImageDescriptor(EDITOR_TITLE_ICON);
        OverlayImageDescriptor overlayIcon = new OverlayImageDescriptor(baseImage);
    
        if (overlay != null)
            overlayIcon.addOverlay(overlay, IDecoration.BOTTOM_LEFT);
        return overlayIcon;
    }
    
    private int getSeverity() {
        int severity = 0;
        try {
            final IResource resource = ResourceUtil.getResource(editor.getEditorInput());
            severity = resource.findMaxProblemSeverity(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE);
        } catch (CoreException e) {
            // Might be a project that is not open
        }
        return severity;
    }
    

    This was the simplest solution I could come up with.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to modify some code in the Eclipse JDT itself (In the Debug
I want to do something using Annotation processing in eclipse jdt. Eclipse jdtapt help
Eclipse (at least the JDT package) comes with a pretty decent XML editor. Flash
I'm writing an Eclipse plugin for the JDT. I need a functionality that tracks
Some time ago I wrote an Eclipse plugin which makes use of JDT to
I have some Ant tasks in my Eclipse JDT project that I want to
I want to use org.eclipse.jdt.ui.refactoring.RenameSupport class RenameSupport renameSupport = RenameSupport.create(packageFragment, newName, RenameSupport.UPDATE_REFERENCES); Here I
I use Eclipse JDT library to parse java source code to visit all methods
I am going to need to do some development with Eclipse JDT while on
I am writing an Eclipse plug-in that uses JDT AST's ASTParser to parse a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.