@Override public void fillContextMenu(IMenuManager menu) { IMenuManager subMenu = new MenuManager("New", NEW_MENU_NAME); if (!contribute) { return; } //Fill the menu from the commonWizard contributions newWizardActionGroup.setContext(getContext()); newWizardActionGroup.fillContextMenu(subMenu); subMenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS)); //Add other .. subMenu.add(new Separator()); subMenu.add(showDlgAction); //append the submenu after the GROUP_NEW group menu.insertAfter(ICommonMenuConstants.GROUP_NEW, subMenu); }
protected void contextMenuAboutToShow(IMenuManager mgr) { if (mgr.isEmpty()) { mgr.add(new GroupMarker(ICommonMenuConstants.GROUP_GOTO)); mgr.add(new Separator(ICommonMenuConstants.GROUP_EDIT)); mgr.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS)); mgr.add(new Separator(ICommonMenuConstants.GROUP_PROPERTIES)); mgr.appendToGroup(ICommonMenuConstants.GROUP_EDIT, actions.get(ACTION_COPY)); mgr.appendToGroup(ICommonMenuConstants.GROUP_EDIT, actions.get(ACTION_CUT)); mgr.appendToGroup(ICommonMenuConstants.GROUP_EDIT, actions.get(ACTION_PASTE)); mgr.appendToGroup(ICommonMenuConstants.GROUP_EDIT, actions.get(ACTION_DELETE)); } actionGroups.setContext(new ActionContext(getSite().getSelectionProvider().getSelection())); actionGroups.fillContextMenu(mgr); }
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 (!(resource instanceof IFile)) return; // Create a menu. IMenuManager submenu = new MenuManager( ActionMessages.OpenWithMenu_label); submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource)); // Add the submenu. menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, submenu); }
/** * Creates the Java plug-in's standard groups for view context menus. * * @param menu the menu manager to be populated */ public static void createStandardGroups(IMenuManager menu) { if (!menu.isEmpty()) return; menu.add(new Separator(IContextMenuConstants.GROUP_NEW)); menu.add(new GroupMarker(IContextMenuConstants.GROUP_GOTO)); menu.add(new Separator(IContextMenuConstants.GROUP_OPEN)); menu.add(new GroupMarker(IContextMenuConstants.GROUP_SHOW)); menu.add(new Separator(ICommonMenuConstants.GROUP_EDIT)); menu.add(new Separator(IContextMenuConstants.GROUP_REORGANIZE)); menu.add(new Separator(IContextMenuConstants.GROUP_GENERATE)); menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH)); menu.add(new Separator(IContextMenuConstants.GROUP_BUILD)); menu.add(new Separator(IContextMenuConstants.GROUP_ADDITIONS)); menu.add(new Separator(IContextMenuConstants.GROUP_VIEWER_SETUP)); menu.add(new Separator(IContextMenuConstants.GROUP_PROPERTIES)); }
protected void fillCallHierarchyViewerContextMenu(IMenuManager menu) { JavaPlugin.createStandardGroups(menu); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, fRefreshSingleElementAction); menu.appendToGroup(IContextMenuConstants.GROUP_SHOW, new Separator(GROUP_FOCUS)); if (fFocusOnSelectionAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fFocusOnSelectionAction); } if (fExpandWithConstructorsAction.canActionBeAdded()) { menu.appendToGroup(GROUP_FOCUS, fExpandWithConstructorsAction); } if (fRemoveFromViewAction.canActionBeAdded()){ menu.appendToGroup(GROUP_FOCUS, fRemoveFromViewAction); } fActionGroups.setContext(new ActionContext(getSelection())); fActionGroups.fillContextMenu(menu); fActionGroups.setContext(null); if (fCopyAction.canActionBeAdded()) { menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, fCopyAction); } }
private void addImportMenu(IMenuManager aMenu) { importWizardActionGroup.setContext(getContext()); if (importWizardActionGroup.getWizardActionIds().length == 0) { aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, importAction); return; } IMenuManager submenu = new MenuManager( WorkbenchNavigatorMessages.PortingActionProvider_ImportResourcesMenu_label, COMMON_NAVIGATOR_IMPORT_MENU); importWizardActionGroup.fillContextMenu(submenu); submenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS)); submenu.add(new Separator()); submenu.add(importAction); aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, submenu); }
private void addExportMenu(IMenuManager aMenu) { exportWizardActionGroup.setContext(getContext()); if (exportWizardActionGroup.getWizardActionIds().length == 0) { aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, exportAction); return; } IMenuManager submenu = new MenuManager( WorkbenchNavigatorMessages.PortingActionProvider_ExportResourcesMenu_label, COMMON_NAVIGATOR_EXPORT_MENU); exportWizardActionGroup.fillContextMenu(submenu); submenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS)); submenu.add(new Separator()); submenu.add(exportAction); aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, submenu); }
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); } }
@Override public void fillContextMenu(IMenuManager menu) { if (openResourceAction.isEnabledForSelectionWithoutContainers()) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, openResourceAction); } if (openPythonAction.isEnabledForSelectionWithoutContainers()) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, openPythonAction); } if (openExternalAction.isEnabledForSelectionWithoutContainers()) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, openExternalAction); } if (copyResourceAction.isEnabled()) { menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, copyResourceAction); } if (pasteAction.isEnabled()) { menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, pasteAction); } if (deleteResourceAction.isEnabled()) { menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, deleteResourceAction); } if (moveResourceAction.isEnabled()) { menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, moveResourceAction); } }
@Override public void fillContextMenu(IMenuManager menu) { IProject project = getBundleProjectFromSelection(); if(project == null) return; if(ResourcesPlugin.getWorkspace().isAutoBuilding()) { // This action is not otherwise shown if project is auto-building, so add it. IStructuredSelection structuredSel = getStructuredSelection(); if(structuredSel != null) { buildAction.selectionChanged(structuredSel); } menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction); } }
@SuppressWarnings("rawtypes") @Override public void fillContextMenu(IMenuManager menu) { IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); boolean hasClosedProjects = false; Iterator resources = selection.iterator(); while (resources.hasNext() && (!hasClosedProjects)) { Object next = resources.next(); IProject project = null; if (next instanceof IProject) { project = (IProject) next; } else if (next instanceof IAdaptable) { project = (IProject) ((IAdaptable) next).getAdapter(IProject.class); } if (project == null) { continue; } if (!project.isOpen()) { hasClosedProjects = true; } } if (!hasClosedProjects) { refreshAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, refreshAction); } }
private void createToolBar() { IToolBarManager mgr = getSite().getActionBars().getToolBarManager(); mgr.removeAll(); mgr.add(new Separator(ICommonMenuConstants.GROUP_SHOW)); mgr.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS)); mgr.add(new Separator(ICommonMenuConstants.GROUP_VIEWER_SETUP)); mgr.appendToGroup(ICommonMenuConstants.GROUP_SHOW, actions.get(ACTION_TOGGLE)); mgr.appendToGroup(ICommonMenuConstants.GROUP_VIEWER_SETUP, actions.get(ACTION_EXPAND)); mgr.appendToGroup(ICommonMenuConstants.GROUP_VIEWER_SETUP, actions.get(ACTION_COLLAPSE)); mgr.update(false); }
@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); // if (fShowShowInMenu) { // MenuManager showInSubMenu = new MenuManager(getShowInMenuLabel()); // IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); // showInSubMenu.add(ContributionItemFactory.VIEWS_SHOW_IN.create(workbenchWindow)); // menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, showInSubMenu); // } IStructuredSelection selection = getStructuredSelection(); if (fShowOpenPropertiesAction && selection != null && fOpenPropertiesDialog.isApplicableForSelection()) menu.appendToGroup(ICommonMenuConstants.GROUP_PROPERTIES, fOpenPropertiesDialog); }
@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (selection != null && !selection.isEmpty()) { menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, copyQualifiedNameAction); } }
@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(ActivitiProjectNature.NATURE_ID)) return; } catch (CoreException e) { e.printStackTrace(); } menu.appendToGroup(ICommonMenuConstants.GROUP_ADDITIONS, getAction(eclass)); } } }
@Override public void fillContextMenu(final IMenuManager aMenu) { if (!contribute || getContext().getSelection().isEmpty()) { return; } final IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); openFileAction.selectionChanged(selection); if (openFileAction.isEnabled()) { aMenu.insertAfter(ICommonMenuConstants.GROUP_OPEN, openFileAction); } addOpenWithMenu(aMenu); }
private void addOpenWithMenu(final IMenuManager aMenu) { final IStructuredSelection ss = (IStructuredSelection) getContext().getSelection(); if (ss == null || ss.size() != 1) { return; } final Object o = ss.getFirstElement(); // first try IResource IAdaptable openable = (IAdaptable) AdaptabilityUtility.getAdapter(o, IResource.class); // otherwise try ResourceMapping if (openable == null) { openable = (IAdaptable) AdaptabilityUtility.getAdapter(o, ResourceMapping.class); } else if (((IResource) openable).getType() != IResource.FILE) { openable = null; } if (openable != null) { // Create a menu flyout. final IMenuManager submenu = new MenuManager(WorkbenchNavigatorMessages.OpenActionProvider_OpenWithMenu_label, ICommonMenuConstants.GROUP_OPEN_WITH); submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_TOP)); submenu.add(new OpenWithMenu(viewSite.getPage(), openable)); submenu.add(new GroupMarker(ICommonMenuConstants.GROUP_ADDITIONS)); // Add the submenu. if (submenu.getItems().length > 2 && submenu.isEnabled()) { aMenu.appendToGroup(ICommonMenuConstants.GROUP_OPEN_WITH, submenu); } } }
@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); } }
public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if (propertiesAction.isApplicableForSelection()) { menu.appendToGroup(ICommonMenuConstants.GROUP_PROPERTIES, propertiesAction); } }
public void fillContextMenu(IMenuManager aMenu) { if (!contribute || getContext().getSelection().isEmpty()) { return; } IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); openFileAction.selectionChanged(selection); if (openFileAction.isEnabled()) { aMenu.insertAfter(ICommonMenuConstants.GROUP_OPEN, openFileAction); } // addOpenWithMenu(aMenu); }
@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")); }
@Override public void fillContextMenu(IMenuManager menu) { IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); IMenuManager submenu = new MenuManager("New", NEW_MENU_NAME); // fill the menu from the commonWizard contributions newWizardActionGroup.setContext(getContext()); newWizardActionGroup.fillContextMenu(submenu); submenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS)); menu.appendToGroup(ICommonMenuConstants.GROUP_NEW, submenu); if (selection.isEmpty()) { return; } if (ResourceSelectionUtil.allResourcesAreOfType(selection, IResource.PROJECT)) { projectDeleteAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, projectDeleteAction); } else if (allScenarioElementsAreRemovable(selection)) { elementDeleteAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, elementDeleteAction); } // add the 'Properties' entry to the popup menu propertyDialogAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_PROPERTIES, propertyDialogAction); }
public void editorContextMenuAboutToShow(IMenuManager ctxMenu) { ctxMenu.prependToGroup(ICommonMenuConstants.GROUP_OPEN, new CommandContributionItem( createCommandContrib_OpenDefinitionContrib())); ctxMenu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, new CommandContributionItem( createCommandContrib_QuickOutline())); prepareSourceMenu(ctxMenu); }
@Override public void fillContextMenu(IMenuManager menu) { super.fillContextMenu(menu); if(navigatorOpenAction.isEnabled()) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, navigatorOpenAction); } }
@Override public void fillContextMenu(IMenuManager menu) { if (openAction.isEnabled()) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, openAction); } }
@SuppressWarnings("unused") private void appendToGroup(IMenuManager menu, IAction action) { if (action.isEnabled()) menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, action); }
@Override public void fillContextMenu(IMenuManager menu) { /* * Actions on multiple selections */ menu.appendToGroup(ICommonMenuConstants.GROUP_EDIT, new DFSAction( DFSActions.DELETE)); menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, new DFSAction( DFSActions.REFRESH)); menu.appendToGroup(ICommonMenuConstants.GROUP_NEW, new DFSAction( DFSActions.DOWNLOAD)); if (site == null) return; ISelection isel = site.getStructuredViewer().getSelection(); if (!(isel instanceof IStructuredSelection)) return; /* * Actions on single selections only */ IStructuredSelection issel = (IStructuredSelection) isel; if (issel.size() != 1) return; Object element = issel.getFirstElement(); if (element instanceof DFSFile) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, new DFSAction( DFSActions.OPEN)); } else if (element instanceof DFSFolder) { menu.appendToGroup(ICommonMenuConstants.GROUP_NEW, new DFSAction( DFSActions.MKDIR)); menu.appendToGroup(ICommonMenuConstants.GROUP_NEW, new DFSAction( DFSActions.UPLOAD_FILES)); menu.appendToGroup(ICommonMenuConstants.GROUP_NEW, new DFSAction( DFSActions.UPLOAD_DIR)); } else if (element instanceof DFSLocation) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, new DFSAction( DFSActions.RECONNECT)); } else if (element instanceof DFSLocationsRoot) { menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, new DFSAction( DFSActions.DISCONNECT)); } }
private void appendToGroup(IMenuManager menu, IAction action) { if (action.isEnabled()) menu.appendToGroup(ICommonMenuConstants.GROUP_OPEN, action); }
/** * Adds the build, open project, close project and refresh resource actions * to the context menu. * <p> * The following conditions apply: build-only projects selected, auto build * disabled, at least one builder present open project-only projects * selected, at least one closed project close project-only projects * selected, at least one open project refresh-no closed project selected * </p> * <p> * Both the open project and close project action may be on the menu at the * same time. * </p> * <p> * No disabled action should be on the context menu. * </p> * * @param menu * context menu to add actions to */ public void fillContextMenu(IMenuManager menu) { IStructuredSelection selection = (IStructuredSelection) getContext().getSelection(); boolean isProjectSelection = true; boolean hasOpenProjects = false; boolean hasClosedProjects = false; boolean hasBuilder = true; // false if any project is closed or does not // have builder Iterator resources = selection.iterator(); while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) { Object next = resources.next(); IProject project = null; if (next instanceof IProject) { project = (IProject) next; } else if (next instanceof IAdaptable) { project = (IProject) ((IAdaptable) next).getAdapter(IProject.class); } if (project == null) { isProjectSelection = false; continue; } if (project.isOpen()) { hasOpenProjects = true; if (hasBuilder && !hasBuilder(project)) { hasBuilder = false; } } else { hasClosedProjects = true; hasBuilder = false; } } if (!selection.isEmpty() && isProjectSelection && !ResourcesPlugin.getWorkspace().isAutoBuilding() && hasBuilder) { // Allow manual incremental build only if auto build is off. buildAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, buildAction); } if (!hasClosedProjects) { refreshAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, refreshAction); } if (isProjectSelection) { if (hasClosedProjects) { openProjectAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, openProjectAction); } if (hasOpenProjects) { closeProjectAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeProjectAction); closeUnrelatedProjectsAction.selectionChanged(selection); menu.appendToGroup(ICommonMenuConstants.GROUP_BUILD, closeUnrelatedProjectsAction); } } }
private void addSimplePortingMenus(IMenuManager aMenu) { aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, importAction); aMenu.appendToGroup(ICommonMenuConstants.GROUP_PORT, exportAction); }