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

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

Introduction

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

Prototype

void update(boolean force);

Source Link

Document

Updates this manager's underlying widget(s) with any changes which have been made to it or its items.

Usage

From source file:codeOrchestra.lcs.status.StatusLineContributionItemEx.java

License:Open Source License

public void setImage(Image image) {
    this.image = image;

    if (label != null && !label.isDisposed()) {
        label.setImage(image);//from ww w . j a v a  2s. c  o m

        IContributionManager contributionManager = getParent();

        if (contributionManager != null) {
            contributionManager.update(true);
        }
    }
}

From source file:codeOrchestra.lcs.status.StatusLineContributionItemEx.java

License:Open Source License

/**
 * Sets the text to be displayed in the status line.
 * //w ww.j  a va 2s .  c o m
 * @param text
 *          the text to be displayed, must not be <code>null</code>
 */
public void setText(String text) {
    Assert.isNotNull(text);

    this.text = LegacyActionTools.escapeMnemonics(text);

    if (label != null && !label.isDisposed()) {
        label.setText(this.text);
    }

    if (this.text.length() == 0) {
        if (isVisible()) {
            setVisible(false);
            IContributionManager contributionManager = getParent();

            if (contributionManager != null) {
                contributionManager.update(true);
            }
        }
    } else {
        // Always update if using 'CALC_TRUE_WIDTH'
        if (!isVisible() || charWidth == CALC_TRUE_WIDTH) {
            setVisible(true);
            IContributionManager contributionManager = getParent();

            if (contributionManager != null) {
                contributionManager.update(true);
            }
        }
    }
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ChangesetDetailsDialog.java

License:Open Source License

private void contributeActions() {
    final SourceFilesCheckinControl sourceFilesSubControl = getCheckinControl().getSourceFilesSubControl();

    sourceFilesSubControl.getContextMenu().addMenuListener(new IMenuListener() {
        @Override/*from   w w  w. java  2s  .  c o  m*/
        public void menuAboutToShow(final IMenuManager manager) {
            final String groupId = StandardActionConstants.HOSTING_CONTROL_CONTRIBUTIONS;

            manager.appendToGroup(groupId, viewSubMenu);
            manager.appendToGroup(groupId, new Separator());
            manager.appendToGroup(groupId, compareSubMenu);
        }
    });

    sourceFilesSubControl.getChangesTable().addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(final DoubleClickEvent event) {
            if (viewAction.isEnabled()) {
                viewAction.run();
            }
        }
    });

    final IContributionManager contributionManager = sourceFilesSubControl.getContributionManager();

    contributionManager.add(new Separator());
    contributionManager.add(compareToolbarAction);
    contributionManager.add(viewToolbarAction);

    contributionManager.update(false);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.CheckinDialog.java

License:Open Source License

private void contributeActions() {
    final SourceFilesCheckinControl sourceFilesSubControl = getCheckinControl().getSourceFilesSubControl();

    sourceFilesSubControl.getContextMenu().addMenuListener(new IMenuListener() {
        @Override//w w  w. j av a  2 s.c om
        public void menuAboutToShow(final IMenuManager manager) {
            final String groupId = StandardActionConstants.HOSTING_CONTROL_CONTRIBUTIONS;

            manager.appendToGroup(groupId, viewSubMenu);
            manager.appendToGroup(groupId, new Separator());
            manager.appendToGroup(groupId, compareSubMenu);
            manager.appendToGroup(groupId, undoAction);
            manager.appendToGroup(groupId, new Separator());
            manager.appendToGroup(groupId, refreshAction);
        }
    });

    sourceFilesSubControl.getChangesTable().addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(final DoubleClickEvent event) {
            if (viewAction.isEnabled()) {
                viewAction.run();
            } else if (viewUnmodifiedAction.isEnabled()) {
                viewUnmodifiedAction.run();
            }
        }
    });

    final IContributionManager contributionManager = sourceFilesSubControl.getContributionManager();

    contributionManager.add(new Separator());
    contributionManager.add(compareToolbarAction);
    contributionManager.add(viewToolbarAction);
    contributionManager.add(undoAction);
    contributionManager.add(new Separator());
    contributionManager.add(refreshAction);

    contributionManager.update(false);
}

From source file:com.microsoft.tfs.client.common.ui.dialogs.vc.ShelvesetDetailsDialog.java

License:Open Source License

