Example usage for org.eclipse.jface.action ICoolBarManager markDirty

List of usage examples for org.eclipse.jface.action ICoolBarManager markDirty

Introduction

In this page you can find the example usage for org.eclipse.jface.action ICoolBarManager markDirty.

Prototype

void markDirty();

Source Link

Document

Marks this contribution manager as dirty.

Usage

From source file:es.cv.gvcase.mdt.common.part.SubActionBarsExt.java

License:Open Source License

/**
 * Sets this SubActionBar active. Updates the toolbars cleaning them from
 * all the duplicated contributed items.
 * //from  w w  w .j a v  a  2  s  .  com
 * @see org.eclipse.ui.SubActionBars2#setActive(boolean)
 */
@Override
protected void setActive(boolean value) {
    if (!value) {
        setAllItemsVisibility(false);
    }
    // Force the Zoom toolbar action item to go non-visible so it's
    // refreshed later.
    setZoomToolbarActionVisibility(false);
    updateSomeActionBars();
    super.setActive(value);

    ICoolBarManager parentCoolBarManager = getTopCoolBarManager();
    if (parentCoolBarManager != null) {
        parentCoolBarManager.markDirty();
    }
    if (myToolBarManager != null && parentCoolBarManager != null) {
        IContributionItem[] items = myToolBarManager.getItems();
        List<String> appliedItems = new ArrayList<String>();
        for (int i = 0; i < items.length; i++) {
            if (appliedItems.contains(items[i].getId())) {
                items[i].setVisible(false);
                continue;
            }
            appliedItems.add(items[i].getId());
            IContributionItem item = items[i];
            item.setVisible(value);
        }
        myToolBarManager.markDirty();
        myToolBarManager.update(true);
    }

    if (value) {
        @SuppressWarnings("unchecked")
        Map<String, IAction> globals = getGlobalActionHandlers();
        if (globals != null) {
            for (Map.Entry<String, IAction> nextEntry : globals.entrySet()) {
                getParent().setGlobalActionHandler(nextEntry.getKey(), nextEntry.getValue());
            }
        }
    } else {
        getParent().clearGlobalActionHandlers();
    }
    getParent().updateActionBars();
}

From source file:gov.redhawk.internal.ui.SubActionBarsExt.java

License:Open Source License

@Override
protected void setActive(final boolean value) {
    if (getActive() == value) {
        return;//from  w  w w.  j  a  va2  s  .  c o m
    }
    super.setActive(value);

    final ICoolBarManager parentCoolBarManager = getTopCoolBarManager();
    if (parentCoolBarManager != null) {
        parentCoolBarManager.markDirty();
    }
    if (this.myToolBarManager != null && parentCoolBarManager != null) {
        final IContributionItem[] items = this.myToolBarManager.getItems();
        for (int i = 0; i < items.length; i++) {
            final IContributionItem item = items[i];
            item.setVisible(value);
        }
        this.myToolBarManager.markDirty();
        this.myToolBarManager.update(false);
    }

    if (value) {
        final Map<?, ?> globals = getGlobalActionHandlers();
        if (globals != null) {
            for (final Map.Entry<?, ?> nextEntry : globals.entrySet()) {
                final Object key = nextEntry.getKey();
                final Object entryValue = nextEntry.getValue();
                if (key instanceof String && entryValue instanceof IAction) {
                    getParent().setGlobalActionHandler((String) key, (IAction) entryValue);
                }
            }
        }
    } else {
        getParent().clearGlobalActionHandlers();
    }
    getParent().updateActionBars();
}

From source file:org.eclipse.ui.internal.ActionSetActionBars.java

License:Open Source License

/**
 * Activate / Deactivate the contributions.
 *///  w w  w  .  j  a  v a 2 s.  c  om
protected void setActive(boolean set) {
    super.setActive(set);

    ICoolBarManager coolBarManager = getCastedParent().getCoolBarManager();
    if (coolBarManager == null) {
        return;
    }

    // 1. Need to set visibility for all non-adjunct actions
    if (coolItemToolBarMgr != null) {
        IContributionItem[] items = coolItemToolBarMgr.getItems();
        for (int i = 0; i < items.length; i++) {
            IContributionItem item = items[i];
            if (item instanceof PluginActionCoolBarContributionItem) {
                PluginActionCoolBarContributionItem actionSetItem = (PluginActionCoolBarContributionItem) item;
                // Only if the action set id for this contribution item is
                // the same
                // as this object
                if (actionSetItem.getActionSetId().equals(actionSetId)) {
                    item.setVisible(set);
                    coolItemToolBarMgr.markDirty();
                    if (!coolBarManager.isDirty()) {
                        coolBarManager.markDirty();
                    }
                }
            }
        }
        // Update the manager
        coolItemToolBarMgr.update(false);
        if (toolBarContributionItem != null) {
            toolBarContributionItem.update(ICoolBarManager.SIZE);
        }
    }

    // 2. Need to set visibility for all adjunct actions
    if (adjunctContributions.size() > 0) {
        for (Iterator i = adjunctContributions.iterator(); i.hasNext();) {
            IContributionItem item = (IContributionItem) i.next();
            if (item instanceof ContributionItem) {
                item.setVisible(set);
                IContributionManager manager = ((ContributionItem) item).getParent();
                manager.markDirty();
                manager.update(false);
                if (!coolBarManager.isDirty()) {
                    coolBarManager.markDirty();
                }
                item.update(ICoolBarManager.SIZE);
            }

        }

    }
}

From source file:org.eclipse.ui.internal.EditorActionBars.java

License:Open Source License

/**
 * Sets the visibility of the manager. If the visibility is
 * <code>true</code> then each item within the manager appears within the
 * parent manager. Otherwise, the items are not visible if force visibility
 * is <code>true</code>, or grayed out if force visibility is
 * <code>false</code>//  w ww .  jav  a  2 s  .  co m
 * <p>
 * This is a workaround for the layout flashing when editors contribute
 * large amounts of items.
 * </p>
 * 
 * @param visible
 *            the new visibility
 * @param forceVisibility
 *            <code>true</code> to change the visibility or
 *            <code>false</code> to change just the enablement state. This
 *            parameter is ignored if visible is <code>true</code>.
 */
private void setVisible(boolean visible, boolean forceVisibility) {
    if (visible) {
        setEnabledAllowed(true);
        if (!isVisible()) {
            setVisible(true);
        }
    } else {
        if (forceVisibility) {
            // Remove the editor tool bar items
            setVisible(false);
        } else {
            // Disabled the tool bar items.
            setEnabledAllowed(false);
        }
    }

    ICoolBarManager coolBarManager = getCastedParent().getCoolBarManager();
    if ((coolItemToolBarMgr != null) && (coolBarManager != null)) {
        IContributionItem[] items = coolItemToolBarMgr.getItems();
        for (int i = 0; i < items.length; i++) {
            IContributionItem item = items[i];
            item.setVisible(visible || !forceVisibility);
            coolItemToolBarMgr.markDirty();
            if (!coolBarManager.isDirty()) {
                coolBarManager.markDirty();
            }
        }
        // Update the manager
        coolItemToolBarMgr.update(false);
        if (toolBarContributionItem != null) {
            toolBarContributionItem.setVisible(visible || !forceVisibility);
        }
        if (getCoolBarManager() != null) {
            ((SubCoolBarManager) getCoolBarManager()).setVisible(visible || !forceVisibility);
        }
    }
}