Actually, I have a new action that I want to show up in the "new" sub-menu when right-clicking somewhere in the source path in the project view, like Class and Interface. But I don't want it to show up when clicking out of the source path, the same way that Class and Interface do. I've tried checking for visibility of the action "NewClass," but it's always true:
AnAction anAction = ActionManager.getInstance().getAction("NewClass");
LOG.info("anAction.getTemplatePresentation().isVisible() = " + anAction.getTemplatePresentation().isVisible());
LOG.info("anAction.isEnabledInModalContext() = " + anAction.isEnabledInModalContext());
anAction.getTemplatePresentation().isVisible() = true
anAction.isEnabledInModalContext() = false
regardless of where I click.
So to hack around this, I get the VirtualFile that was selected when the right-click happened, and I want to check if it's in the source path, but I'm not finding a way to do that.
FWIW, here's the line in plugin.xml that adds my action to the menu:
<add-to-group group-id="NewGroup" anchor="after" relative-to-action="NewClass"/>
Any thoughts would be appreciated.