org.eclipse.ui.menus.IMenuService Java Examples

The following examples show how to use org.eclipse.ui.menus.IMenuService. 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: DefaultNavigatorActionProvider.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * The default behavior is to show the same content as clicking the dropdown arrow. Subclass could override.
 * 
 * @param parent
 *            the parent toolbar
 */
protected void run(ToolBar parent)
{
	if (!isEnabled())
	{
		return;
	}
	Point toolbarLocation = parent.getLocation();
	toolbarLocation = parent.getParent().toDisplay(toolbarLocation.x, toolbarLocation.y);
	Point toolbarSize = parent.getSize();
	MenuManager menuManager = new MenuManager(null, getMenuId());
	IMenuService menuService = (IMenuService) partSite.getService(IMenuService.class);
	menuService.populateContributionManager(menuManager, MenuUtil.menuUri(menuManager.getId()));
	fillMenu(menuManager);
	Menu menu = menuManager.createContextMenu(parent);
	menu.setLocation(toolbarLocation.x, toolbarLocation.y + toolbarSize.y + 2);
	menu.setVisible(true);
}
 
Example #2
Source File: ApplicationActionBarAdvisor.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 创建自定义的插件菜单 2012-03-07
 * @return ;
 */
/*
 * private MenuManager createAutoPluginMenu() { MenuManager menu = new MenuManager("asdfasd",
 * "net.heartsome.cat.ts.ui.menu.plugin"); // menu = MenuManag
 * 
 * // menu.appendToGroup(groupName, item) menu.add(helpSearchAction); return menu; }
 */

@Override
public void dispose() {
	if (isDisposed) {
		return;
	}
	isDisposed = true;
	IMenuService menuService = (IMenuService) window.getService(IMenuService.class);
	menuService.releaseContributions(coolbarPopupMenuManager);
	coolbarPopupMenuManager.dispose();
	super.dispose();
}
 
Example #3
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 创建自定义的插件菜单 2012-03-07
 * @return ;
 */
/*
 * private MenuManager createAutoPluginMenu() { MenuManager menu = new MenuManager("asdfasd",
 * "net.heartsome.cat.ts.ui.menu.plugin"); // menu = MenuManag
 * 
 * // menu.appendToGroup(groupName, item) menu.add(helpSearchAction); return menu; }
 */

@Override
public void dispose() {
	if (isDisposed) {
		return;
	}
	isDisposed = true;
	IMenuService menuService = (IMenuService) window.getService(IMenuService.class);
	menuService.releaseContributions(coolbarPopupMenuManager);
	coolbarPopupMenuManager.dispose();
	super.dispose();
}
 
Example #4
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 创建自定义的插件菜单 2012-03-07
 * @return ;
 */
/*
 * private MenuManager createAutoPluginMenu() { MenuManager menu = new MenuManager("asdfasd",
 * "net.heartsome.cat.ts.ui.menu.plugin"); // menu = MenuManag
 * 
 * // menu.appendToGroup(groupName, item) menu.add(helpSearchAction); return menu; }
 */

@Override
public void dispose() {
	if (isDisposed) {
		return;
	}
	isDisposed = true;
	IMenuService menuService = (IMenuService) window.getService(IMenuService.class);
	menuService.releaseContributions(coolbarPopupMenuManager);
	coolbarPopupMenuManager.dispose();
	super.dispose();
}
 
Example #5
Source File: OpenDropDownMenuHandler.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ToolItem toolItem = findToolItem(event);
  String menuId = getMenuId(toolItem);
  IMenuService menuService = ServiceUtils.getService(event, IMenuService.class);
  openDropDownMenu(menuId, toolItem, menuService);
  return null;
}
 
Example #6
Source File: DesignerActionBarContributor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void contributeToMenu( IMenuManager menubar )
{
	super.contributeToMenu( menubar );
	updateEditMenu( menubar );
	// Insert Menu
	MenuManager insertMenu = new MenuManager( Messages.getString( "DesignerActionBarContributor.menu.insert" ), M_INSERT ); //$NON-NLS-1$
	createInsertMenu( insertMenu );

	insertMenu.addMenuListener( new IMenuListener( ) {

		public void menuAboutToShow( IMenuManager manager )
		{
			manager.removeAll( );
			insertElementActions = null;
			createInsertMenu( manager );
		}
	} );

	// insertMenu.add( getAction( ImportLibraryAction.ID ) );
	menubar.insertAfter( IWorkbenchActionConstants.M_EDIT, insertMenu );

	// Element Menu
	MenuManager elementMenu = new MenuManager( Messages.getString( "DesignerActionBarContributor.menu.element" ), M_ELEMENT ); //$NON-NLS-1$
	contributeElementMenu( elementMenu );
	menubar.insertAfter( M_INSERT, elementMenu );

	// Data Menu
	MenuManager dataMenu = new MenuManager( Messages.getString( "DesignerActionBarContributor.menu.data" ), M_DATA ); //$NON-NLS-1$

	// the data actions are now registered through eclipse menu extensions
	IMenuService menuService = (IMenuService) PlatformUI.getWorkbench( )
			.getService( IMenuService.class );
	menuService.populateContributionManager( dataMenu, "menu:birtData" ); //$NON-NLS-1$
	menubar.insertAfter( M_ELEMENT, dataMenu );

	menubar.update( );
}
 
