To help us prepare for our talks for our talks at Oracle CodeOne – “Writing Better Code (Faster) in the Apache NetBeans IDE [BOF4759]” and “Hacking the NetBeans IDE [BOF4760]”, we have been writing some blog posts on NetBeans. We hope you find them useful…
Extending Local History in NetBeans IDE
One of my pet hates on NetBeans IDE is that you cannot get a local history on multiple files. I do not like the way it is commented out if you select multiple files like this…
I think it would be much cooler if it could open all the files selected like this….
As Steve Jobs might say, “fix it” and now that you can.
Making Local history accept multiple files
The NetBeans platform provides a very modular code base which does most of the hard work for you. It just needs code added to call back when you want something to happen. Extensive use is made of Annotations to reduce code needed and the code is cleanly split out into Actions, Views, etc.
The Show Local History function is controlled by the ShowHistoryAction.java class. It contains two sections of interest to us. The enable function is called by NetBeans to determine when the menu option is enabled or disabled. Currently it is setup to reject anything which is not a File or more than one file. We can easily change this with the additional code.
The action is still expecting to be given a single file so we also need a little bit of code to handle the multiple files selected. For the moment, we will just open them all in a new window each.
Notice how little actual code I have written to implement this. I am just reusing existing NetBeans functionality.
We could easily hack this code to recursively open directories and all manner of new features. But Steve Jobs also believed in leaving the audience wanting more, so we will stop there for this instalment…
Can we help you to solve any of these problems?
IDRsolutions has been helping companies to solve these problems since 1999.
|Convert PDF to HTML5 or SVG||Convert PDF forms to HTML5|
|Java SDK for Image files||Java SDK for PDF files|