Extend an Existing NetBeans IDE Project's Functionality
By Geertjan-Oracle on Jul 28, 2005
<folder name="Projects"> <folder name="Actions"> <file name="org-myorg-genericprojectaction-GenericProjectAction.instance" /> </folder> </folder>
And then you can invoke the action from a project's contextual menu:
To put the action in a different place in the contextual menu, you'd use the <attr> element, but then you'd need to know the real name (i.e., not the name that appears on the menu item but the name that you'd find in the localization bundle). And that's always a problem to work out -- a lot of digging through the NetBeans sources to see what something else is called, in order to know where the thing you're actually interested in should go.
In addition, I can imagine some actions that are relevant to web projects, but not to J2SE projects. Or J2EE-related project actions that have no relevance for web projects. However, I don't think it's possible (yet) to make that distinction in the layer.xml file.
By the way, using the layer.xml file like this is similar to what you do in free-form projects (i.e., not the standard projects for which the IDE generates its own Ant file) with Ant targets -- you can hook Ant targets up to a free-form project's contextual menu, but then only to a specific project, not to all projects simultaneously. On top of that, of course, the functionality that a plug-in offers is, at least potentially, much more extensive than what an Ant script can provide. And -- most important of all -- you can share a plug-in much more easily than an Ant script. Just put the NBM file in an e-mail, for example, or make it available via the Update Center. The Ant script, no matter how useful it is, requires a lot of little fiddly steps before it's hooked into someone else's project.