Add ActionGroup to and Remove ActionGroup from EditorPopupMenu
Answered
Hi Team,
I understand that we can add actions to a given group dynamically. Is it possible to hide/show the group itself dynamically programmatically in a plugin?
For dynamically adding actions to the group, I'm overriding getChildren() as below.
if (condition) {
return new AnAction[]{new myAction1(),new myAction2()};
}
return new Action[0];
When the condition is not satisfied and I right click from the editor, I see the action group still being part of the right click menu item but disabled. When no actions can be added (based on a condition), I want to hide the action group (outermenu) itself. How can I get this?
Please sign in to leave a comment.
See https://plugins.jetbrains.com/docs/intellij/basic-action-system.html#the-compact-attribute
Actually, I'm looking for a way to hide (not disable) the group itself…
Override
com.intellij.openapi.actionSystem.AnAction#update
as described here https://plugins.jetbrains.com/docs/intellij/basic-action-system.html#enabling-and-setting-visibility-for-an-action