本文整理汇总了Java中org.eclipse.ui.actions.OpenWithMenu类的典型用法代码示例。如果您正苦于以下问题:Java OpenWithMenu类的具体用法?Java OpenWithMenu怎么用?Java OpenWithMenu使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OpenWithMenu类属于org.eclipse.ui.actions包,在下文中一共展示了OpenWithMenu类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addOpenWithMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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);
}
示例2: addOpenWithMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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);
}
示例3: addOpenWithMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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);
}
示例4: addOpenWithMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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);
}
示例5: addOpenWithMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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);
}
示例6: addOpenWithMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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);
}
示例7: fillContextMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
@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);
}
}
}
示例8: show
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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 );
}
示例9: addOpenWithMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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);
}
}
}
示例10: showOpenWithMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
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);
}
示例11: createMenuCloseListener
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
private MenuCloseListener createMenuCloseListener( OpenWithMenu openWithMenu ) {
return new MenuCloseListener( workbenchPage.getWorkbenchWindow().getShell(), openWithMenu );
}
示例12: MenuCloseListener
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
MenuCloseListener( Shell shell, OpenWithMenu openWithMenu ) {
this.shell = shell;
this.openWithMenu = openWithMenu;
}
示例13: fillContextMenu
import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
@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);
}