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

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

Introduction

In this page you can find the example usage for org.eclipse.jface.action IToolBarManager 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:org.eclipse.egit.ui.internal.commit.CommitEditor.java

License:Open Source License

/**
 * @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
 *///w w w  .  jav a2s  .c o  m
protected void createHeaderContents(IManagedForm headerForm) {
    RepositoryCommit commit = getCommit();
    ScrolledForm form = headerForm.getForm();
    new HeaderText(form.getForm(), commit.getRevCommit().name());
    form.setToolTipText(commit.getRevCommit().name());
    getToolkit().decorateFormHeading(form.getForm());

    IToolBarManager toolbar = form.getToolBarManager();

    ControlContribution repositoryLabelControl = new ControlContribution("repositoryLabel") { //$NON-NLS-1$
        @Override
        protected Control createControl(Composite parent) {
            FormToolkit toolkit = getHeaderForm().getToolkit();
            Composite composite = toolkit.createComposite(parent);
            RowLayout layout = new RowLayout();
            composite.setLayout(layout);
            composite.setBackground(null);
            String label = getCommit().getRepositoryName();

            ImageHyperlink link = new ImageHyperlink(composite, SWT.NONE);
            link.setText(label);
            link.setFont(JFaceResources.getBannerFont());
            link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            link.setToolTipText(UIText.CommitEditor_showGitRepo);
            link.addHyperlinkListener(new HyperlinkAdapter() {
                @Override
                public void linkActivated(HyperlinkEvent event) {
                    RepositoriesView view;
                    try {
                        view = (RepositoriesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
                                .getActivePage().showView(RepositoriesView.VIEW_ID);
                        view.showRepository(getCommit().getRepository());
                    } catch (PartInitException e) {
                        Activator.handleError(UIText.CommitEditor_couldNotShowRepository, e, false);
                    }
                }
            });

            return composite;
        }
    };
    toolbar.add(repositoryLabelControl);
    toolbar.add(createCommandContributionItem(CreateTagHandler.ID));
    toolbar.add(createCommandContributionItem(CreateBranchHandler.ID));
    toolbar.add(createCommandContributionItem(CheckoutHandler.ID));
    toolbar.add(createCommandContributionItem(CherryPickHandler.ID));
    toolbar.add(createCommandContributionItem(RevertHandler.ID));
    addContributions(toolbar);
    toolbar.update(true);
    getSite().setSelectionProvider(new ISelectionProvider() {

        public void setSelection(ISelection selection) {
            // Ignored
        }

        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
            // Ignored
        }

        public ISelection getSelection() {
            return new StructuredSelection(getCommit());
        }

        public void addSelectionChangedListener(ISelectionChangedListener listener) {
            // Ignored
        }
    });
}

From source file:org.eclipse.egit.ui.internal.reflog.ReflogView.java

License:Open Source License

private void updateRefLink(final String name) {
    IToolBarManager toolbar = form.getToolBarManager();
    toolbar.removeAll();//from  w w  w . j  a v a  2s .  co  m

    ControlContribution refLabelControl = new ControlContribution("refLabel") { //$NON-NLS-1$
        @Override
        protected Control createControl(Composite cParent) {
            Composite composite = toolkit.createComposite(cParent);
            composite.setLayout(new RowLayout());
            composite.setBackground(null);

            final ImageHyperlink refLink = new ImageHyperlink(composite, SWT.NONE);
            Image image = UIIcons.BRANCH.createImage();
            UIUtils.hookDisposal(refLink, image);
            refLink.setImage(image);
            refLink.setFont(JFaceResources.getBannerFont());
            refLink.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            refLink.addHyperlinkListener(new HyperlinkAdapter() {
                @Override
                public void linkActivated(HyperlinkEvent event) {
                    Repository repository = getRepository();
                    if (repository == null)
                        return;
                    RefSelectionDialog dialog = new RefSelectionDialog(refLink.getShell(), repository);
                    if (Window.OK == dialog.open())
                        showReflogFor(repository, dialog.getRefName());
                }
            });
            refLink.setText(Repository.shortenRefName(name));

            return composite;
        }
    };
    toolbar.add(refLabelControl);
    toolbar.update(true);
}

From source file:org.eclipse.egit.ui.internal.repository.BranchPropertySource.java

License:Open Source License

