Example usage for org.eclipse.jface.action CoolBarManager setItems

List of usage examples for org.eclipse.jface.action CoolBarManager setItems

Introduction

In this page you can find the example usage for org.eclipse.jface.action CoolBarManager setItems.

Prototype

public void setItems(IContributionItem[] newItems) 

Source Link

Document

Replaces the current items with the given items.

Usage

From source file:org.eclipse.rcptt.tesla.ui.Q7KeyFormatter.java

License:Open Source License

public static void installQ7Formatter() {
    KeyFormatterFactory.setDefault(new Q7KeyFormatter());
    IWorkbench workbench = PlatformUI.getWorkbench();
    for (IWorkbenchWindow w : workbench.getWorkbenchWindows()) {
        if (!(w instanceof WorkbenchWindow))
            continue;

        final WorkbenchWindow ww = (WorkbenchWindow) w;
        final Shell shell = ww.getShell();
        final CoolBarManager coolBarManager = ww.getCoolBarManager();

        if (shell != null && coolBarManager != null)
            shell.getDisplay().syncExec(new Runnable() {
                public void run() {
                    try {
                        shell.setLayoutDeferred(true);
                        IContributionItem[] items = coolBarManager.getItems();
                        coolBarManager.setItems(new IContributionItem[0]);
                        coolBarManager.setItems(items);
                    } finally {
                        shell.setLayoutDeferred(false);
                    }/*from  ww w . ja  v a  2 s.c  om*/
                }
            });
    }
}