org.eclipse.jface.action.IMenuManager Java Examples

The following examples show how to use org.eclipse.jface.action.IMenuManager. 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 Project: typescript.java   Author: angelozerr   File: ReferencesSearchGroup.java    License: MIT License 6 votes vote down vote up
public void fillContextMenu(IMenuManager manager) {
	MenuManager javaSearchMM = new MenuManager(getName(), IContextMenuConstants.GROUP_SEARCH);
	// addAction(fFindReferencesAction, javaSearchMM);
	addAction(fFindReferencesInProjectAction, javaSearchMM);
	// addAction(fFindReferencesInHierarchyAction, javaSearchMM);

	javaSearchMM.add(new Separator());
	//
	// Iterator iter= SearchUtil.getLRUWorkingSets().sortedIterator();
	// while (iter.hasNext()) {
	// addWorkingSetAction((IWorkingSet[]) iter.next(), javaSearchMM);
	// }
	// addAction(fFindReferencesInWorkingSetAction, javaSearchMM);

	if (!javaSearchMM.isEmpty())
		manager.appendToGroup(fGroupId, javaSearchMM);
}
 
Example #2
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: JavaSearchResultPage.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void init(IPageSite site) {
	super.init(site);
	IMenuManager menuManager = site.getActionBars().getMenuManager();
	menuManager.insertBefore(IContextMenuConstants.GROUP_PROPERTIES, new Separator(GROUP_FILTERING));
	fActionGroup.fillActionBars(site.getActionBars());
	menuManager.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, new Action(SearchMessages.JavaSearchResultPage_preferences_label) {
		@Override
		public void run() {
			String pageId= "org.eclipse.search.preferences.SearchPreferencePage"; //$NON-NLS-1$
			String[] displayedPages= { pageId,
					"org.eclipse.ui.editors.preferencePages.Annotations", //$NON-NLS-1$
					"org.eclipse.ui.preferencePages.ColorsAndFonts" //$NON-NLS-1$
			};
			PreferencesUtil.createPreferenceDialogOn(JavaPlugin.getActiveWorkbenchShell(), pageId, displayedPages, null).open();
		}
	});
}
 
Example #3
/**
 * Adds the filter actions to the menu
 *
 * @param mm the menu manager
 */
public void fillViewMenu(IMenuManager mm) {
	if (mm.find(IWorkingSetActionGroup.ACTION_GROUP) == null) {
		mm.add(new Separator(IWorkingSetActionGroup.ACTION_GROUP));
	}
	add(mm, fSelectWorkingSetAction);
	add(mm, fClearWorkingSetAction);
	add(mm, fEditWorkingSetAction);
	add(mm, new Separator());
	add(mm, new Separator(LRU_GROUP));

	fMenuManager= mm;
	fMenuListener= new IMenuListener() {
		public void menuAboutToShow(IMenuManager manager) {
			removePreviousLRUWorkingSetActions(manager);
			addLRUWorkingSetActions(manager);
		}
	};
	fMenuManager.addMenuListener(fMenuListener);
}
 
Example #4
Source Project: translationstudio8   Author: heartsome   File: EditActionGroup.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void fillContextMenu(IMenuManager menu) {
	IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();

	boolean anyResourceSelected = !selection.isEmpty()
			&& ResourceSelectionUtil.allResourcesAreOfType(selection, IResource.PROJECT | IResource.FOLDER
					| IResource.FILE);

	copyAction.selectionChanged(selection);
	// menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, copyAction);
	pasteAction.selectionChanged(selection);
	// menu.insertAfter(copyAction.getId(), pasteAction);
	// menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, pasteAction);

	if (anyResourceSelected) {
		deleteAction.selectionChanged(selection);
		// menu.insertAfter(pasteAction.getId(), deleteAction);
		menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, deleteAction);
	}
}
 
