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

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

Introduction

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

Prototype

@Override
public void update(boolean force) 

Source Link

Document

Subclasses may extend this IContributionManager method, but must call super.update.

Usage

From source file:com.nokia.tools.ui.ide.ToolbarHider.java

License:Open Source License

protected void hideExternToolBar() {
    setVisibleForListedIds(false);/*from ww  w . j  a  va2 s .c om*/
    CoolBar coolBar = getMainCoolBar();
    if (null == coolBar)
        return;
    for (CoolItem item : ((CoolBar) coolBar).getItems()) {
        // check disposed, can happen when reset perspective
        if (!item.isDisposed() && item.getData() instanceof ToolBarContributionItem) {
            ToolBarContributionItem toolbaritem = ((ToolBarContributionItem) item.getData());

            if (shouldRemoveGroup(toolbaritem)) {
                CoolBarManager mngr = (CoolBarManager) toolbaritem.getParent();
                if (null == mngr) {

                    mngr = ((ApplicationWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow())
                            .getCoolBarManager();
                    toolbaritem.setParent(mngr);
                    mngr.refresh();

                }
                IContributionItem remitem = mngr.remove(toolbaritem);
                if (null != remitem)
                    removedItems.add(remitem);
                mngr.update(true);
            }

        }
    }
}

From source file:org.eclipse.eclipsemonkey.actions.RecreateMonkeyCoolbarAction.java

License:Open Source License

private void createTheToolbar(List toolbarData, final IAction action) {
    CoolBarManager outerManager = ((WorkbenchWindow) window).getCoolBarManager();

    MonkeyToolbarStruct current = new MonkeyToolbarStruct();
    current.key = ""; //$NON-NLS-1$
    current.subtoolbar = new MonkeyToolbarStruct();

    SortedSet sorted = new TreeSet();
    sorted.addAll(toolbarData);//from ww  w  .j  av  a 2  s.  c  om

    Iterator iter = sorted.iterator();
    while (iter.hasNext()) {
        Association element = (Association) iter.next();
        final IPath script_file_to_run = element.path;
        addNestedToolbarAction(current, outerManager, element.key, script_file_to_run, element.imagePath);
    }

    outerManager.update(true);
}

From source file:org.eclipse.ui.tests.internal.EditorActionBarsTest.java

License:Open Source License

/**
 * Tests an edge case in cool bar updating when the cool bar has a single separator 
 * and no other contents (or multiple separators and no other contents). 
 * See bug 239945 for details./*from w w  w  . ja  v a 2s  .  c o  m*/
 * @throws Throwable
 */
public void test239945() throws Throwable {
    // Test a cool bar with a single separator
    CoolBarManager coolBarManager = new CoolBarManager();
    coolBarManager.add(new Separator(CoolBarManager.USER_SEPARATOR));
    try {
        coolBarManager.createControl(fWindow.getShell());
        coolBarManager.update(true);
    } catch (ArrayIndexOutOfBoundsException e) {
        fail("Exception updating cool bar with a single separator");
    }

    // Test a cool bar with multiple separators
    CoolBarManager coolBarManager2 = new CoolBarManager();
    coolBarManager2.add(new Separator(CoolBarManager.USER_SEPARATOR));
    try {
        coolBarManager2.createControl(fWindow.getShell());
        coolBarManager2.update(true);
    } catch (ArrayIndexOutOfBoundsException e) {
        fail("Exception updating cool bar with multiple separators");
    }
}

From source file:zigen.plugin.db.ui.editors.sql.SourceEditor.java

License:Open Source License

public void createToolbarPart(final Composite parent) {
    // coolBar = new CoolBar(parent, SWT.FLAT);
    coolBar = new CoolBar(parent, SWT.NONE);

    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    coolBar.setLayoutData(data);/*from  ww w.j a v  a 2s .  c o  m*/

    CoolBarManager coolBarMgr = new CoolBarManager(coolBar);

    // GridData gid = new GridData();
    // gid.horizontalAlignment = GridData.FILL;
    // coolBar.setLayoutData(gid);

    ToolBarManager toolBarMgr1 = new ToolBarManager(SWT.FLAT);
    toolBarMgr1.add(execScriptAction);

    ToolBarManager toolBarMgr2 = new ToolBarManager(SWT.FLAT);
    toolBarMgr2.add(openSQLAction);
    toolBarMgr2.add(saveSQLAction);

    coolBarMgr.add(new ToolBarContributionItem(toolBarMgr2));
    coolBarMgr.add(new ToolBarContributionItem(toolBarMgr1));
    coolBarMgr.update(true);

    coolBar.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            parent.getParent().layout(true);
            parent.layout(true);
        }
    });
}

From source file:zigen.plugin.db.ui.views.internal.DDLToolBar.java

License:Open Source License

public DDLToolBar(final Composite parent, IEditorPart editor) {
    this.fEditor = editor;
    // this.coolBar = new CoolBar(parent, SWT.FLAT);
    this.coolBar = new CoolBar(parent, SWT.NONE);

    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    coolBar.setLayoutData(data);/*  w  ww. j av a2s .  com*/

    CoolBarManager coolBarMgr = new CoolBarManager(coolBar);
    ToolBarManager toolBarMgr1 = new ToolBarManager(SWT.FLAT);
    toolBarMgr1.add(saveAction);
    coolBarMgr.add(new ToolBarContributionItem(toolBarMgr1));
    coolBarMgr.update(true);
    coolBar.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            parent.getParent().layout(true);
            parent.layout(true);
        }
    });

}

From source file:zigen.plugin.db.ui.views.internal.SQLToolBar.java

License:Open Source License

public void createPartControl(final Composite parent) {
    coolBar = new CoolBar(parent, SWT.FLAT);
    // coolBar = new CoolBar(parent, SWT.NONE);

    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    coolBar.setLayoutData(data);/*from ww w .j av  a  2s . c o m*/
    CoolBarManager coolBarMgr = new CoolBarManager(coolBar);
    coolBarMgr.add(getToolBarContributionItem1(coolBarMgr));
    coolBarMgr.add(getToolBarContributionItem2(coolBarMgr));
    coolBarMgr.add(getToolBarContributionItem3(coolBarMgr));
    coolBarMgr.add(getToolBarContributionItem4(coolBarMgr));
    coolBarMgr.add(getToolBarContributionItem5(coolBarMgr));
    coolBarMgr.add(getToolBarContributionItem6(coolBarMgr));
    coolBarMgr.update(true);

    coolBar.addControlListener(new ControlListener() {

        public void controlMoved(ControlEvent e) {
        }

        public void controlResized(ControlEvent e) {
            parent.getParent().layout(true);
            parent.layout(true);
        }
    });
}