That could be a pretty useful thing for adding new actions that are applicable to projects. (Maybe an action that interacts with Roman's Project Packager, for example.)
So, this is how I added the action (click to enlarge):
But, the best part is that I discovered how to do this by just hanging out in the System Filesystem Browser which you get when you create a module project. It lists all the layers made available by all the available modules. So, that's how I found out about the existence of the ProjectsTabActions folder... And then I just used the Action wizard to create the action and tweaked the layer.xml file so that the action was registered in the ProjectsTabActions folder instead of somewhere else.
So, whenever you create a module project, you get the System Filesystem Browser, which is an extremely educational tool, allowing you to discover folders that you never knew existed. Here, for the uninitiated, is part of my System Filesystem Browser (click to enlarge):
What's also cool about the System Filesystem Browser is that you can drag and drop items within the folder, which results in tags being added to the layer.xml file for sorting the item within the folder. In fact, I didn't type anything in the layer.xml file shown in the second screenshot above (apart from the name of the ProjectsTabActions folder). It was all done for me by the IDE. Something else that's cool is that everything that the current module is going to add to the module universe is printed in bold in the System Filesystem Browser. Really handy. Go ahead—enlarge the screenshot above and notice the bold folders and then enlarge the second screenshot above and notice that the bold folders are the ones that are in my module's layer.xml file. Handy, right?
I'm really enjoying your blog, have been learning lots by reading it--you aren't just promoting, you are educating, so kudos to you.
I saw this blog entry and was wondering--how do I add a menu item to a free-form project? The docs leave something out. I have a custom target in my build file, say, "do-foo". I can map this to an existing IDE action in project.xml (like compile.file), but if I add a new ide-action, like nb.do-foo, I can't figure out how to trigger it. Since NB support is built-in, it would be nice to add context-menu actions that trigger Ant targets.
Any advice is welcome!
Patrick
Thoughts?
Thanks,
Patrick
Hi Geertjan
Sorry, some tags got clobbered on that last post. Here's a correction: ...
So, to be specific, in project.xml, I have a new <action> element under my <ide-actions>. Now I need to figure out how to add a context-menu item for the project that triggers that action. In my case, I set the action to <action name="compile.single"> so I can trigger it from the Build/Compile File menu.
TIA
Patrick
Hi Geertjan
I checked back to see if there was a reply, and found my posting, in two parts, was cropped so only one part (the important one) got posted.
Here's my situation/use case: I have XDoclet tags that currently process a whole directory tree. There is one global flag to check if XDoclet needs to run, but if it does need to run, it runs against the whole tree. This takes several minutes, so when I just modify 1 file there's a long delay to see the new generated output.
I want to pass in a file name, or multiple file names, into my Ant script, so that the XDoclet tag processes just those files (or all files if I pass nothing in). I have modified the XDoclet script in Ant to take one or more files, have tested it. Now I want to use that Ant target from NetBeans, passing in the current file or selected files in the Project view.
This is about the same as "Debug Single File". The issue is, I can create an <ide-actions> entry for my special new target, and I can trigger it, say, with "Compile Single File". That is, NB already knows about the compile.single or debug.single targets and when I map those to an Ant task, it knows how to run them. How can I map a menu item to a custom <ide-actions> entry, such as "Run XDoclet on Current File"?
That's it! The script works, everything works, I just can't trigger the script from within NB without a hack--changing the meaning of an existing tag like "Compile Single File" to mean something else.
Thanks, Patrick
<img src="http://blogs.sun.com/roller/resources/geertjan/runxdocletoncurrentfile.png">
<img src="http://blogs.sun.com/roller/resources/geertjan/runtothehills2.png">
<img src="http://blogs.sun.com/roller/resources/geertjan/runtothehills1.png">
Hi Geertjan--I am aware of that option, but it does something different. You can take a target in the Ant file and map it to a GUI menu command. When you do that, the Ant target is executed (pretty much) as if it had been run from the command line.
What I am looking for is something a little different. If you look at the documentation on Advanced Free-Form Project Configuration, see section http://www.netbeans.org/kb/41/freeform-config.html#runsingle. There, they set up an Ant target that expects to be called from NetBeans, and passed a variable called ${runclass}. If that variable is not given, the target will fail. I'm doing the same thing, except I'm calling an XDoclet target with a variable called ${files}. If I map the way you did, on Project Properties/Build and Run, the Ant target will be called but with no special variables. However, it is possible to do, the question is whether it will work if you step outside of run.single, debug.single, etc. as the examples are limited to those situations.
Try adding this to your Ant build file:
Then add this to your project.xml file:
to your ide-actions section. No, how do you execute "run-do-single-file" from within NetBeans?
Thanks,
Patrick