Java Code Examples for org.eclipse.jface.action.IMenuManager#findMenuUsingPath()

The following examples show how to use org.eclipse.jface.action.IMenuManager#findMenuUsingPath() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JavaOutlinePage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Convenience method to add the action installed under the given actionID to the
 * specified group of the menu.
 *
 * @param menu		the menu manager
 * @param group		the group to which to add the action
 * @param actionID	the ID of the new action
 */
protected void addAction(IMenuManager menu, String group, String actionID) {
	IAction action= getAction(actionID);
	if (action != null) {
		if (action instanceof IUpdate)
			((IUpdate) action).update();

		if (action.isEnabled()) {
	 		IMenuManager subMenu= menu.findMenuUsingPath(group);
	 		if (subMenu != null)
	 			subMenu.add(action);
	 		else
	 			menu.appendToGroup(group, action);
		}
	}
}
 
Example 2
Source File: TLAEditorActionContributor.java    From tlaplus with MIT License 5 votes vote down vote up
public void init(IActionBars bars)
{
    super.init(bars);

    IMenuManager menuManager = bars.getMenuManager();
    IMenuManager editMenu = menuManager.findMenuUsingPath("toolbox.edit.menu");
    if (editMenu != null)
    {
        editMenu.add(new Separator());
        editMenu.add(fContentAssistProposal);
        editMenu.add(fContentAssistTip);
    }
}
 
Example 3
Source File: TLAMultiPageEditorActionBarContributor.java    From tlaplus with MIT License 5 votes vote down vote up
public void init(IActionBars bars)
{
    super.init(bars);

    IMenuManager menuManager = bars.getMenuManager();
    IMenuManager editMenu = menuManager.findMenuUsingPath("toolbox.edit.menu");
    if (editMenu != null)
    {
        editMenu.add(new Separator());
        editMenu.add(fContentAssistProposal);
        editMenu.add(fContentAssistTip);
    }
}
 
Example 4
Source File: TypeScriptEditorActionContributor.java    From typescript.java with MIT License 5 votes vote down vote up
@Override
public void contributeToMenu(IMenuManager menu) {
	super.contributeToMenu(menu);

	IMenuManager navigateMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
	if (navigateMenu != null) {
		navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fShowOutline);
	}
}
 
Example 5
Source File: JSActionContributor.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void contributeToMenu(IMenuManager menu)
{
	super.contributeToMenu(menu);

	IMenuManager navigateMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);

	if (navigateMenu != null)
	{
		navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fOpenDeclaration);
	}
}
 
Example 6
Source File: BasicCompilationUnitEditorActionContributor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void contributeToMenu(IMenuManager menu) {

	super.contributeToMenu(menu);
	if (fContentAssistMenuListener != null)
		fContentAssistMenuListener.dispose();

	IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
	if (editMenu != null) {
		editMenu.add(fChangeEncodingAction);
		IMenuManager caMenu= new MenuManager(JavaEditorMessages.BasicEditorActionContributor_specific_content_assist_menu, "specific_content_assist"); //$NON-NLS-1$
		editMenu.insertAfter(ITextEditorActionConstants.GROUP_ASSIST, caMenu);

		caMenu.add(fRetargetContentAssist);
		Collection<CompletionProposalCategory> descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
		List<IAction> specificAssistActions= new ArrayList<IAction>(descriptors.size());
		for (Iterator<CompletionProposalCategory> it= descriptors.iterator(); it.hasNext();) {
			final CompletionProposalCategory cat= it.next();
			if (cat.hasComputers()) {
				IAction caAction= new SpecificContentAssistAction(cat);
				caMenu.add(caAction);
				specificAssistActions.add(caAction);
			}
		}
		fSpecificAssistActions= specificAssistActions.toArray(new SpecificContentAssistAction[specificAssistActions.size()]);
		if (fSpecificAssistActions.length > 0) {
			fContentAssistMenuListener= new MenuListener(caMenu);
			caMenu.addMenuListener(fContentAssistMenuListener);
		}
		caMenu.add(new Separator("context_info")); //$NON-NLS-1$
		caMenu.add(fContextInformation);

		editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, fQuickAssistAction);
	}
}
 
Example 7
Source File: CompilationUnitEditorActionContributor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void contributeToMenu(IMenuManager menu) {
	super.contributeToMenu(menu);

	IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
	if (editMenu != null) {
		editMenu.appendToGroup(IContextMenuConstants.GROUP_ADDITIONS, fToggleInsertModeAction);
	}
}
 