Example #5
Source Project: n4js   Author: eclipse   File: N4JSNavigatorActionProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void fillContextMenu(final IMenuManager menu) {
	// {@link N4JSProjectActionGroup} does enablement-logic
	// on its own, thus always invoke it here
	projectGroup.fillContextMenu(menu);

	// Only delegate to {@link N4JSWorkingSetActionProvider},
	// if the current selection contains working sets.
	if (selectionContainsWorkingSet) {
		workingSetActionProvider.fillContextMenu(menu);
	}

	if (assignWorkingSetsAction.isEnabled()) {
		menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, assignWorkingSetsAction);
	}
}
 
Example #6
Source Project: birt   Author: eclipse   File: TabularLevelNodeProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the context menu for the given object. Gets the action from the
 * actionRegistry and adds the action to the menu.
 * 
 * @param menu
 *            the menu
 * @param object
 *            the object
 */
public void createContextMenu( TreeViewer sourceViewer, Object object,
		IMenuManager menu )
{
	super.createContextMenu( sourceViewer, object, menu );

	if ( ( (LevelHandle) object ).canEdit( ) )
	{
		menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS,
				new EditCubeLevelAction( object,
						Messages.getString( "CubeLevelNodeProvider.menu.text" ) ) ); //$NON-NLS-1$
	}

	menu.insertBefore( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", //$NON-NLS-1$
			new ShowPropertyAction( object ) );

	menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", new Separator( ) ); //$NON-NLS-1$
	IAction action = new RefreshAction( sourceViewer );
	if (action.isEnabled( ))
	{
		menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", action ); //$NON-NLS-1$
	}
}
 
Example #7
Source Project: RDFS   Author: iVCE   File: ServerView.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Contextual menu
 */
private void createContextMenu() {
  // Create menu manager.
  MenuManager menuMgr = new MenuManager();
  menuMgr.setRemoveAllWhenShown(true);
  menuMgr.addMenuListener(new IMenuListener() {
    public void menuAboutToShow(IMenuManager mgr) {
      fillContextMenu(mgr);
    }
  });

  // Create menu.
  Menu menu = menuMgr.createContextMenu(viewer.getControl());
  viewer.getControl().setMenu(menu);

  // Register menu for extension.
  getSite().registerContextMenu(menuMgr, viewer);
}
 
Example #8
Source Project: gama   Author: gama-platform   File: GamlEditor.java    License: GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void rulerContextMenuAboutToShow(final IMenuManager menu) {
	super.rulerContextMenuAboutToShow(menu);
	menu.remove("projection");

	final IMenuManager foldingMenu = new MenuManager(XtextUIMessages.Editor_FoldingMenu_name, "projection"); //$NON-NLS-1$
	menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, foldingMenu);
	IAction action = getAction("FoldingToggle"); //$NON-NLS-1$
	foldingMenu.add(action);
	action = getAction("FoldingExpandAll"); //$NON-NLS-1$
	foldingMenu.add(action);
	action = getAction("FoldingCollapseAll"); //$NON-NLS-1$
	foldingMenu.add(action);
	action = getAction("FoldingCollapseStrings"); //$NON-NLS-1$
	foldingMenu.add(action);
	action = getAction("FoldingRestore"); //$NON-NLS-1$
	foldingMenu.add(action);
}
 
Example #9
Source Project: birt   Author: eclipse   File: LeveAttributelNodeProvider.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the context menu for the given object. Gets the action from the
 * actionRegistry and adds the action to the menu.
 * 
 * @param menu
 *            the menu
 * @param object
 *            the object
 */
public void createContextMenu( TreeViewer sourceViewer, Object object,
		IMenuManager menu )
{
	super.createContextMenu( sourceViewer, object, menu );

	menu.insertBefore( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", //$NON-NLS-1$
			new ShowPropertyAction( object ) );

	menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", new Separator( ) ); //$NON-NLS-1$
	IAction action = new RefreshAction( sourceViewer );
	if (action.isEnabled( ))
	{
		menu.insertAfter( IWorkbenchActionConstants.MB_ADDITIONS + "-refresh", action ); //$NON-NLS-1$
	}
}
 
