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

The following examples show how to use org.eclipse.jface.action.IMenuManager#addMenuListener() . 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: GenerateBuildPathActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void fillContextMenu(IMenuManager menu) {
       super.fillContextMenu(menu);
       if (!canOperateOnSelection())
       	return;
       String menuText= ActionMessages.BuildPath_label;
       IMenuManager subMenu= new MenuManager(menuText, MENU_ID);
       subMenu.addMenuListener(new IMenuListener() {
       	public void menuAboutToShow(IMenuManager manager) {
       		fillViewSubMenu(manager);
       	}
       });
       subMenu.setRemoveAllWhenShown(true);
       subMenu.add(new ConfigureBuildPathAction(fSite));
       menu.appendToGroup(fGroupName, subMenu);
   }
 
Example 2
Source File: PerformanceView.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
private void createMenu() {
	IMenuManager mgr = getViewSite().getActionBars().getMenuManager();
	mgr.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager m) {
			addDynamicVisualisationSelection(m);
		}
	});
}
 
Example 3
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 4
Source File: CategoryFilterActionGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void contributeToViewMenu(IMenuManager menuManager) {
	menuManager.add(new Separator(CATEGORY_MENU_GROUP_NAME));
	menuManager.appendToGroup(CATEGORY_MENU_GROUP_NAME, fMenuAction);
	fMenuListener= new IMenuListener() {
				public void menuAboutToShow(IMenuManager manager) {
					if (!manager.isVisible())
						return;
					updateMenu(manager);
				}
			};
	menuManager.addMenuListener(fMenuListener);
	fMenuManager= menuManager;
}
 
Example 5
Source File: ViewMenus.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param contributionItems
 * @since 3.4
 */
public void createMenu(final List<IContributionItem> contributionItems){
	IMenuManager menuMgr = site.getActionBars().getMenuManager();
	menuMgr.setRemoveAllWhenShown(true);
	menuMgr.addMenuListener(new IMenuListener() {
		@Override
		public void menuAboutToShow(IMenuManager manager){
			fillContextMenu(menuMgr, contributionItems);
		}
	});
	menuMgr.add(new Separator()); // for the entry to appear
}
 
Example 6
Source File: LamiReportView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createPartControl(@Nullable Composite parent) {
    LamiAnalysisReport report = fReport;
    if (report == null || parent == null) {
        return;
    }

    setPartName(report.getName());

    fTabFolder = new CTabFolder(parent, SWT.NONE);
    fTabFolder.setSimple(false);

    for (LamiResultTable table : report.getTables()) {
        String name = table.getTableClass().getTableTitle();

        CTabItem tabItem = new CTabItem(fTabFolder, SWT.NULL);
        tabItem.setText(name);

        SashForm sf = new SashForm(fTabFolder, SWT.NONE);
        fTabPages.add(new LamiReportViewTabPage(sf, table));
        tabItem.setControl(sf);
    }

    /* Add toolbar buttons */
    Action toggleTableAction = new ToggleTableAction();
    toggleTableAction.setText(Messages.LamiReportView_ActivateTableAction_ButtonName);
    toggleTableAction.setToolTipText(Messages.LamiReportView_ActivateTableAction_ButtonTooltip);
    toggleTableAction.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath("icons/table.gif")); //$NON-NLS-1$

    IActionBars actionBars = getViewSite().getActionBars();
    IToolBarManager toolbarMgr = actionBars.getToolBarManager();
    toolbarMgr.add(toggleTableAction);

    fNewChartAction.setText(Messages.LamiReportView_NewCustomChart);

    fClearCustomViewsAction.setText(Messages.LamiReportView_ClearAllCustomViews);
    IMenuManager menuMgr = actionBars.getMenuManager();
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener((@Nullable IMenuManager manager) -> {
        if (manager != null) {
            populateMenu(manager);
        }
    });
    populateMenu(menuMgr);

    /* Select the first tab initially */
    CTabFolder tf = checkNotNull(fTabFolder);
    if (tf.getItemCount() > 0) {
        tf.setSelection(0);
    }

}