/**
 * @param repository//ww w  .j  av a 2s.  c  o  m
 *            the repository
 * @param fullBranchName
 *            the full name of the branch to show
 * @param page
 *            the page showing the properties
 */
public BranchPropertySource(Repository repository, String fullBranchName, PropertySheetPage page) {
    myPage = page;
    myBranchName = Repository.shortenRefName(fullBranchName);
    myRepository = repository;

    synchronized (myPage) {
        // check if the actions are already there, if not, create them
        IActionBars bars = myPage.getSite().getActionBars();
        IToolBarManager mgr = bars.getToolBarManager();

        editAction = ((ActionContributionItem) mgr.find(EDITACTIONID));
        if (editAction != null)
            ((EditAction) editAction.getAction()).setSource(this);
        else {
            editAction = new ActionContributionItem(
                    new EditAction(UIText.RepositoryPropertySource_EditConfigButton, UIIcons.EDITCONFIG, this));

            mgr.add(new Separator());
            mgr.add(editAction);
        }

        mgr.update(false);
    }
}

From source file:org.eclipse.egit.ui.internal.repository.RepositoryPropertySourceProvider.java

License:Open Source License

private void checkChangeType(SourceType type) {
    // the different pages contribute different actions, so if we
    // change to a different page type, we need to clear them
    if (lastSourceType != type) {
        IToolBarManager mgr = myPage.getSite().getActionBars().getToolBarManager();
        boolean update = false;
        update = update | mgr.remove(RepositoryPropertySource.CHANGEMODEACTIONID) != null;
        update = update | mgr.remove(RepositoryPropertySource.SINGLEVALUEACTIONID) != null;
        update = update | mgr.remove(RepositoryPropertySource.EDITACTIONID) != null;
        update = update | mgr.remove(BranchPropertySource.EDITACTIONID) != null;
        if (update)
            mgr.update(false);
    }//  ww w .j a  va2s.  com
    lastSourceType = type;
}

From source file:org.eclipse.egit.ui.internal.repository.RepositoryRemotePropertySource.java

License:Open Source License

/**
 * @param config// w  w w.  ja v a2 s . c  o m
 * @param remoteName
 * @param page
 *
 */
public RepositoryRemotePropertySource(StoredConfig config, String remoteName, PropertySheetPage page) {
    myConfig = config;
    myName = remoteName;
    IToolBarManager mgr = page.getSite().getActionBars().getToolBarManager();
    // we may have some contributions from the RepositoryPropertySource that
    // we should remove
    boolean update = false;
    update = update | mgr.remove(RepositoryPropertySource.CHANGEMODEACTIONID) != null;
    update = update | mgr.remove(RepositoryPropertySource.SINGLEVALUEACTIONID) != null;
    update = update | mgr.remove(RepositoryPropertySource.EDITACTIONID) != null;
    if (update)
        mgr.update(false);
}

From source file:org.eclipse.emf.ecp.view.model.internal.preview.e3.views.PreviewView.java

License:Open Source License

/**
 * @param toolBarManager toolBarManager the toolbar manager to which the buttons should be added.
 *//* ww  w .  java 2  s  .  co  m*/
private void addButtonsToFormToolbar(IToolBarManager toolBarManager) {

    addSampleDataButtons(toolBarManager);
    toolBarManager.add(new Separator());
    addRefreshButtons(toolBarManager);

    toolBarManager.update(true);
}

From source file:org.eclipse.emf.eef.runtime.ui.editors.pages.AbstractEEFEditorPage.java

License:Open Source License

/**
 * refresh page actions.//from   w  w w  .  j  a  v  a  2s  . c  o m
 */
protected void refreshToolbar() {
    if (getManagedForm().getForm() != null) {
        if (!actions.isEmpty()) {
            IToolBarManager toolBarManager = getManagedForm().getForm().getToolBarManager();
            for (Action action : actions) {
                toolBarManager.add(action);
            }
            toolBarManager.update(true);
        }
    }
}

From source file:org.eclipse.emf.mapping.presentation.SimpleMappedObjectViewer.java

License:Open Source License