Example #10
Source Project: tlaplus   Author: tlaplus   File: FilteredItemsSelectionDialog.java    License: MIT License 6 votes vote down vote up
private void createPopupMenu() {
	removeHistoryItemAction = new RemoveHistoryItemAction();
	removeHistoryActionContributionItem = new ActionContributionItem(
			removeHistoryItemAction);

	contextMenuManager = new MenuManager();
	contextMenuManager.setRemoveAllWhenShown(true);
	contextMenuManager.addMenuListener(new IMenuListener() {
		
		public void menuAboutToShow(IMenuManager manager) {
			fillContextMenu(manager);
		}
	});

	final Table table = list.getTable();
	Menu menu= contextMenuManager.createContextMenu(table);
	table.setMenu(menu);
}
 
Example #11
Source Project: spotbugs   Author: spotbugs   File: BugActionProvider.java    License: GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void fillContextMenu(IMenuManager menu) {
    super.fillContextMenu(menu);

    menu.insertBefore(ICommonMenuConstants.GROUP_PORT, new Separator("fb"));
    menu.insertBefore(ICommonMenuConstants.GROUP_PORT, new Separator("fb.project"));
    menu.insertBefore(ICommonMenuConstants.GROUP_PORT, new Separator("fb.filter"));
}
 
Example #12
Source Project: lapse-plus   Author: OWASP   File: SinkView.java    License: GNU General Public License v3.0 5 votes vote down vote up
private void hookContextMenu() {
    MenuManager menuMgr = new MenuManager("#PopupMenu");
    menuMgr.setRemoveAllWhenShown(true);
    menuMgr.addMenuListener(new IMenuListener() {
        public void menuAboutToShow(IMenuManager manager) {
            SinkView.this.fillContextMenu(manager);
        }
    });
    Menu menu = menuMgr.createContextMenu(viewer.getControl());
    viewer.getControl().setMenu(menu);
    getSite().registerContextMenu(menuMgr, viewer);
}
 
Example #13
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: NewWizardsActionGroup.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fillContextMenu(IMenuManager menu) {
	super.fillContextMenu(menu);

	ISelection selection= getContext().getSelection();
	if (selection instanceof IStructuredSelection) {
		if (canEnable((IStructuredSelection)selection)) {
	        MenuManager newMenu= new MenuManager(ActionMessages.NewWizardsActionGroup_new);
	        menu.appendToGroup(IContextMenuConstants.GROUP_NEW, newMenu);
	        newMenu.add(getNewWizardMenu());
		}
	}

}
 
Example #14
Source Project: LogViewer   Author: anb0s   File: LogViewer.java    License: Eclipse Public License 2.0 5 votes vote down vote up
private void fillContextMenu(IMenuManager manager) {
    manager.add(refreshCurrentFileAction);
    manager.add(startTailOnCurrentFile);
    manager.add(stopTailOnCurrentFile);
    manager.add(fileCloseAction);
    manager.add(fileClearAction);
    manager.add(new Separator());
    manager.add(fileEncodingAction);
    manager.add(tabRenameAction);
    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
 
Example #15
Source Project: nebula   Author: eclipse   File: XViewerCustomMenu.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public void init(final XViewer xviewer) {
   this.xViewer = xviewer;
   setupActions();
   xViewer.getTree().addListener(SWT.KeyUp, e-> {
       if (e.keyCode == 'c' && e.stateMask == (SWT.CONTROL | SWT.SHIFT)) {
           performCopyColumnCells();
        } else if (e.keyCode == 'b' && e.stateMask == (SWT.CONTROL | SWT.SHIFT)) {
           performViewOrCopyCell(Option.Copy);
        } else if (e.keyCode == 'v' && e.stateMask == (SWT.CONTROL | SWT.SHIFT)) {
           performViewOrCopyCell(Option.View);
        } else if (e.keyCode == 'c' && e.stateMask == SWT.CONTROL) {
           performCopy();
        }
   });
   xViewer.getTree().addListener(SWT.Dispose, e-> {
         if (clipboard != null) {
            clipboard.dispose();
         }
   });
   xViewer.getMenuManager().addMenuListener(new IMenuListener() {
      @Override
      public void menuAboutToShow(IMenuManager manager) {
         if (headerMouseClick) {
            setupMenuForHeader();
            xviewer.updateMenuActionsForHeader();
         } else {
            setupMenuForTable();
            xViewer.updateMenuActionsForTable();
         }
      }
   });
   xViewer.getTree().addListener(SWT.MenuDetect, event -> {
         Point pt = Display.getCurrent().map(null, xViewer.getTree(), new Point(event.x, event.y));
         Rectangle clientArea = xViewer.getTree().getClientArea();
         headerMouseClick = clientArea.y <= pt.y && pt.y < (clientArea.y + xViewer.getTree().getHeaderHeight());
   });
}
 
Example #16
Source Project: translationstudio8   Author: heartsome   File: ApplicationActionBarAdvisor.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void fillMenuBar(IMenuManager menuBar) {
	MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE);
	menuBar.add(fileMenu);
	fileMenu.add(exitAction);

	MenuManager editMenu = new MenuManager("&Edit", IWorkbenchActionConstants.M_EDIT);
	menuBar.add(editMenu);
	editMenu.add(preferenceAction);
}
 
