org.eclipse.ui.actions.OpenWithMenu Java Examples
The following examples show how to use
org.eclipse.ui.actions.OpenWithMenu.
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: OpenEditorActionGroup.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
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("Open With"); submenu.add(new OpenWithMenu(fSite.getPage(), (IFile) resource)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); }
Example #2
Source File: OpenEditorActionGroup.java From typescript.java with MIT License | 6 votes |
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(IContextMenuConstants.GROUP_OPEN, submenu); }
Example #3
Source File: GWTOpenEditorActionGroup.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
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(); IFile file = AdapterUtilities.getAdapter(o, IFile.class); if (file == null) { return; } // Create a menu. IMenuManager submenu = new MenuManager(ActionMessages.OpenWithMenu_label); submenu.add(new OpenWithMenu(site.getPage(), file)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); }
Example #4
Source File: OpenEditorActionGroup.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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(IContextMenuConstants.GROUP_OPEN, submenu); }
Example #5
Source File: NewTextSearchActionGroup.java From Pydev with Eclipse Public License 1.0 | 6 votes |
private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) { if (selection == null) { return; } fOpenAction.selectionChanged(selection); if (fOpenAction.isEnabled()) { menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenAction); } if (selection.size() != 1) { return; } Object o = selection.getFirstElement(); if (!(o instanceof IAdaptable)) { return; } // Create menu IMenuManager submenu = new MenuManager("Open Wit&h"); submenu.add(new OpenWithMenu(fPage, (IAdaptable) o)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); }
Example #6
Source File: NewTextSearchActionGroup.java From Pydev with Eclipse Public License 1.0 | 6 votes |
private void addOpenWithMenu(IMenuManager menu, IStructuredSelection selection) { if (selection == null) { return; } fOpenAction.selectionChanged(selection); if (fOpenAction.isEnabled()) { menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, fOpenAction); } if (selection.size() != 1) { return; } Object o = selection.getFirstElement(); if (!(o instanceof IAdaptable)) { return; } // Create menu IMenuManager submenu = new MenuManager(SearchMessages.OpenWithMenu_label); submenu.add(new OpenWithMenu(fPage, (IAdaptable) o)); // Add the submenu. menu.appendToGroup(IContextMenuConstants.GROUP_OPEN, submenu); }
Example #7
Source File: TmfActionProvider.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public void fillContextMenu(IMenuManager menu) { ISelection selection = getContext().getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) selection; if (structuredSelection.size() == 1 && structuredSelection.getFirstElement() instanceof TmfTraceElement) { TmfTraceElement traceElement = (TmfTraceElement) structuredSelection.getFirstElement(); if (traceElement.getResource() instanceof IFile) { MenuManager openWithMenu = new MenuManager(Messages.TmfActionProvider_OpenWith); openWithMenu.add(new OpenWithMenu(page, traceElement.getResource())); menu.insertAfter(ICommonMenuConstants.GROUP_OPEN_WITH, openWithMenu); } } } }
Example #8
Source File: OpenWithQuickMenu.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
private void show( Control focusControl, Point location ) { Menu quickMenu = new Menu( focusControl.getShell() ); OpenWithMenu openWithMenu = new OpenWithMenu( workbenchPage, file ); openWithMenu.fill( quickMenu, 0 ); quickMenu.setLocation( location ); quickMenu.addListener( SWT.Hide, createMenuCloseListener( openWithMenu ) ); quickMenu.setVisible( true ); }
Example #9
Source File: OpenActionProvider.java From gama with GNU General Public License v3.0 | 5 votes |
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 = CloseResourceAction.getAdapter(o, IResource.class); // otherwise try ResourceMapping if (openable == null) { openable = CloseResourceAction.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); } } }
Example #10
Source File: OpenWithQuickMenu.java From eclipse-extras with Eclipse Public License 1.0 | 4 votes |
private MenuCloseListener createMenuCloseListener( OpenWithMenu openWithMenu ) { return new MenuCloseListener( workbenchPage.getWorkbenchWindow().getShell(), openWithMenu ); }
Example #11
Source File: OpenWithQuickMenu.java From eclipse-extras with Eclipse Public License 1.0 | 4 votes |
MenuCloseListener( Shell shell, OpenWithMenu openWithMenu ) { this.shell = shell; this.openWithMenu = openWithMenu; }