Example #7
Source File: WorkbenchUtils.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
public static void refreshMainMenu() {
  	IWorkbenchWindow w = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
WorkbenchWindow ww = (WorkbenchWindow)w;
  	IMenuService service = (IMenuService)w.getService(IMenuService.class);
  	service.populateContributionManager((ContributionManager)ww.getActionBars().getMenuManager(), MenuUtil.MAIN_MENU);
  }
 
Example #8
Source File: ApplicationActionBarAdvisor.java    From translationstudio8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {

	// Set up the context Menu
	coolbarPopupMenuManager = new MenuManager();
	coolbarPopupMenuManager.add(new ActionContributionItem(lockToolBarAction));
	coolBar.setContextMenuManager(coolbarPopupMenuManager);
	IMenuService menuService = (IMenuService) window.getService(IMenuService.class);
	menuService.populateContributionManager(coolbarPopupMenuManager, "popup:windowCoolbarContextMenu");

	coolBar.add(new GroupMarker("group.file"));

	// File Group
	// IToolBarManager fileToolBar = new ToolBarManager(coolBar.getStyle());
	// fileToolBar.add(new Separator(IWorkbenchActionConstants.NEW_GROUP));
	// fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.OPEN_EXT));
	// fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.SAVE_GROUP));
	// // 为了使工具栏和菜单中的图片大小不一样,重新创建新建 Action
	// newAction = ActionFactory.NEW_WIZARD_DROP_DOWN.create(window);
	// register(newAction);
	// ImageDescriptor newImage =
	// net.heartsome.cat.ts.ui.Activator.getImageDescriptor(ImageConstant.TOOL_NEW_PROJECT);
	// newAction.setImageDescriptor(newImage);
	// // 解决在 Windows 下图片显示错误的问题
	// newAction.setDisabledImageDescriptor(newImage);
	// newAction.setToolTipText(Messages.getString("ts.ApplicationActionBarAdvisor.newAction"));
	// fileToolBar.add(newAction);

	// saveAction = ActionFactory.SAVE.create(window);
	// register(saveAction);
	// saveAction.setImageDescriptor(net.heartsome.cat.ts.ui.Activator.getImageDescriptor(ImageConstant.TOOL_SAVE));
	// saveAction.setToolTipText("保存");
	// fileToolBar.add(saveAction);

	// undoAction = ActionFactory.UNDO.create(window);
	// register(undoAction);
	// undoAction.setImageDescriptor(net.heartsome.cat.ts.ui.Activator.getImageDescriptor(ImageConstant.TOOL_UNDO));
	// undoAction.setToolTipText("撤销");
	// fileToolBar.add(undoAction);
	//
	// redoAction = ActionFactory.REDO.create(window);
	// register(redoAction);
	// redoAction.setImageDescriptor(net.heartsome.cat.ts.ui.Activator.getImageDescriptor(ImageConstant.TOOL_REDO));
	// redoAction.setToolTipText("重做");
	// fileToolBar.add(redoAction);
	// fileToolBar.add(new GroupMarker(IWorkbenchActionConstants.SAVE_EXT));
	// fileToolBar.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
	// Add to the cool bar manager
	// coolBar.add(new ToolBarContributionItem(fileToolBar, IWorkbenchActionConstants.TOOLBAR_FILE));

	coolBar.add(new GroupMarker("group.new.menu"));

	coolBar.add(new GroupMarker("group.undoredo"));

	coolBar.add(new GroupMarker("group.copySource"));

	
	coolBar.add(new GroupMarker("group.search"));
	//createToolItem(coolBar);

	coolBar.add(new GroupMarker("group.findreplace"));
	
	coolBar.add(new GroupMarker("group.completeTranslation"));

	coolBar.add(new GroupMarker("group.approve"));

	coolBar.add(new GroupMarker("group.addTerm"));

	coolBar.add(new GroupMarker("group.preview"));

	coolBar.add(new GroupMarker("group.tagoperation"));

	coolBar.add(new GroupMarker("group.sourceoperation"));

	coolBar.add(new GroupMarker("group.deleteTrans"));

	coolBar.add(new GroupMarker("group.changeLayout"));

	coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

	coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR));

	coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_HELP));

	// Help group
	// IToolBarManager helpToolBar = new ToolBarManager(coolBar.getStyle());
	// helpToolBar.add(new Separator(IWorkbenchActionConstants.GROUP_HELP));
	// // 按照设计文档的要求,先注释 helpSearchAction
	// // helpToolBar.add(helpSearchAction);
	// // Add the group for applications to contribute
	// helpToolBar.add(new GroupMarker("tagoperation"));
	// helpToolBar.add(new GroupMarker("pretranslation"));
	//
	// // Add to the cool bar manager
	// coolBar.add(new ToolBarContributionItem(helpToolBar, IWorkbenchActionConstants.TOOLBAR_HELP));
	//coolBar.add(createToolItem(coolBar));
}
 
