private void addOpenWithMenu(IMenuManager menu) { ISelection selection = getContext().getSelection(); if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) return; IStructuredSelection ss = (IStructuredSelection) selection; if (ss.size() != 1) return; Object o = ss.getFirstElement(); if (!(o instanceof IAdaptable)) return; IAdaptable element = (IAdaptable) o; Object resource = element.getAdapter(IResource.class); if (element instanceof IStorage && !(resource instanceof IFile)) { // Create a menu. IMenuManager submenu = new MenuManager(ActionMessages.OpenWithMenu_label); submenu.add(new OpenStorageWithMenu(fSite.getPage(), element)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); } else if ((element instanceof IModelElement) || (element.getAdapter(IModelElement.class) != null)) { // Create a menu. IMenuManager submenu = new MenuManager(ActionMessages.OpenWithMenu_label); submenu.add( new OpenModelElementWithMenu( fSite.getPage(), (IModelElement) element.getAdapter(IModelElement.class))); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); } else if ((resource instanceof IFile)) { // Create a menu. IMenuManager submenu = new MenuManager(ActionMessages.OpenWithMenu_label); submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); } }
public void buildContextMenu(IMenuManager manager) { super.buildContextMenu(manager); IAction action; action = actionRegistry.getAction(PromuoveSimpleToCompositeAction.ID); if (action.isEnabled()) manager.appendToGroup(GEFActionConstants.GROUP_REST, action); action = actionRegistry.getAction(PromuoveStateToDHSAction.ID); if (action.isEnabled()) manager.appendToGroup(GEFActionConstants.GROUP_REST, action); }
/* * @see IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void menuAboutToShow(IMenuManager menu) { menu.add(new Separator(IContextMenuConstants.GROUP_OPEN)); menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT)); menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS)); IAction action; action = getCopyToClipboardAction(); if (action != null) menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, action); action = getSelectAllAction(); if (action != null) menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, action); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fGotoInputAction); }
@Override public void buildContextMenu(IMenuManager menu) { GEFActionConstants.addStandardActionGroups(menu); // menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(EditAction.ID)); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.UNDO.getId())); menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId())); menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.DELETE.getId())); menu.appendToGroup(GEFActionConstants.GROUP_PRINT, getAction(ActionFactory.PRINT.getId())); menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.IMPORT.getId())); menu.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.EXPORT.getId())); }
/** * Called when the context menu is about to show. Actions, whose state is enabled, will appear in * the context menu. * * @see * org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager) */ public void buildContextMenu(IMenuManager menu) { // Add standard action groups to the menu GEFActionConstants.addStandardActionGroups(menu); // Add actions to the menu menu.appendToGroup( GEFActionConstants.GROUP_UNDO, // target group id getAction(ActionFactory.UNDO.getId())); // action to add menu.appendToGroup(GEFActionConstants.GROUP_UNDO, getAction(ActionFactory.REDO.getId())); // menu.appendToGroup( // GEFActionConstants.GROUP_EDIT, // getAction(ActionFactory.DELETE.getId())); }
protected void updatePeriodActions() { IActionBars actionBars = getViewSite().getActionBars(); IMenuManager menuManager = actionBars.getMenuManager(); if (periodActions != null) { for (int i = 0; i < periodActions.length; i++) { menuManager.remove(periodActions[i]); periodActions[i].dispose(); } periodActions = null; } createPeriodActions(); if (periodActions != null) { for (int i = 0; i < periodActions.length; i++) { menuManager.appendToGroup("periods", periodActions[i]); } } TimeSpan periodTimeSpan = TimeSpan.fromString(dialogSettings.get(K_PERIOD)); TimeSpan resolutionTimeSpan = TimeSpan.fromString(dialogSettings.get(K_RESOLUTION)); setPeriodActionSelection(periodTimeSpan, resolutionTimeSpan); actionBars.updateActionBars(); }
@Override public void fillContextMenu(IMenuManager menuManager) { ISearchResult result = getCurrentSearchResult(); if (result != null) { menuManager.appendToGroup(IContextMenuConstants.GROUP_SEARCH, fSearchAgainAction); } }
@Override public void fillContextMenu(IMenuManager aMenu) { IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); if (selection.size() != 1) { return; } Object object = selection.getFirstElement(); IFolder folder = Adapters.adapt(object, IFolder.class); if (folder == null) { return; } if (folder.getFile(IProjectDescription.DESCRIPTION_FILE_NAME).exists()) { for (IProject project : folder.getWorkspace().getRoot().getProjects()) { if (project.getLocation().equals(folder.getLocation())) { // project already in workspace SelectProjectForFolderAction action = new SelectProjectForFolderAction(project, this.viewer); aMenu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, action); return; } } OpenFolderAsProjectAction action = new OpenFolderAsProjectAction(folder, this.viewer); aMenu.prependToGroup(ICommonMenuConstants.GROUP_PORT, action); } }
private void addOpenNewWindowAction(IMenuManager menu, Object element) { if (element instanceof IJavaElement) { element = ((IJavaElement) element).getResource(); } if (!(element instanceof IContainer)) return; menu.appendToGroup( IContextMenuConstants.GROUP_OPEN, new PatchedOpenInNewWindowAction(getSite().getWorkbenchWindow(), (IContainer) element)); }
protected void addAction(IMenuManager menu, String group, String actionId) { IAction action = getAction(actionId); if (action != null) { if (action instanceof IUpdate) ((IUpdate) action).update(); IMenuManager subMenu = menu.findMenuUsingPath(group); if (subMenu != null) subMenu.add(action); else menu.appendToGroup(group, action); } }
public void fillActionBars(IActionBars actionBars) { // create new layout group IMenuManager manager = actionBars.getMenuManager(); final IContributionItem groupMarker = new GroupMarker("layout"); // $NON-NLS-1$ manager.add(groupMarker); IMenuManager newManager = new MenuManager(ScriptBrowsingMessages.PackagesView_LayoutActionGroup_layout_label); manager.appendToGroup("layout", newManager); // $NON-NLS-1$ super.addActions(newManager); }
/* (non-Javadoc) * Method declared in ActionGroup */ @Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (!fIsTypeHiararchyViewerOwner) appendToGroup(menu, fOpenTypeHierarchy); if (!fIsCallHiararchyViewerOwner) appendToGroup(menu, fOpenCallHierarchy); if (fShowShowInMenu) { MenuManager showInSubMenu = new MenuManager(getShowInMenuLabel()); IWorkbenchWindow workbenchWindow = fOpenSuperImplementation.getSite().getWorkbenchWindow(); showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(workbenchWindow)); menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, showInSubMenu); } IStructuredSelection selection = getStructuredSelection(); if (fShowOpenPropertiesAction && selection != null && fOpenPropertiesDialog.isApplicableForSelection()) menu.appendToGroup(IContextMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog); }
/** * Called when the menu is about to show. Construct the context menu by adding actions common to * all editparts. * * @see * org.eclipse.gef.ContextMenuProvider#buildContextMenu(org.eclipse.jface.action.IMenuManager) */ public void buildContextMenu(IMenuManager manager) { super.buildContextMenu(manager); // UseLayout if (checkAllElements(getViewer().getSelection(), UseLayoutEditPart.class)) { IAction action = getActionRegistry().getAction(DeleteLinkPageLayoutAction.ID); if (action.isEnabled()) { manager.appendToGroup(GEFActionConstants.GROUP_EDIT, action); } } }
@Override protected IMenuManager contributeToEditMenu(IMenuManager menuManager) { IMenuManager editMenu = super.contributeToEditMenu(menuManager); // Text Positions IMenuManager textPositionMenu = new MenuManager(Messages.CanvasEditorActionBarContributor_0); for (String id : TextPositionAction.ACTION_IDS) { textPositionMenu.add(getAction(id)); } editMenu.appendToGroup(GROUP_EDIT_MENU, textPositionMenu); // Border Color editMenu.appendToGroup(GROUP_EDIT_MENU, getAction(BorderColorAction.ID)); // Lock editMenu.insertAfter( ArchimateEditorActionFactory.RENAME.getId(), new Separator("lock")); // $NON-NLS-1$ editMenu.appendToGroup("lock", getAction(LockObjectAction.ID)); // $NON-NLS-1$ return editMenu; }
@Override public void createMenu(IMenuManager mgr) { int selectionType = SelectionUtil.getSelectionType(selection); if (selectionType == SelectionUtil.UNSUPPORTED) { return; } if (selectionType == SelectionUtil.PROJECT_WITH_NATURE) { OpenNewJobWizardAction openNewJobWizardAction = new OpenNewJobWizardAction(); mgr.appendToGroup(OPEN, openNewJobWizardAction); } }
/* * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(org.eclipse.jface.action.IMenuManager) */ @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$ } }
/* (non-Javadoc) * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) */ @Override public void fillContextMenu(final IMenuManager menu) { super.fillContextMenu(menu); ISelection selection = getContext().getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection sselection = (IStructuredSelection) selection; if (sselection.size() <= 1) { IMenuManager submenu = new MenuManager(Messages.getString("NewWizardActions.new_action_group")); // $NON-NLS-1$ menu.appendToGroup(IContextMenuConstants.GROUP_NEW, submenu); submenu.add(new NewWizardMenu(this.window)); } } }
/* * (non-Javadoc) * * @see org.eclipse.gef.ContextMenuProvider#menuAboutToShow(org.eclipse.jface.action.IMenuManager) */ public void buildContextMenu(IMenuManager manager) { GEFActionConstants.addStandardActionGroups(manager); IAction action; action = getActionRegistry().getAction(ActionFactory.UNDO.getId()); manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action); action = getActionRegistry().getAction(ActionFactory.REDO.getId()); manager.appendToGroup(GEFActionConstants.GROUP_UNDO, action); manager.appendToGroup(GEFActionConstants.GROUP_EDIT, getAction(ActionFactory.DELETE.getId())); manager.add(new Separator()); action = getActionRegistry().getAction(PropertyAction.COPY); if (action.isEnabled()) manager.appendToGroup(GEFActionConstants.GROUP_REST, action); manager.add(new Separator()); action = getActionRegistry().getAction(ActionFactory.SAVE.getId()); manager.appendToGroup(GEFActionConstants.GROUP_SAVE, action); }
/* (non-Javadoc) * Method declared on ActionGroup. */ public void fillContextMenu(IMenuManager manager) { MenuManager javaSearchMM = new MenuManager(MENU_TEXT, IContextMenuConstants.GROUP_SEARCH); addAction(fFindImplementorsAction, javaSearchMM); addAction(fFindImplementorsInProjectAction, javaSearchMM); javaSearchMM.add(new Separator()); Iterator iter = SearchUtil.getLRUWorkingSets().sortedIterator(); while (iter.hasNext()) { addWorkingSetAction((IWorkingSet[]) iter.next(), javaSearchMM); } addAction(fFindImplementorsInWorkingSetAction, javaSearchMM); if (!javaSearchMM.isEmpty()) manager.appendToGroup(fGroupId, javaSearchMM); }
/* * (non-Javadoc) Method declared in ActionGroup */ public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (!canOperateOnSelection()) return; String menuText = PHPUIMessages.IncludePathActionGroup_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); }
public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); String menuText = "Source"; // ActionMessages.SourceMenu_label; // if (fQuickAccessAction != null) { // menuText= fQuickAccessAction.addShortcut(menuText); // } IMenuManager subMenu = new MenuManager(menuText, MENU_ID); int added = 0; if (isEditorOwner()) { added = fillEditorSubMenu(subMenu); } else { added = fillViewSubMenu(subMenu); } if (added > 0) menu.appendToGroup(fGroupName, subMenu); }
@Override protected void fillContextMenu(IMenuManager mgr) { mgr.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); getSite().setSelectionProvider(getSearchSelectionProvider()); mgr.appendToGroup( IContextMenuConstants.GROUP_PROPERTIES, new Action("Open Search Preferences") { @Override public void run() { Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); PreferencesUtil.createPreferenceDialogOn( shell, "org.eclipse.search.preferences.SearchPreferencePage", null, null) .open(); } }); }
public void fillContextMenu(IMenuManager menu) { // Add the Create Tafj Package menu if the project has the // packager nature if (getContext() != null && getContext().getSelection() instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) getContext().getSelection(); if (structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof IProject) { IProject project = (IProject) structuredSelection.getFirstElement(); try { if (project.hasNature(TafjPackagerProjectNature.NATURE_ID)) { menu.appendToGroup(ICommonMenuConstants.GROUP_GENERATE, startPackagerAction); } } catch (CoreException e) { // Ignore } } } }
/* * (non-Javadoc) Method declared in ActionGroup */ @Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); String menuText = ActionMessages.SourceMenu_label; if (fQuickAccessAction != null) { // TODO port QuickAccessMenu from JSDT DartX.todo(); // menuText = fQuickAccessAction.addShortcut(menuText); } IMenuManager subMenu = new MenuManager(menuText, MENU_ID); int added = 0; if (isEditorOwner()) { added = fillEditorSubMenu(subMenu); } else { added = fillViewSubMenu(subMenu); } if (added > 0) { menu.appendToGroup(fGroupName, subMenu); } }
private void addOpenWithMenu(IStructuredSelection ss, IMenuManager menu) { if (ss.isEmpty()) return; if (ss.size() != 1) return; Object o = ss.getFirstElement(); if (!(o instanceof IEGLFile)) return; IEGLFile element = (IEGLFile) o; IResource resource = element.getResource(); if (!(resource instanceof IFile)) return; // Create a menu. IMenuManager submenu = new MenuManager( UINlsStrings.EGLOpenActionProvider_OpenWith, ICommonMenuConstants.GROUP_OPEN_WITH); submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP)); submenu.add(new OpenWithMenu(viewSite.getPage(), (IFile) resource)); submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_ADDITIONS)); // Add the submenu. menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN_WITH, submenu); }
@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); ISelection selection = getContext().getSelection(); if (selection.isEmpty()) return; if (selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; Object el = sel.getFirstElement(); if (el instanceof EClass) { EClass eclass = (EClass) el; String platformString = eclass.eResource().getURI().toPlatformString(true); Path path = new Path(platformString); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path); if (file == null) return; IProject project = file.getProject(); try { if (!project.hasNature(ExampleProjectNature.NATURE_ID)) return; } catch (CoreException e) { e.printStackTrace(); } menu.appendToGroup(ICommonMenuConstants.GROUP_ADDITIONS, getAction(eclass)); } } }
@Override public void fillContextMenu(IMenuManager menuManager) { menuManager.appendToGroup( ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(undoAction)); menuManager.appendToGroup( ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(redoAction)); menuManager.appendToGroup(ICommonMenuConstants.GROUP_EDIT, new Separator()); menuManager.appendToGroup( ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(cutAction)); menuManager.appendToGroup( ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(copyAction)); menuManager.appendToGroup( ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(pasteAction)); IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); boolean anyResourceSelected = !selection.isEmpty(); if (anyResourceSelected) { removeAction.selectionChanged(selection); menuManager.appendToGroup( ICommonMenuConstants.GROUP_EDIT, new ActionContributionItem(removeAction)); } }
public void fillContextMenu(IMenuManager menu) { if (menuAction.isEnabled()) menu.appendToGroup("group.new", menuAction); }
@Override protected void contributeToActionBars( final IServiceLocator serviceLocator, final IActionBars actionBars, final HandlerCollection handlers) { super.contributeToActionBars(serviceLocator, actionBars, handlers); final IMenuManager menuManager = actionBars.getMenuManager(); menuManager.appendToGroup( NICO_CONTROL_MENU_ID, new CommandContributionItem( new CommandContributionItemParameter( getSite(), null, NicoUI.PAUSE_COMMAND_ID, null, null, null, null, null, null, null, CommandContributionItem.STYLE_CHECK, null, false))); if (getConsole().getProcess().isProvidingFeatureSet(IRemoteEngineController.FEATURE_SET_ID)) { menuManager.appendToGroup( NICO_CONTROL_MENU_ID, new CommandContributionItem( new CommandContributionItemParameter( getSite(), null, NicoUI.DISCONNECT_COMMAND_ID, null, null, null, null, null, null, null, CommandContributionItem.STYLE_PUSH, null, false))); menuManager.appendToGroup( NICO_CONTROL_MENU_ID, new CommandContributionItem( new CommandContributionItemParameter( getSite(), null, NicoUI.RECONNECT_COMMAND_ID, null, null, null, null, null, null, null, CommandContributionItem.STYLE_PUSH, null, false))); } menuManager.insertBefore( SharedUIResources.ADDITIONS_MENU_ID, new Separator("workspace")); // $NON-NLS-1$ menuManager.appendToGroup( "workspace", //$NON-NLS-1$ new ChangeWorkingDirectoryWizard.ChangeAction(this)); menuManager.insertBefore( SharedUIResources.ADDITIONS_MENU_ID, new Separator("view")); // $NON-NLS-1$ menuManager.appendToGroup( "view", //$NON-NLS-1$ new AdjustWithAction()); final RProcess process = (RProcess) getConsole().getProcess(); if (process.isProvidingFeatureSet(RTool.R_DATA_FEATURESET_ID) && process.getAdapter(IREnvConfiguration.class) != null) { final MenuManager rEnv = new MenuManager("R environment"); menuManager.appendToGroup(NICO_CONTROL_MENU_ID, rEnv); rEnv.add( new HandlerContributionItem( new CommandContributionItemParameter( getSite(), null, HandlerContributionItem.NO_COMMAND_ID, null, null, null, null, "Index c&ompletely", null, null, CommandContributionItem.STYLE_PUSH, null, false), new REnvUpdateHandler(process, true))); rEnv.add( new HandlerContributionItem( new CommandContributionItemParameter( getSite(), null, HandlerContributionItem.NO_COMMAND_ID, null, null, null, null, "Index ch&anges", null, null, CommandContributionItem.STYLE_PUSH, null, false), new REnvUpdateHandler(process, false))); } }
@Override public void fillContextMenu(IMenuManager menu) { if (fWorkingSetAssignementAction.isEnabled()) menu.appendToGroup(IContextMenuConstants.GROUP_BUILD, fWorkingSetAssignementAction); }