Java Code Examples for org.eclipse.jface.action.MenuManager#update()

The following examples show how to use org.eclipse.jface.action.MenuManager#update() . 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: MendeleyOverlayDecorator.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * THis method sets the main menu contribution 'Mendeley' to visible
 */
private void updateMenuContribution() {
	if(window instanceof WorkbenchWindow) {
		MenuManager menuManager = ((WorkbenchWindow)window).getMenuManager();
	    
	    //you'll need to find the id for the item
	    String mainMenuId = "de.tudresden.slr.model.mendeley.menus.mainMenu";
	    IContributionItem item = menuManager.find(mainMenuId);
	    item.update();
	    if (item != null) {
	        // clean old one
	        item.setVisible(true);

	        // refresh menu gui
	        menuManager.update();
	    }
	}
}
 
Example 2
Source File: PluginConfigManage.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void addPluginMenu(final PluginConfigBean bean) {
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始添加新的菜单
			Action action = new Action() {
				@Override
				public void run() {
					executePlugin(bean);
				}
			};
			action.setText(bean.getName());
			action.setId(bean.getId());
			if (!"".equals(bean.getShortcutKey())) {
				action.setText(bean.getName() + "\t" + bean.getShortcutKey());
			}

			pluginMenu.add(action);
			pluginMenu.update();
		}
	}
}
 
Example 3
Source File: PluginConfigManage.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 删除配置插件的菜单
 * @param idList
 *            ;
 */
public void deletePluginMenu(String deleteId) {
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始删除已经添加的菜单
			for (int j = 0; j < pluginMenu.getItems().length; j++) {
				String actionId = pluginMenu.getItems()[j].getId();
				if (deleteId.equals(actionId)) {
					pluginMenu.remove(actionId);
				}
			}
			pluginMenu.update();
		}
	}
}
 
Example 4
Source File: PluginConfigManage.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public void updataPluginMenu(PluginConfigBean bean) {
	String id = bean.getId();
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始删除已经添加的菜单
			for (int j = 0; j < pluginMenu.getItems().length; j++) {
				String actionId = pluginMenu.getItems()[j].getId();
				if (id.equals(actionId)) {
					pluginMenu.remove(id);
					pluginMenu.update();
					addPluginMenu(bean);
				}
			}
		}
	}
}
 
Example 5
Source File: PluginConfigManage.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public void addPluginMenu(final PluginConfigBean bean) {
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始添加新的菜单
			Action action = new Action() {
				@Override
				public void run() {
					executePlugin(bean);
				}
			};
			action.setText(bean.getName());
			action.setId(bean.getId());
			if (!"".equals(bean.getShortcutKey())) {
				action.setText(bean.getName() + "\t" + bean.getShortcutKey());
			}

			pluginMenu.add(action);
			pluginMenu.update();
		}
	}
}
 
Example 6
Source File: PluginConfigManage.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 删除配置插件的菜单
 * @param idList
 *            ;
 */
public void deletePluginMenu(String deleteId) {
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始删除已经添加的菜单
			for (int j = 0; j < pluginMenu.getItems().length; j++) {
				String actionId = pluginMenu.getItems()[j].getId();
				if (deleteId.equals(actionId)) {
					pluginMenu.remove(actionId);
				}
			}
			pluginMenu.update();
		}
	}
}
 
Example 7
Source File: PluginConfigManage.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public void updataPluginMenu(PluginConfigBean bean) {
	String id = bean.getId();
	for (int i = 0; i < parentManager.getItems().length; i++) {
		if ("net.heartsome.cat.ts.ui.menu.plugin".equals(parentManager.getItems()[i].getId())) {
			MenuManager pluginMenu = (MenuManager) parentManager.getItems()[i];
			// 开始删除已经添加的菜单
			for (int j = 0; j < pluginMenu.getItems().length; j++) {
				String actionId = pluginMenu.getItems()[j].getId();
				if (id.equals(actionId)) {
					pluginMenu.remove(id);
					pluginMenu.update();
					addPluginMenu(bean);
				}
			}
		}
	}
}
 
Example 8
Source File: N4JSApplicationActionBarAdvisor.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void fillActionBars(final int flags) {
	delegate.fillActionBars(flags);

	// To remove 'Build Working Set' contribution item from the main menu.
	final IMenuManager menuManager = configurer.getMenuManager();
	final MenuManager projectManager = getMenuManager(PROJECT_MENU_PREDICATE, menuManager);
	if (null != projectManager) {
		final MenuManager workingSetManager = getMenuManager(WORKING_SET_MENU_PREDICATE, projectManager);
		projectManager.remove(workingSetManager);
		projectManager.update(true);
	}
}