private void contributeActions() {
    final SourceFilesCheckinControl sourceFilesSubControl = getCheckinControl().getSourceFilesSubControl();

    sourceFilesSubControl.getContextMenu().addMenuListener(new IMenuListener() {
        @Override/*w ww.j  av  a 2 s.  c om*/
        public void menuAboutToShow(final IMenuManager manager) {
            final String groupId = StandardActionConstants.HOSTING_CONTROL_CONTRIBUTIONS;

            manager.appendToGroup(groupId, viewSubMenu);
            manager.appendToGroup(groupId, new Separator());
            manager.appendToGroup(groupId, compareSubMenu);
        }
    });

    sourceFilesSubControl.getChangesTable().addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(final DoubleClickEvent event) {
            if (viewAction.isEnabled()) {
                viewAction.run();
            } else if (viewUnmodifiedAction.isEnabled()) {
                viewUnmodifiedAction.run();
            }
        }
    });

    final IContributionManager contributionManager = sourceFilesSubControl.getContributionManager();

    contributionManager.add(new Separator());
    contributionManager.add(compareToolbarAction);
    contributionManager.add(viewToolbarAction);

    contributionManager.update(false);
}

From source file:com.nokia.carbide.cpp.pi.address.GenericAddrTable.java

License:Open Source License

public void setIsDrilldown(boolean isDrilldown) {
    this.isDrilldown = isDrilldown;
    copyDrilldownAction.setEnabled(isDrilldown);
    saveDrilldownAction.setEnabled(isDrilldown);

    // may need to clean up stale Edit & File menu entry for PICopyDrilldown and PISaveDrilldown 
    if (!isDrilldown) {
        IMenuManager editMenuManager = PIPageEditor.getActionBars().getMenuManager()
                .findMenuUsingPath(IIDEActionConstants.M_EDIT);

        if (editMenuManager instanceof SubMenuManager) {
            IContributionManager editManager = ((SubMenuManager) editMenuManager).getParent();
            ActionContributionItem item;

            editMenuManager.remove("PICopyDrilldown"); //$NON-NLS-1$
            item = new ActionContributionItem(copyDrilldownAction);
            item.setVisible(true);// w  w w.j  a  v  a 2 s .c o  m
            editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);

            editMenuManager.remove("PICopyTable"); //$NON-NLS-1$
            copyTableAction.setEnabled(table.getItemCount() > 0);
            item = new ActionContributionItem(copyTableAction);
            item.setVisible(true);
            editManager.prependToGroup(IIDEActionConstants.CUT_EXT, item);
        }

        IMenuManager fileMenuManager = PIPageEditor.getActionBars().getMenuManager()
                .findMenuUsingPath(IIDEActionConstants.M_FILE);

        if (fileMenuManager instanceof SubMenuManager) {
            IContributionManager fileManager = ((SubMenuManager) fileMenuManager).getParent();
            ActionContributionItem item;

            fileMenuManager.remove("PISaveTable"); //$NON-NLS-1$
            saveTableAction.setEnabled(table.getItemCount() > 0);
            item = new ActionContributionItem(saveTableAction);
            item.setVisible(true);
            fileManager.insertAfter("saveAll", item); //$NON-NLS-1$

            fileMenuManager.remove("PISaveDrilldown"); //$NON-NLS-1$
            item = new ActionContributionItem(saveDrilldownAction);
            item.setVisible(true);
            fileManager.insertAfter("PISaveTable", item); //$NON-NLS-1$
            fileManager.update(true);
        }
    }
}

From source file:com.nokia.carbide.remoteconnections.internal.ui.ConnectionStatusSelectorContribution.java

License:Open Source License

@Override
public void update() {
    IContributionManager parent = getParent();
    if (parent != null)
        parent.update(true);
}

From source file:com.nokia.tools.variant.carbidev.ApplicationActionBarAdvisor.java

License:Open Source License

