Example usage for org.eclipse.jface.action IMenuManager getId

List of usage examples for org.eclipse.jface.action IMenuManager getId

Introduction

In this page you can find the example usage for org.eclipse.jface.action IMenuManager getId.

Prototype

String getId();

Source Link

Document

Returns the identifier of this contribution item.

Usage

From source file:com.iw.plugins.spindle.editors.SummarySourceViewer.java

License:Mozilla Public License

protected final IMenuListener getContextMenuListener() {
    if (menuListener == null) {
        menuListener = new IMenuListener() {

            public void menuAboutToShow(IMenuManager menu) {
                String id = menu.getId();
                if ("readonly-source-viewer".equals(id)) {
                    getTextWidget().setFocus();
                    if (popupListener != null) {
                        popupListener.menuAboutToShow(menu);
                    }//from  www.j av  a2 s  . co  m
                }
            }
        };
    }
    return menuListener;
}

From source file:com.nokia.tools.vct.confml.editor.include.xincmodel.presentation.EXincModelActionBarContributor.java

License:Open Source License

/**
 * This populates the pop-up menu before it appears.
 * <!-- begin-user-doc -->/*  w  w w .  j  a  va2 s  .  c  o  m*/
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void menuAboutToShow(IMenuManager menuManager) {
    if ("targets".equals(menuManager.getId())) {
        if ((style & ADDITIONS_LAST_STYLE) == 0) {
            menuManager.add(new Separator("additions"));
        }
        menuManager.add(new Separator("edit"));

        // Add the edit menu actions.
        //
        menuManager.add(new ActionContributionItem(undoAction));
        menuManager.add(new ActionContributionItem(redoAction));
        menuManager.add(new Separator());
        menuManager.add(new ActionContributionItem(copyAction));
        menuManager.add(new Separator());

        if ((style & ADDITIONS_LAST_STYLE) != 0) {
            menuManager.add(new Separator("additions"));
            menuManager.add(new Separator());
        }
        // Add our other standard marker.
        //
        menuManager.add(new Separator("additions-end"));

        addGlobalActions(menuManager);

    } else {
        super.menuAboutToShow(menuManager);
        MenuManager submenuManager = null;

        submenuManager = new MenuManager(XIncludeEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item"));
        populateManager(submenuManager, createChildActions, null);
        menuManager.insertBefore("edit", submenuManager);

        submenuManager = new MenuManager(
                XIncludeEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item"));
        populateManager(submenuManager, createSiblingActions, null);
        menuManager.insertBefore("edit", submenuManager);
    }
}

From source file:org.eclipse.cdt.debug.internal.ui.disassembly.viewer.DisassemblyPane.java

License:Open Source License

protected final IMenuListener getContextMenuListener() {
    if (fMenuListener == null) {
        fMenuListener = new IMenuListener() {

            @Override// w ww  . j  a v  a2 s .com
            public void menuAboutToShow(IMenuManager menu) {
                String id = menu.getId();
                if (getRulerContextMenuId().equals(id)) {
                    //                        setFocus();
                    rulerContextMenuAboutToShow(menu);
                } else if (getViewContextMenuId().equals(id)) {
                    //                        setFocus();
                    viewContextMenuAboutToShow(menu);
                }
            }
        };
    }
    return fMenuListener;
}

From source file:org.eclipse.cdt.debug.internal.ui.views.disassembly.DisassemblyView.java

License:Open Source License

/**
 * Creates and returns the listener on this view's context menus.
 *
 * @return the menu listener/*from  ww w .ja  v  a  2  s .  co  m*/
 */
protected final IMenuListener getContextMenuListener() {
    if (fMenuListener == null) {
        fMenuListener = new IMenuListener() {

            public void menuAboutToShow(IMenuManager menu) {
                String id = menu.getId();
                if (getRulerContextMenuId().equals(id)) {
                    setFocus();
                    rulerContextMenuAboutToShow(menu);
                } else if (getViewContextMenuId().equals(id)) {
                    setFocus();
                    viewContextMenuAboutToShow(menu);
                }
            }
        };
    }
    return fMenuListener;
}

From source file:org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.ProviderContributionDescriptor.java

License:Open Source License

/**
 * Determines if the provider contribution descriptor has contributions
 * for a given popup menu with a given selection as a context.
 * //from   www. jav  a  2  s .c  om
 * @param popupMenu The target popup menu manager
 * @param selection The menu context (selection)
 * @return whether contribution are available or not
 */
public boolean hasContributionsFor(IMenuManager popupMenu, ISelection selection) {
    assert null != popupMenu : "null popupMenu"; //$NON-NLS-1$
    assert null != selection : "null selection"; //$NON-NLS-1$

    String popupId = popupMenu.getId();
    Class popupClass = popupMenu.getClass();

    Iterator iter = popupContributions.iterator();
    while (iter.hasNext()) {
        PopupContributionDescriptor contribution = (PopupContributionDescriptor) iter.next();
        if (contribution.appliesTo(popupId, popupClass, selection))
            return true;
    }
    return false;
}

From source file:org.eclipse.gmf.runtime.common.ui.services.action.internal.contributionitem.ProviderContributionDescriptor.java

License:Open Source License

/**
 * Gets a list of contributions available in the descriptor for a given 
 * popup menu with a given selection as a context.
 * /*from   w  ww.  j  av a 2s  .c  om*/
 * @param popupMenu The target popup menu manager
 * @param selection The menu context (selection)
 * @return a list of contributions
 */
public List getContributionsFor(IMenuManager popupMenu, ISelection selection) {
    assert null != popupMenu : "null popupMenu"; //$NON-NLS-1$
    assert null != selection : "null selection"; //$NON-NLS-1$

    List contributions = new ArrayList();
    Iterator iter = popupContributions.iterator();
    while (iter.hasNext()) {
        PopupContributionDescriptor contribution = (PopupContributionDescriptor) iter.next();
        if (contribution.appliesTo(popupMenu.getId(), popupMenu.getClass(), selection)) {
            contributions.addAll(contribution.getContributionItems());
        }
    }
    return contributions;
}

From source file:org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.java

License:Open Source License

protected IMenuListener createContextMenuListener() {
    final IMenuListener superListener = super.createContextMenuListener();
    return new IMenuListener() {
        public void menuAboutToShow(IMenuManager menu) {
            if (!getOverviewRulerContextMenuId().equals(menu.getId())) {
                superListener.menuAboutToShow(menu);
                return;
            }//w w w .  j  a va 2  s.co  m
            setFocus();
            overviewRulerContextMenuAboutToShow(menu);
        }
    };
}

From source file:org.eclipse.ui.texteditor.AbstractTextEditor.java

License:Open Source License

/**
 * Creates the listener on this editor's context menus.
 *
 * @return the created menu listener// ww  w . j av  a 2  s. c o  m
 * @since 3.4
 */
protected IMenuListener createContextMenuListener() {
    return new IMenuListener() {
        public void menuAboutToShow(IMenuManager menu) {
            String id = menu.getId();
            if (getRulerContextMenuId().equals(id)) {
                setFocus();
                rulerContextMenuAboutToShow(menu);
            } else if (getEditorContextMenuId().equals(id)) {
                setFocus();
                editorContextMenuAboutToShow(menu);
            }
        }
    };
}

From source file:org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorActionGroup.java

License:Open Source License

private void addRefactorSubmenu(IMenuManager menu) {

    IMenuManager refactorSubmenu = new MenuManager(RefactoringWizardMessages.RefactorMenu_label, MENU_ID);
    refactorSubmenu.addMenuListener(new IMenuListener() {
        public void menuAboutToShow(IMenuManager manager) {
            refactorMenuShown(manager);/*w ww  .jav  a2 s.c o  m*/
        }
    });
    refactorSubmenu.add(fNoActionAvailable);
    if (menu.find(refactorSubmenu.getId()) == null) {
        if (menu.find(fGroupName) == null) {
            menu.add(refactorSubmenu);
        } else {
            menu.appendToGroup(fGroupName, refactorSubmenu);
        }
    }
}

From source file:org.l2x6.eircc.ui.editor.AbstractIrcEditor.java

License:Open Source License

/**
 * Creates the listener on this editor's context menus.
 *
 * @return the created menu listener/*from  ww w.java  2 s  . co  m*/
 * @since 3.4
 */
protected IMenuListener createContextMenuListener() {
    return new IMenuListener() {
        public void menuAboutToShow(IMenuManager menu) {
            String id = menu.getId();
            if (getEditorContextMenuId().equals(id)) {
                setFocus();
                editorContextMenuAboutToShow(menu);
            }
        }
    };
}