Eclipse update the statusbar

585 Views Asked by At

I'm working on Eclipse plugin and I add an 16x16 icon to the statusbar by

ToolBarManager manager = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL); 
manager.add(updatingNewsAction);

Where updatingNewsAction is a class that extends org.eclipse.jface.action.Action.

However I've got problem with removing the updatingNewsAction from the toolbar. It's removed, but I can see that only when something updates the statusbar - for example minimazing/maximazing the borderline views. Then after reading some blog post I've wrote:

PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
        @Override
        public void run() {

            IWorkbench wb = PlatformUI.getWorkbench();
            IWorkbenchWindow win = wb.getActiveWorkbenchWindow();

            IWorkbenchPage page = win.getActivePage();

            IWorkbenchPart part = page.getActivePart();
            IWorkbenchPartSite site = part.getSite();

            IViewSite vSite = (IViewSite) site;

            IActionBars actionBars = vSite.getActionBars();

            if (actionBars == null) {
                return;
            }
            IStatusLineManager statusLineManager = actionBars.getStatusLineManager();

            if (statusLineManager == null) {
                return;
            }
            statusLineManager.update(true);
        }
    });

Which is a step forward, because it gets updated when switching focus between views, but still it doesn't happen immediately and without user interactions. How to update the status bar programmatically immediately?

0

There are 0 best solutions below