public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager,
        IStatusLineManager statusLineManager) {
    String label = isTop ? "Top" : "Bottom";
    String oppositeLabel = isTop ? "Bottom" : "Top";

    selectNextMappedObject = new SelectObjectAction(
            MappingUIPlugin.getPlugin().getString("_UI_NextMappedObject_menu_item"),
            MappingUIPlugin.getPlugin().getImageDescriptor("full/elcl16/SelectNext" + label + "MappedObject"));
    selectNextMappedObject/*ww  w  .ja  v  a2s.  c  om*/
            .setToolTipText(MappingUIPlugin.getPlugin().getString("_UI_NextMappedObject_description"));
    selectNextMappedObject.setHoverImageDescriptor(
            MappingUIPlugin.getPlugin().getImageDescriptor("full/clcl16/SelectNext" + label + "MappedObject"));
    selectNextMappedObject.setDisabledImageDescriptor(
            MappingUIPlugin.getPlugin().getImageDescriptor("full/dlcl16/SelectNext" + label + "MappedObject"));
    toolBarManager.add(selectNextMappedObject);
    menuManager.add(selectNextMappedObject);

    selectPreviousMappedObject = new SelectObjectAction(
            MappingUIPlugin.getPlugin().getString("_UI_PreviousMappedObject_menu_item"), MappingUIPlugin
                    .getPlugin().getImageDescriptor("full/elcl16/SelectPrevious" + label + "MappedObject"));
    selectPreviousMappedObject
            .setToolTipText(MappingUIPlugin.getPlugin().getString("_UI_PreviousMappedObject_description"));
    selectPreviousMappedObject.setHoverImageDescriptor(MappingUIPlugin.getPlugin()
            .getImageDescriptor("full/clcl16/SelectPrevious" + label + "MappedObject"));
    selectPreviousMappedObject.setDisabledImageDescriptor(MappingUIPlugin.getPlugin()
            .getImageDescriptor("full/dlcl16/SelectPrevious" + label + "MappedObject"));
    toolBarManager.add(selectPreviousMappedObject);
    menuManager.add(selectPreviousMappedObject);

    menuManager.add(new Separator());

    selectNextUnmappedObject = new SelectObjectAction(
            MappingUIPlugin.getPlugin().getString("_UI_NextUnmappedObject_menu_item"), MappingUIPlugin
                    .getPlugin().getImageDescriptor("full/elcl16/SelectNext" + label + "UnmappedObject"));
    selectNextUnmappedObject
            .setToolTipText(MappingUIPlugin.getPlugin().getString("_UI_NextUnmappedObject_description"));
    selectNextUnmappedObject.setHoverImageDescriptor(MappingUIPlugin.getPlugin()
            .getImageDescriptor("full/clcl16/SelectNext" + label + "UnmappedObject"));
    selectNextUnmappedObject.setDisabledImageDescriptor(MappingUIPlugin.getPlugin()
            .getImageDescriptor("full/dlcl16/SelectNext" + label + "UnmappedObject"));
    toolBarManager.add(selectNextUnmappedObject);
    menuManager.add(selectNextUnmappedObject);

    selectPreviousUnmappedObject = new SelectObjectAction(
            MappingUIPlugin.getPlugin().getString("_UI_PreviousUnmappedObject_menu_item"), MappingUIPlugin
                    .getPlugin().getImageDescriptor("full/elcl16/SelectPrevious" + label + "UnmappedObject"));
    selectPreviousUnmappedObject
            .setToolTipText(MappingUIPlugin.getPlugin().getString("_UI_PreviousUnmappedObject_description"));
    selectPreviousUnmappedObject.setHoverImageDescriptor(MappingUIPlugin.getPlugin()
            .getImageDescriptor("full/clcl16/SelectPrevious" + label + "UnmappedObject"));
    selectPreviousUnmappedObject.setDisabledImageDescriptor(MappingUIPlugin.getPlugin()
            .getImageDescriptor("full/dlcl16/SelectPrevious" + label + "UnmappedObject"));
    toolBarManager.add(selectPreviousUnmappedObject);
    menuManager.add(selectPreviousUnmappedObject);

    menuManager.add(new Separator());

    filterMappedObjects = new Action(MappingUIPlugin.getPlugin().getString("_UI_FilterMappedObjects_menu_item"),
            MappingUIPlugin.getPlugin().getImageDescriptor("full/elcl16/HideAllMappedObjects")) {
        @Override
        public void run() {
            preserveState();
            Object input = getInput();
            setInput(input);
            restoreState();

            updateActions();
        }

        @Override
        public void setChecked(boolean checked) {
            super.setChecked(checked);
            setToolTipText(MappingUIPlugin.getPlugin()
                    .getString(checked ? "_UI_FilterMappedObjects_checked_description"
                            : "_UI_FilterMappedObjects_unchecked_description"));
        }
    };
    filterMappedObjects.setChecked(false);
    filterMappedObjects.setHoverImageDescriptor(
            MappingUIPlugin.getPlugin().getImageDescriptor("full/clcl16/HideAllMappedObjects"));
    filterMappedObjects.setDisabledImageDescriptor(
            MappingUIPlugin.getPlugin().getImageDescriptor("full/dlcl16/HideAllMappedObjects"));
    toolBarManager.add(filterMappedObjects);
    menuManager.add(filterMappedObjects);

    menuManager.add(new Separator());

    selectOtherMappedObjects = new Action(
            MappingUIPlugin.getPlugin().getString("_UI_SelectOtherMappedObjects_menu_item"), MappingUIPlugin
                    .getPlugin().getImageDescriptor("full/elcl16/Select" + oppositeLabel + "MappedObjects")) {
        @Override
        public void run() {
            selectOtherMappedObjects();
        }
    };
    selectOtherMappedObjects.setEnabled(false);
    selectOtherMappedObjects
            .setToolTipText(MappingUIPlugin.getPlugin().getString("_UI_SelectOtherMappedObjects_description"));
    selectOtherMappedObjects.setHoverImageDescriptor(MappingUIPlugin.getPlugin()
            .getImageDescriptor("full/clcl16/Select" + oppositeLabel + "MappedObjects"));
    selectOtherMappedObjects.setDisabledImageDescriptor(MappingUIPlugin.getPlugin()
            .getImageDescriptor("full/dlcl16/Select" + oppositeLabel + "MappedObjects"));
    toolBarManager.add(selectOtherMappedObjects);
    menuManager.add(selectOtherMappedObjects);

    toolBarManager.update(true);
    menuManager.update(true);
}