Example #17
Source Project: elexis-3-core   Author: elexis   File: CodeSelectorFactory.java    License: Eclipse Public License 1.0 5 votes vote down vote up
protected void addMenuContribution(IConfigurationElement commandElement, IMenuManager manager,
	Object[] selection){
	ContributionAction action = new ContributionAction(commandElement);
	if (action.isValid()) {
		action.setSelection(selection);
		manager.add(action);
	}
}
 
Example #18
Source Project: elexis-3-core   Author: elexis   File: DiagnosenDisplay.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private Menu createDgMenu(){
	MenuManager contextMenuManager = new MenuManager();
	contextMenuManager.setRemoveAllWhenShown(true);
	contextMenuManager.addMenuListener(new IMenuListener() {
		public void menuAboutToShow(IMenuManager manager){
			IStructuredSelection selection = viewer.getStructuredSelection();
			if (!selection.isEmpty()) {
				manager.add(new Action() {
					
					public ImageDescriptor getImageDescriptor(){
						return Images.IMG_DELETE.getImageDescriptor();
					};
					
					public String getText(){
						return Messages.DiagnosenDisplay_RemoveDiagnoses;
					};
					
					public void run(){
						for (Object object : selection.toList()) {
							if (object instanceof IDiagnosis) {
								actEncounter.removeDiagnosis((IDiagnosis) object);
								CoreModelServiceHolder.get().save(actEncounter);
							}
						}
						setEncounter(actEncounter);
					};
				});
			}
		}
	});
	return contextMenuManager.createContextMenu(table);
}
 
Example #19
Source Project: neoscada   Author: eclipse   File: ProfileActionBarContributor.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This inserts global actions before the "additions-end" separator.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
protected void addGlobalActions ( IMenuManager menuManager )
{
    menuManager.insertAfter ( "additions-end", new Separator ( "ui-actions" ) ); //$NON-NLS-1$ //$NON-NLS-2$
    menuManager.insertAfter ( "ui-actions", showPropertiesViewAction ); //$NON-NLS-1$

    refreshViewerAction.setEnabled ( refreshViewerAction.isEnabled () );
    menuManager.insertAfter ( "ui-actions", refreshViewerAction ); //$NON-NLS-1$

    super.addGlobalActions ( menuManager );
}
 
Example #20
Source Project: depan   Author: google   File: FilterTableEditorControl.java    License: Apache License 2.0 5 votes vote down vote up
private void addElementMenuActions(
    Collection<ContextualFilterContributor<? extends ContextualFilter>> filters,
    IMenuManager mgr) {
  for (ContextualFilterContributor<? extends ContextualFilter>
      filter : filters) {
    Action action = new ElementAction(filter.getLabel(), filter);
    mgr.add(action);
  }
}
 
Example #21
Source Project: eip-designer   Author: lbroudoux   File: EipActionBarContributor.java    License: Apache License 2.0 5 votes vote down vote up
/**
   * This inserts global actions before the "additions-end" separator.
   * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
   * @generated
   */
@Override
protected void addGlobalActions(IMenuManager menuManager) {
     menuManager.insertAfter("additions-end", new Separator("ui-actions"));
     menuManager.insertAfter("ui-actions", showPropertiesViewAction);

     refreshViewerAction.setEnabled(refreshViewerAction.isEnabled());		
     menuManager.insertAfter("ui-actions", refreshViewerAction);

     super.addGlobalActions(menuManager);
  }
 
