org.eclipse.swt.widgets.CoolBar

Here are the examples of the java api class org.eclipse.swt.widgets.CoolBar taken from open source projects.

1. CoolBarAdvisor#advise()

Project: RSSOwl
File: CoolBarAdvisor.java
/**
   * Fill the Coolbar
   *
   * @param fromUpdate if <code>true</code> this method will ensure to re-layout
   * and update the coolbar.
   */
public void advise(boolean fromUpdate) {
    /* Retrieve Control if available */
    CoolBar barControl = null;
    if (fManager instanceof CoolBarManager)
        barControl = ((CoolBarManager) fManager).getControl();
    /* Disable Redraw to avoid Flicker */
    if (barControl != null && fromUpdate)
        barControl.getShell().setRedraw(false);
    try {
        /* First Remove All */
        fManager.removeAll();
        /* Load Toolbar Mode */
        CoolBarMode mode = CoolBarMode.values()[fPreferences.getInteger(DefaultPreferences.TOOLBAR_MODE)];
        /* Load and Add Items */
        int[] items = fPreferences.getIntegers(DefaultPreferences.TOOLBAR_ITEMS);
        if (items == null || items.length == 0)
            items = new int[] { CoolBarItem.SPACER.ordinal() };
        ToolBarManager currentToolBar = new ToolBarManager(mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL ? (SWT.FLAT | SWT.RIGHT) : SWT.FLAT);
        for (int id : items) {
            final CoolBarItem item = CoolBarItem.values()[id];
            if (item != null) {
                /* Separator: Start a new Toolbar */
                if (item == CoolBarItem.SEPARATOR) {
                    fManager.add(currentToolBar);
                    currentToolBar = new ToolBarManager(mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL ? (SWT.FLAT | SWT.RIGHT) : SWT.FLAT);
                } else /* Spacer */
                if (item == CoolBarItem.SPACER) {
                    ActionContributionItem contribItem = new ActionContributionItem(new //$NON-NLS-1$
                    Action(//$NON-NLS-1$
                    "") {

                        @Override
                        public boolean isEnabled() {
                            return false;
                        }
                    });
                    currentToolBar.add(contribItem);
                } else /* Any other Item */
                {
                    ActionContributionItem contribItem = new CoolBarActionContributionitem(item, getAction(item, mode, currentToolBar));
                    contribItem.setId(item.getId());
                    if (mode == CoolBarMode.IMAGE_TEXT_HORIZONTAL || mode == CoolBarMode.IMAGE_TEXT_VERTICAL)
                        contribItem.setMode(ActionContributionItem.MODE_FORCE_TEXT);
                    /* Add to Toolbar */
                    currentToolBar.add(contribItem);
                }
            }
        }
        /* Add latest Toolbar Manager to Coolbar too */
        fManager.add(currentToolBar);
        /* Ensure Updates are properly Propagated */
        if (fromUpdate) {
            /* Update Overall Coolbar UI */
            fManager.update(true);
            if (barControl != null) {
                boolean isLocked = barControl.getLocked();
                barControl.setLocked(!isLocked);
                barControl.setLocked(isLocked);
            }
            /* Update Action UI */
            updateActions(OwlUI.getActivePart(fWindow));
        }
    } finally {
        if (barControl != null && fromUpdate)
            barControl.getShell().setRedraw(true);
    }
}