From source file:org.eclipse.incquery.viewers.runtime.zest.extensions.IncQueryViewersZestViewSupport.java

License:Open Source License

public void createToolbar() {
    refreshGraph/*from w  w w .  j  av a 2 s  . c  o  m*/
            .setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/refresh.gif"));
    clearGraph.setImageDescriptor(Activator.imageDescriptorFromPlugin(Activator.PLUGIN_ID, "icons/clear.gif"));

    IToolBarManager toolBarManager = getOwner().getViewSite().getActionBars().getToolBarManager();
    toolBarManager.removeAll();
    toolBarManager.add(refreshGraph);
    toolBarManager.add(clearGraph);
    if (owner instanceof IZoomableWorkbenchPart) {
        ZoomContributionViewItem toolbarZoomContributionViewItem = new ZoomContributionViewItem(
                (IZoomableWorkbenchPart) owner);
        toolBarManager.add(toolbarZoomContributionViewItem);
        toolBarManager.update(true);
    }
    IMenuManager menuManager = getOwner().getViewSite().getActionBars().getMenuManager();
    menuManager.removeAll();
    menuManager.add(createLayoutMenu());
}

From source file:org.eclipse.incquery.viewers.tooling.ui.views.ViewersMultiSandboxViewComponent.java

License:Open Source License

void fillToolBarBasedOnCurrentTab() {
    IViewerSandboxTab tab = getCurrentContributedTab();
    if (tab != null) {
        IToolBarManager mgr = getViewSite().getActionBars().getToolBarManager();
        //mgr.removeAll(); // this is moved to ViewersMultiSandboxView.fillToolBar
        for (IContributionItem item : getToolbarContributions(tab)) {
            if (item instanceof MenuManager) {
                for (IContributionItem _item : ((MenuManager) item).getItems()) {
                    mgr.add(_item);//from  w w  w.j  a  v  a  2 s  . c  om
                }
            } else {
                mgr.add(item);
            }
        }
        mgr.update(true);

        IMenuManager mmgr = getViewSite().getActionBars().getMenuManager();
        mmgr.removeAll();
        for (IContributionItem item : getDropdownMenuContributions(tab)) {
            mmgr.add(item);
        }
        mmgr.updateAll(true);

        // getViewSite().getActionBars().updateActionBars(); // this is moved to ViewersMultiSandboxView.fillToolBar
    }
}