How can i make an action visible or not?

When I right click on a file in the tree, i want to have a new item there (under 'New'). And i want to control when this item/action is it visible or not.
How can i do this? (In a plugin)
Thank you!

Comment actions Permalink

Please see
Enabling/Visibility of actions can be controlled via com.intellij.openapi.actionSystem.Presentation

Comment actions Permalink

Override method AnAction.update() and call AnActionEvent.getPresentation().setEnabled(), setVisible() or both. There are millions of examples in IntelliJ IDEA Community Edition source code.

BTW there's a dedicated forum for plugin developers:


Please sign in to leave a comment.