当前位置: 首页>>代码示例>>Java>>正文


Java OpenWithMenu类代码示例

本文整理汇总了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);
}
 
开发者ID:angelozerr,项目名称:typescript.java,代码行数:25,代码来源:OpenEditorActionGroup.java

示例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);
}
 
开发者ID:angelozerr,项目名称:jsbuild-eclipse,代码行数:26,代码来源:OpenEditorActionGroup.java

示例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);
}
 
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:24,代码来源:GWTOpenEditorActionGroup.java

示例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);
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:25,代码来源:OpenEditorActionGroup.java

示例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);
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:27,代码来源:NewTextSearchActionGroup.java

示例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);
}
 
开发者ID:fabioz,项目名称:Pydev,代码行数:27,代码来源:NewTextSearchActionGroup.java

示例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);
		}
	}

}
 
开发者ID:de-jcup,项目名称:egradle,代码行数:40,代码来源:OpenGradleResourceDialog.java

示例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 );
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:9,代码来源:OpenWithQuickMenu.java

示例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);
		}
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:28,代码来源:OpenActionProvider.java

示例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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:35,代码来源:EnsembleOpenResourceDialog.java

示例11: createMenuCloseListener

import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
private MenuCloseListener createMenuCloseListener( OpenWithMenu openWithMenu ) {
  return new MenuCloseListener( workbenchPage.getWorkbenchWindow().getShell(), openWithMenu );
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:4,代码来源:OpenWithQuickMenu.java

示例12: MenuCloseListener

import org.eclipse.ui.actions.OpenWithMenu; //导入依赖的package包/类
MenuCloseListener( Shell shell, OpenWithMenu openWithMenu ) {
  this.shell = shell;
  this.openWithMenu = openWithMenu;
}
 
开发者ID:rherrmann,项目名称:eclipse-extras,代码行数:5,代码来源:OpenWithQuickMenu.java

示例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);
}
 
开发者ID:nasa,项目名称:OpenSPIFe,代码行数:52,代码来源:EnsembleOpenResourceDialog.java


注:本文中的org.eclipse.ui.actions.OpenWithMenu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。