Example 8
Source File: BasicJavaEditorActionContributor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void contributeToMenu(IMenuManager menu) {

	super.contributeToMenu(menu);

	IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
	if (editMenu != null) {

		MenuManager structureSelection= new MenuManager(JavaEditorMessages.ExpandSelectionMenu_label, "expandSelection"); //$NON-NLS-1$
		editMenu.insertAfter(ITextEditorActionConstants.SELECT_ALL, structureSelection);
		structureSelection.add(fStructureSelectEnclosingAction);
		structureSelection.add(fStructureSelectNextAction);
		structureSelection.add(fStructureSelectPreviousAction);
		structureSelection.add(fStructureSelectHistoryAction);

		editMenu.appendToGroup(ITextEditorActionConstants.GROUP_INFORMATION, fRetargetShowInformationAction);
	}

	IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
	if (navigateMenu != null) {
		navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fShowOutline);
		navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, fOpenHierarchy);
	}

	IMenuManager gotoMenu= menu.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
	if (gotoMenu != null) {
		gotoMenu.add(new Separator("additions2"));  //$NON-NLS-1$
		gotoMenu.appendToGroup("additions2", fGotoPreviousMemberAction); //$NON-NLS-1$
		gotoMenu.appendToGroup("additions2", fGotoNextMemberAction); //$NON-NLS-1$
		gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
	}
}
 
Example 9
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void prepareNavigateMenu(IMenuManager menu) {
	IMenuManager navigateMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
	if(navigateMenu != null) {
		navigateMenu.appendToGroup(IWorkbenchActionConstants.SHOW_EXT, pushItem(EditorCommandIds.QuickOutline));
	}
	
	IMenuManager gotoMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE + "/goTo");
	if(gotoMenu != null) {
		gotoMenu.add(new Separator("additions2"));
		
		gotoMenu.appendToGroup("additions2", pushItem(EditorCommandIds.GoToMatchingBracket));
	}
}
 
Example 10
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void prepareEditMenu(IMenuManager menu) {
	IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
	if(editMenu != null) {
		editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, pushItem(
			ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, 
			ITextEditorActionConstants.CONTENT_ASSIST));
		
		editMenu.appendToGroup(ITextEditorActionConstants.GROUP_ASSIST, pushItem(
			ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION, 
			ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION));
	}
	
}
 
Example 11
Source File: LangEditorActionContributor.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
protected void prepareSourceMenu(IMenuManager menu) {
	IMenuManager sourceMenu = menu.findMenuUsingPath(SOURCE_MENU_ID);
	if(sourceMenu == null) {
		// This structure should have been created declaratively by plugin.xml, 
		LangCore.logError("Source menu " + SOURCE_MENU_ID + " not created by plugin.xml!");

		// We can create it programmatically, by other plugin.xml declarative menu contribution will
		// fail to find the menu because it will be created too late.
		sourceMenu = LangEditorContextMenuContributor.createSourceMenuSkeleton();
		menu.insertAfter(IWorkbenchActionConstants.M_EDIT, sourceMenu);
	}
	
	contributeSourceMenu(sourceMenu);
}
 
Example 12
Source File: TexEditorActionContributor.java    From texlipse with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public void contributeToMenu(IMenuManager menuManager) {
	super.contributeToMenu(menuManager);
	
    //Add a new group to the navigation/goto menu
    IMenuManager gotoMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE+"/"+IWorkbenchActionConstants.GO_TO);
    if (gotoMenu != null) {
        gotoMenu.add(new Separator("additions2"));
    }
    
    IMenuManager editMenu = menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_WINDOW);
    MenuManager manager = new MenuManager("Latex Symbols");
    if (editMenu != null) {
        menuManager.insertBefore(IWorkbenchActionConstants.M_WINDOW, manager);
        MenuManager smallGreekMenu = new MenuManager("Greek lower case");
        MenuManager captialGreekMenu = new MenuManager("Greek upper case");
        MenuManager arrowsMenu = new MenuManager("Arrows");
        MenuManager compareMenu = new MenuManager("Compare symbols");
        MenuManager stdBinOpMenu = new MenuManager("Binary Operator");
        MenuManager stdBracesMenu = new MenuManager("Braces");
        MenuManager stdAccentsMenu = new MenuManager("Accents");
        manager.add(captialGreekMenu);
        manager.add(smallGreekMenu);
        manager.add(new Separator());
        manager.add(arrowsMenu);
        manager.add(compareMenu);
        manager.add(stdBinOpMenu);
        manager.add(stdBracesMenu);
        manager.add(new Separator());
        manager.add(stdAccentsMenu);
        

        for (int i = 0; i < greekSmall.length; i++)
            smallGreekMenu.add(greekSmall[i]);
        for (int i = 0; i < greekCapital.length; i++)
            captialGreekMenu.add(greekCapital[i]);
        for (int i = 0; i < arrows.length; i++)
            arrowsMenu.add(arrows[i]);
        for (int i = 0; i < stdCompare.length; i++)
            compareMenu.add(stdCompare[i]);
        for (int i = 0; i < stdBinOp.length; i++)
            stdBinOpMenu.add(stdBinOp[i]);
        for (int i = 0; i < stdBraces.length; i++)
            stdBracesMenu.add(stdBraces[i]);
        for (int i = 0; i < stdAccents.length; i++)
            stdAccentsMenu.add(stdAccents[i]);
    }
}