Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Hacking the NetBeans IDE – 4. Changing the way NetBeans IDE Local History works

1 min read

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…

If you’re a first-time reader, or simply want to be notified when we post new articles and updates, you can keep up to date by social media (Twitter, Facebook and Google+) or the Blog RSS.

 

Mark Stephens Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX. He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Leave a Reply

Your email address will not be published. Required fields are marked *