Example #22
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: GenerateActionGroup.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private int addEditorAction(IMenuManager menu, String actionID) {
	if (fEditor == null)
		return 0;
	IAction action= fEditor.getAction(actionID);
	if (action == null)
		return 0;
	if (action instanceof IUpdate)
		((IUpdate)action).update();
	if (action.isEnabled()) {
		menu.add(action);
		return 1;
	}
	return 0;
}
 
Example #23
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: CCPActionGroup.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fillContextMenu(IMenuManager menu) {
	super.fillContextMenu(menu);
	for (int i= 0; i < fActions.length; i++) {
		SelectionDispatchAction action= fActions[i];
		if (action == fCutAction && !fCutAction.isEnabled())
			continue;
		menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, action);
	}
}
 
Example #24
Source Project: CodeCheckerEclipsePlugin   Author: Ericsson   File: ReportListView.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void fillContextMenu(IMenuManager manager) {
    //manager.add(new RerunSelectedAction(this));
    manager.add(new NewInstanceAction(new ReportListViewCustom()));
    manager.add(new Separator());
    // Other plug-ins can contribute there actions here
    manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
}
 
Example #25
Source Project: Eclipse-Postfix-Code-Completion   Author: trylimits   File: DialogPackageExplorer.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Populate the context menu with the necessary actions.
 *
 * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
 */
public void menuAboutToShow(IMenuManager manager) {
    if (fActionGroup == null) // no context menu
        return;
    JavaPlugin.createStandardGroups(manager);
    fActionGroup.fillContextMenu(manager);
}
 
Example #26
Source Project: birt   Author: eclipse   File: SchematicContextMenuProvider.java    License: Eclipse Public License 1.0 5 votes vote down vote up
private void updateDynamicItems( String actionId, IMenuManager menu )
{
	IAction action = getAction( actionId );
	if ( action != null && action instanceof MenuUpdateAction )
	{
		( (MenuUpdateAction) action ).updateMenu( (MenuManager) menu );
	}
}
 
Example #27
Source Project: n4js   Author: eclipse   File: N4JSNewWizardsActionGroup.java    License: Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fillContextMenu(final IMenuManager menu) {
	super.fillContextMenu(menu);

	final ISelection selection = getContext().getSelection();
	if (selection instanceof IStructuredSelection) {
		if (canEnable((IStructuredSelection) selection)) {
			final MenuManager newMenu = new MenuManager("Ne&w");
			menu.appendToGroup(IContextMenuConstants.GROUP_NEW, newMenu);
			newMenu.add(getNewWizardMenu());
		}
	}

}
 
Example #28
Source Project: typescript.java   Author: angelozerr   File: TypeScriptEditorActionContributor.java    License: 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 #29
private void fillQuickMenu(IMenuManager manager, List<IAction> activeActions) {
	if (activeActions.isEmpty()) {
		manager.add(NO_ACTION_AVAILABLE);
	} else {
		for (int i= 0; i < activeActions.size(); i++) {
			manager.add(activeActions.get(i));
		}
	}
}
 
Example #30
Source Project: tracecompass   Author: tracecompass   File: ControlFlowView.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * @since 2.0
 */
@Override
protected void fillTimeGraphEntryContextMenu(@NonNull IMenuManager menuManager) {
    ISelection selection = getSite().getSelectionProvider().getSelection();
    if (selection instanceof StructuredSelection) {
        StructuredSelection sSel = (StructuredSelection) selection;
        if (sSel.getFirstElement() instanceof TimeGraphEntry) {
            TimeGraphEntry entry = (TimeGraphEntry) sSel.getFirstElement();
            ITmfTreeDataModel entryModel = entry.getEntryModel();
            if (entryModel instanceof ThreadEntryModel) {
                menuManager.add(new FollowThreadAction(ControlFlowView.this, entry.getName(), ((ThreadEntryModel) entryModel).getThreadId(), getTrace(entry)));
            }
        }
    }
}