private void hackProperties(IWorkbenchWindow window) {

    window.addPageListener(new IPageListener() {

        public void pageActivated(IWorkbenchPage page) {

            getAndHideProperties(page);//  w  w  w. ja v a2  s .  c  o  m

        }

        public void pageClosed(IWorkbenchPage page) {

        }

        public void pageOpened(IWorkbenchPage page) {
            getAndHideProperties(page);

        }

    });

    window.getPartService().addPartListener(new IPartListener() {

        public void partActivated(IWorkbenchPart part) {
            getAndHideProperties(part.getSite().getPage());
        }

        public void partBroughtToTop(IWorkbenchPart part) {
            getAndHideProperties(part.getSite().getPage());
        }

        public void partClosed(IWorkbenchPart part) {
            handlePropertiesVisibility(part);

        }

        private void handlePropertiesVisibility(IWorkbenchPart part) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            if (workbench != null) {
                IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                if (activeWorkbenchWindow != null) {
                    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
                    if (activePage != null) {
                        IEditorPart activeEditor = activePage.getActiveEditor();
                        if (activeEditor != null) {
                            return;
                        }
                    }
                }
            }
            if (propertiesControl != null && !propertiesControl.isDisposed()) {
                propertiesControl.setVisible(false);
            } else {
                getAndHideProperties(part.getSite().getPage());
            }
        }

        public void partDeactivated(IWorkbenchPart part) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            if (workbench != null) {
                IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                if (activeWorkbenchWindow != null) {
                    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
                    if (activePage != null) {
                        IEditorPart activeEditor = activePage.getActiveEditor();
                        if (activeEditor != null) {
                            return;
                        }
                    }
                }
            }
            if (propertiesControl != null && !propertiesControl.isDisposed()) {
                propertiesControl.setVisible(false);
            } else {
                getAndHideProperties(part.getSite().getPage());
            }
        }

        public void partOpened(IWorkbenchPart part) {
            IWorkbench workbench = PlatformUI.getWorkbench();
            if (workbench != null) {
                IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
                if (activeWorkbenchWindow != null) {
                    IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
                    if (activePage != null) {
                        IEditorPart activeEditor = activePage.getActiveEditor();
                        if (activeEditor != null) {
                            return;
                        }
                    }
                }
            }
            if (part instanceof PropertySheet) {
                PageBookView findView = (PageBookView) part;
                if (findView.getCurrentPage() instanceof PropertySheetPage) {
                    PropertySheetPage currentPage = (PropertySheetPage) findView.getCurrentPage();
                    SubActionBars actionBars = (SubActionBars) currentPage.getSite().getActionBars();
                    SubToolBarManager toolBarManager = (SubToolBarManager) actionBars.getToolBarManager();
                    IContributionManager parent2 = toolBarManager.getParent();
                    parent2.removeAll();
                    parent2.update(true);
                    propertiesControl = (Composite) currentPage.getControl();
                    propertiesControl.setVisible(false);
                    propertiesControl.addPaintListener(new PaintListener() {

                        public void paintControl(PaintEvent e) {
                            propertiesControl.setVisible(false);

                        }

                    });
                }
            }
        }

    });

}

From source file:com.nokia.tools.variant.carbidev.ApplicationActionBarAdvisor.java

License:Open Source License

private void getAndHideProperties(IWorkbenchPage page) {
    IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (activeWorkbenchWindow != null) {
        IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
        if (activePage != null) {
            IEditorPart activeEditor = activePage.getActiveEditor();
            if (activeEditor != null) {
                return;
            }/*from ww w.j  a  va  2 s. c o  m*/
        }
    }
    PageBookView findView = (PageBookView) page.findView("org.eclipse.ui.views.PropertySheet");
    if (findView != null && findView.getCurrentPage() instanceof PropertySheetPage) {
        PropertySheetPage currentPage = (PropertySheetPage) findView.getCurrentPage();
        SubActionBars actionBars = (SubActionBars) currentPage.getSite().getActionBars();
        SubToolBarManager toolBarManager = (SubToolBarManager) actionBars.getToolBarManager();
        IContributionManager parent2 = toolBarManager.getParent();
        parent2.removeAll();
        parent2.update(true);
        propertiesControl = (Composite) currentPage.getControl();
        propertiesControl.setVisible(false);
        propertiesControl.addPaintListener(new PaintListener() {

            public void paintControl(PaintEvent e) {
                propertiesControl.setVisible(false);

            }

        });
    }
}

From source file:com.sonatype.buildserver.eclipse.ui.StatusLineCLabelContribution.java

License:Open Source License

public void setText(String text) {
    if (text == null)
        throw new NullPointerException();

    this.text = text;

    if (label != null && !label.isDisposed())
        label.setText(stripText(text));//from   w  w w . j  a  va2 s  .c  o m

    if (this.text.length() == 0) {
        if (isVisible()) {
            setVisible(false);
            IContributionManager contributionManager = getParent();

            if (contributionManager != null)
                contributionManager.update(true);
        }
    } else {
        if (!isVisible()) {
            setVisible(true);
            IContributionManager contributionManager = getParent();

            if (contributionManager != null)
                contributionManager.update(true);
        }
    }
}