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

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

Introduction

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

Prototype

@Override
    public void markDirty() 

Source Link

Usage

From source file:com.atlassian.connector.eclipse.internal.crucible.ui.editor.parts.ExpandablePart.java

License:Open Source License

private void fillToolBar(ToolBarManager toolbarManager, boolean expanded) {
    if (!enableToolbar) {
        return;//from   w ww  . j  av a2s  .  c om
    }

    List<IReviewAction> toolbarActions = getToolbarActions(expanded);

    //      for (Control control : actionsComposite.getChildren()) {
    //         if (control instanceof ImageHyperlink) {
    //            control.setMenu(null);
    //            control.dispose();
    //         }
    //      }

    toolbarManager.removeAll();

    if (toolbarActions != null) {

        for (final IReviewAction action : toolbarActions) {
            action.setActionListener(actionListener);
            toolbarManager.add(action);
            //            ImageHyperlink link = createActionHyperlink(actionsComposite, toolkit, action);
            //            if (!action.isEnabled()) {
            //               link.setEnabled(false);
            //            }
        }
    }
    toolbarManager.markDirty();
    toolbarManager.update(true);
    //      actionsComposite.getParent().layout();
}

From source file:net.yatomiya.e4.ui.workbench.renderers.swt.ToolBarManagerRenderer.java

License:Open Source License

@Inject
@Optional//from  w  w  w  .j  a v a2 s .  co  m
private void subscribeTopicUpdateToBeRendered(@UIEventTopic(UIEvents.UIElement.TOPIC_ALL) Event event) {
    // Ensure that this event is for a MMenuItem
    if (!(event.getProperty(UIEvents.EventTags.ELEMENT) instanceof MToolBarElement)) {
        return;
    }

    MToolBarElement itemModel = (MToolBarElement) event.getProperty(UIEvents.EventTags.ELEMENT);
    String attName = (String) event.getProperty(UIEvents.EventTags.ATTNAME);
    if (UIEvents.UIElement.TOBERENDERED.equals(attName)) {
        Object obj = itemModel.getParent();
        if (!(obj instanceof MToolBar)) {
            return;
        }
        ToolBarManager parent = getManager((MToolBar) obj);
        if (itemModel.isToBeRendered()) {
            if (parent != null) {
                modelProcessSwitch(parent, itemModel);
                parent.update(true);
                ToolBar tb = parent.getControl();
                if (tb != null && !tb.isDisposed()) {
                    tb.pack(true);
                    tb.getShell().layout(new Control[] { tb }, SWT.DEFER);
                }
            }
        } else {
            IContributionItem ici = modelToContribution.remove(itemModel);
            if (ici != null && parent != null) {
                parent.remove(ici);
            }
            if (ici != null) {
                ici.dispose();
            }
        }
    } else if (UIEvents.UIElement.VISIBLE.equals(attName)) {
        IContributionItem ici = getContribution(itemModel);
        if (ici == null) {
            return;
        }

        ToolBarManager parent = null;
        if (ici instanceof MenuManager) {
            parent = (ToolBarManager) ((MenuManager) ici).getParent();
        } else if (ici instanceof ContributionItem) {
            parent = (ToolBarManager) ((ContributionItem) ici).getParent();
        }

        if (parent == null) {
            ici.setVisible(itemModel.isVisible());
            return;
        }

        IContributionManagerOverrides ov = parent.getOverrides();
        // partial fix for bug 383569: only change state if there are no
        // extra override mechanics controlling element visibility
        if (ov == null) {
            ici.setVisible(itemModel.isVisible());
        } else {
            Boolean visible = ov.getVisible(ici);
            if (visible == null) {
                // same as above: only change state if there are no extra
                // override mechanics controlling element visibility
                ici.setVisible(itemModel.isVisible());
            }
        }

        parent.markDirty();
        parent.update(true);
        ToolBar tb = parent.getControl();
        if (tb != null && !tb.isDisposed()) {
            tb.pack(true);
            if (tb.getParent() != null) {
                tb.getParent().pack(true);
            }
            tb.getShell().layout(new Control[] { tb }, SWT.DEFER);
        }
    }
}