Example #9
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
@Override
	protected void fillCoolBar(ICoolBarManager coolBar) {
		// Set up the context Menu
		coolbarPopupMenuManager = new MenuManager();
		coolbarPopupMenuManager.add(new ActionContributionItem(lockToolBarAction));
		coolBar.setContextMenuManager(coolbarPopupMenuManager);
		IMenuService menuService = (IMenuService) window.getService(IMenuService.class);
		menuService.populateContributionManager(coolbarPopupMenuManager, "popup:windowCoolbarContextMenu");

		coolBar.add(new GroupMarker("group.file"));

		coolBar.add(new GroupMarker("group.search"));
		createToolItem(coolBar);

		coolBar.add(new GroupMarker("group.new.menu"));

		coolBar.add(new GroupMarker("group.undoredo"));
		
		coolBar.add(new GroupMarker("group.tu"));
		
		coolBar.add(new GroupMarker("group.tmxtool"));

		coolBar.add(new GroupMarker("group.tmxclear"));

		coolBar.add(new GroupMarker("group.copySource"));

		coolBar.add(new GroupMarker("group.completeTranslation"));

		coolBar.add(new GroupMarker("group.approve"));

		coolBar.add(new GroupMarker("group.addTerm"));

		coolBar.add(new GroupMarker("group.preview"));

		coolBar.add(new GroupMarker("group.tagoperation"));

		coolBar.add(new GroupMarker("group.sourceoperation"));

		coolBar.add(new GroupMarker("group.deleteTrans"));

		coolBar.add(new GroupMarker("group.changeLayout"));

		coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

		coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR));

		coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_HELP));
		//未提供 24 位图标,屏蔽工具栏。
//		IToolBarManager toolbar = new ToolBarManager(coolBar.getStyle());
//		coolBar.add(new ToolBarContributionItem(toolbar, "help"));
//		toolbar.add(helpAction);
	}
 
Example #10
Source File: ApplicationActionBarAdvisor.java    From tmxeditor8 with GNU General Public License v2.0 2 votes vote down vote up
@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
	// Set up the context Menu
	coolbarPopupMenuManager = new MenuManager();
	coolbarPopupMenuManager.add(new ActionContributionItem(lockToolBarAction));
	coolBar.setContextMenuManager(coolbarPopupMenuManager);
	IMenuService menuService = (IMenuService) window.getService(IMenuService.class);
	menuService.populateContributionManager(coolbarPopupMenuManager, "popup:windowCoolbarContextMenu");

	coolBar.add(new GroupMarker("group.file"));

	coolBar.add(new GroupMarker("group.new.menu"));

	coolBar.add(new GroupMarker("group.undoredo"));

	coolBar.add(new GroupMarker("group.copySource"));

	coolBar.add(new GroupMarker("group.search"));
	createToolItem(coolBar);

	coolBar.add(new GroupMarker("group.completeTranslation"));

	coolBar.add(new GroupMarker("group.approve"));

	coolBar.add(new GroupMarker("group.addTerm"));

	coolBar.add(new GroupMarker("group.preview"));

	coolBar.add(new GroupMarker("group.tagoperation"));

	coolBar.add(new GroupMarker("group.sourceoperation"));

	coolBar.add(new GroupMarker("group.deleteTrans"));

	coolBar.add(new GroupMarker("group.changeLayout"));

	coolBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));

	coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_EDITOR));

	coolBar.add(new GroupMarker(IWorkbenchActionConstants.GROUP_HELP));

}