Search in sources :

Example 1 with IActionSetDescriptor

use of org.eclipse.ui.internal.registry.IActionSetDescriptor in project translationstudio8 by heartsome.

the class ApplicationActionBarAdvisor method removeUnusedAction.

/**
	 * 移除无用的菜单项:<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] });
        }
    }
}
Also used : ActionSetRegistry(org.eclipse.ui.internal.registry.ActionSetRegistry) IExtension(org.eclipse.core.runtime.IExtension) IActionSetDescriptor(org.eclipse.ui.internal.registry.IActionSetDescriptor)

Example 2 with IActionSetDescriptor

use of org.eclipse.ui.internal.registry.IActionSetDescriptor in project dbeaver by serge-rider.

the class ApplicationActionBarAdvisor method removeUnWantedActions.

private void removeUnWantedActions() {
    ActionSetRegistry asr = WorkbenchPlugin.getDefault().getActionSetRegistry();
    IActionSetDescriptor[] actionSets = asr.getActionSets();
    for (IActionSetDescriptor actionSet : actionSets) {
        for (String element : actionSetId) {
            if (element.equals(actionSet.getId())) {
                log.debug("Disable Eclipse action set '" + actionSet.getId() + "'");
                IExtension ext = actionSet.getConfigurationElement().getDeclaringExtension();
                asr.removeExtension(ext, new Object[] { actionSet });
            }
        }
    }
}
Also used : ActionSetRegistry(org.eclipse.ui.internal.registry.ActionSetRegistry) IExtension(org.eclipse.core.runtime.IExtension) IActionSetDescriptor(org.eclipse.ui.internal.registry.IActionSetDescriptor)

Aggregations

IExtension (org.eclipse.core.runtime.IExtension)2 ActionSetRegistry (org.eclipse.ui.internal.registry.ActionSetRegistry)2 IActionSetDescriptor (org.eclipse.ui.internal.registry.IActionSetDescriptor)2