How can I customize the context/menu bar programmatically?
Hi,
I need to remove some actions from menu bar programmatically.
I know that it's possible to do this though Settings > Appearance & Behavior > Menus and Toolbars, but I'm trying to build an plugin that customize the actions and show by default the actions that I need.
I can remove the tools:
// get tool window manager
final ToolWindowManager manager = ToolWindowManager.getInstance(project);
// iterate all tools windows by id
for (final String id : manager.getToolWindowIds()) {
...
}
// get tool window
final ToolWindow toolWindow = manager.getToolWindow(id);
// hide tool window
toolWindow.setAvailable(false, null);
Using the ActionManager class I can get all the actions available:
final ActionManager actionManager = ActionManagerImpl.getInstance();
String[] actionIds = actionManager.getActionIds("");
Now I need to know how can I remove some of them.
Thank you,
Eduardo Costa
请先登录再写评论。
You can get the corresponding menu action group from ActionManager and invoke DefaultActionGroup.remove(action) on it.
I tried the code bellow (to remove help menu for example) and works:
Thank you Peter by your reply.
Best regards,
Eduardo Costa