Java 类org.eclipse.ui.actions.OpenWithMenu 实例源码
项目:typescript.java
文件:OpenEditorActionGroup.java
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);
}
项目:jsbuild-eclipse
文件:OpenEditorActionGroup.java
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);
}
项目:gwt-eclipse-plugin
文件:GWTOpenEditorActionGroup.java
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);
}
项目:Eclipse-Postfix-Code-Completion
文件:OpenEditorActionGroup.java
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);
}
项目:Eclipse-Postfix-Code-Completion-Juno38
文件:OpenEditorActionGroup.java
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);
}
项目:Pydev
文件:NewTextSearchActionGroup.java
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);
}
项目:Pydev
文件:NewTextSearchActionGroup.java
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);
}
项目:egradle
文件:OpenGradleResourceDialog.java
@Override
protected void fillContextMenu(IMenuManager menuManager) {
super.fillContextMenu(menuManager);
final IStructuredSelection selectedItems = getSelectedItems();
if (selectedItems.isEmpty()) {
return;
}
IWorkbenchPage activePage = getActivePage();
if (activePage == null) {
return;
}
menuManager.add(new Separator());
// Add 'Open' menu item
OpenFileAction openFileAction = new OpenFileAction(activePage) {
@Override
public void run() {
okPressed();
}
};
openFileAction.selectionChanged(selectedItems);
if (openFileAction.isEnabled()) {
menuManager.add(openFileAction);
IAdaptable selectedAdaptable = getSelectedAdaptable();
if (selectedAdaptable != null) {
// Add 'Open With' sub-menu
MenuManager subMenu = new MenuManager("Open with");
OpenWithMenu openWithMenu = new ResourceOpenWithMenu(activePage, selectedAdaptable);
subMenu.add(openWithMenu);
menuManager.add(subMenu);
}
}
}
项目:eclipse-extras
文件:OpenWithQuickMenu.java
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 );
}
项目:gama
文件:OpenActionProvider.java
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);
}
}
}
项目:OpenSPIFe
文件:EnsembleOpenResourceDialog.java
private void showOpenWithMenu(final Composite openComposite) {
IWorkbenchPage activePage = getActivePage();
if (activePage == null) {
return;
}
IAdaptable selectedAdaptable = getSelectedAdaptable();
if (selectedAdaptable == null) {
return;
}
OpenWithMenu openWithMenu = new OpenWithMenu(activePage, selectedAdaptable) {
/*
* (non-Javadoc)
* @see org.eclipse.ui.actions.OpenWithMenu#openEditor(org.eclipse.ui.IEditorDescriptor, boolean)
*/
@Override
protected void openEditor(IEditorDescriptor editorDescriptor, boolean openUsingDescriptor) {
computeResult();
setResult(Collections.EMPTY_LIST);
close();
super.openEditor(editorDescriptor, openUsingDescriptor);
}
};
Menu menu = new Menu(openComposite.getParent());
Control c = openComposite;
Point p = c.getLocation();
p.y = p.y + c.getSize().y;
p = c.getParent().toDisplay(p);
menu.setLocation(p);
openWithMenu.fill(menu, -1);
menu.setVisible(true);
}
项目:eclipse-extras
文件:OpenWithQuickMenu.java
private MenuCloseListener createMenuCloseListener( OpenWithMenu openWithMenu ) {
return new MenuCloseListener( workbenchPage.getWorkbenchWindow().getShell(), openWithMenu );
}
项目:eclipse-extras
文件:OpenWithQuickMenu.java
MenuCloseListener( Shell shell, OpenWithMenu openWithMenu ) {
this.shell = shell;
this.openWithMenu = openWithMenu;
}
项目:OpenSPIFe
文件:EnsembleOpenResourceDialog.java
@Override
protected void fillContextMenu(IMenuManager menuManager) {
super.fillContextMenu(menuManager);
IStructuredSelection selectedItems = getSelectedItems();
if (selectedItems.isEmpty()) {
return;
}
IWorkbenchPage activePage = getActivePage();
if (activePage == null) {
return;
}
// Add 'Open' menu item
OpenFileAction openFileAction = new OpenFileAction(activePage) {
@Override
public void run() {
okPressed();
}
};
openFileAction.selectionChanged(selectedItems);
if (!openFileAction.isEnabled()) {
return;
}
menuManager.add(new Separator());
menuManager.add(openFileAction);
IAdaptable selectedAdaptable = getSelectedAdaptable();
if (selectedAdaptable == null) {
return;
}
// Add 'Open With...' sub-menu
MenuManager subMenu = new MenuManager(IDEWorkbenchMessages.OpenResourceDialog_openWithMenu_label);
OpenWithMenu openWithMenu = new OpenWithMenu(activePage, selectedAdaptable) {
/*
* (non-Javadoc)
* @see org.eclipse.ui.actions.OpenWithMenu#openEditor(org.eclipse.ui.IEditorDescriptor, boolean)
*/
@Override
protected void openEditor(IEditorDescriptor editorDescriptor, boolean openUsingDescriptor) {
computeResult();
setResult(Collections.EMPTY_LIST);
close();
super.openEditor(editorDescriptor, openUsingDescriptor);
}
};
subMenu.add(openWithMenu);
menuManager.add(subMenu);
}