/** * 移除无用的菜单项:<br/> * File 菜单下的“open file...”和“Convert Line Delimiters To” */ private void removeUnusedAction() { ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry(); IActionSetDescriptor[] actionSets = reg.getActionSets(); List<String> actionSetIds = Arrays.asList("org.eclipse.ui.actionSet.openFiles", "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo", "org.eclipse.ui.actions.showKeyAssistHandler", "org.eclipse.ui.edit.text.actionSet.navigation", "org.eclipse.ui.edit.text.actionSet.annotationNavigation"); for (int i = 0; i < actionSets.length; i++) { if (actionSetIds.contains(actionSets[i].getId())) { IExtension ext = actionSets[i].getConfigurationElement().getDeclaringExtension(); reg.removeExtension(ext, new Object[] { actionSets[i] }); } } }
private void removeActionById(String actionSetId) { // Use of an internal API is required to remove actions that are provided // by including Eclipse bundles. ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry(); IActionSetDescriptor[] actionSets = reg.getActionSets(); for (int i = 0; i < actionSets.length; i++) { if (actionSets[i].getId().equals(actionSetId)) { IExtension ext = actionSets[i].getConfigurationElement().getDeclaringExtension(); reg.removeExtension(ext, new Object[] { actionSets[i] }); return; } } }
/** * 移除无用的菜单项:<br/> * File 菜单下的“open file...”和“Convert Line Delimiters To” */ private void removeUnusedAction() { ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry(); IActionSetDescriptor[] actionSets = reg.getActionSets(); List<String> actionSetIds = Arrays.asList("org.eclipse.ui.actionSet.openFiles", "org.eclipse.ui.edit.text.actionSet.convertLineDelimitersTo", "org.eclipse.ui.actions.showKeyAssistHandler"); for (int i = 0; i < actionSets.length; i++) { if (actionSetIds.contains(actionSets[i].getId())) { IExtension ext = actionSets[i].getConfigurationElement().getDeclaringExtension(); reg.removeExtension(ext, new Object[] { actionSets[i] }); } } }
private void removeActionSets() { // currently we just remove the cheat-sheets here; see: // http://random-eclipse-tips.blogspot.de/2009/02/eclipse-rcp-removing-unwanted_02.html ActionSetRegistry reg = WorkbenchPlugin.getDefault().getActionSetRegistry(); IActionSetDescriptor[] actionSets = reg.getActionSets(); for (int i = 0; i < actionSets.length; i++) { if (Objects.equals(actionSets[i].getId(), "org.eclipse.ui.cheatsheets.actionSet")) { IExtension ext = actionSets[i].getConfigurationElement() .getDeclaringExtension(); reg.removeExtension(ext, new Object[] { actionSets[i] }); } } }