Multiview Editors and NetBeans

Finally, code has started to run as expected. I am able to see multiview editor for file with extenstion “story” in NetBeans IDE. Well, I am talking about the code I downloaded from Vadiraj’s blog today and executing it almost as expected.

Vadiraj’s Blog

Few years back, Vadiraj Deshpande (Sun Employee) devoted time to make use of Geertjan’s Multiview API Sample, to extend the support for multiview editor supplied with it, by adding a new view using Visual Library.

Last year, I got interested in creating a multiview editor support for new type of files. So, I asked the question on NetBeans Forums, where Vadiraj replied by providing pointers to Geertjan’s blog series and his own blogs.

Multiview Editor Support

Today, I decided to give it a try and headed towards Vadiraj’s blog to get started. Hence, I downloaded the code of Geertjan’s Multiview API Sample and realized from Vadiraj’s blog, that it was supposed to build in NetBeans 5.5 IDE.

Manage NetBeans Platforms

However, as I had recently found out that NetBeans IDE allows you to manage NetBeans Platform for your NetBeans Module Projects. As per the blog, I made changes to the NetBeans Platform Config file of the project and made it possible to actually build the module that’s supposed to work in NetBeans 5.5 IDE against its modules clusters, while using any higher release of NetBeans IDE. This is only possible if you have the installation directories of previous releases.

I didn’t had 5.5, so I made use of 6.0 to build the module and possibly uncover any deprecated usage, if present. The splash screen flashed and soon, after ClassCastException was thrown;

public BookDataLoader() {

The bold faced text is the culprit, building against NetBeans 6.0 causes this and to solve this issue, do the following change;

public BookDataLoader() {

I have just passed the FQN of the BookDataObject class as String to the super constructor and then, I ran the module in debug mode. It works smoothly now and then, I just drag-n-drop the supplied abc.story file to see the Multiview Editor in action. Indeed, I saw the same view as specified in Geertjan’s blog.

Click to enlarge!

Afterwards, I found out that I actually had NetBeans 5.5.1 IDE. So, I thought of giving it a try and hence, I added it as one of the platforms in 6.5 FCS I was using. I didn’t revert back changes made to the code as mentioned above and build the module. I was amazed to see the same result.

Backward Compatibility

This is really exciting to actually the run the module made using 5.5 release in higher releases of the same. You might also know that NetBeans API’s generally supports backward compatibility, so there should not be any problem if I build the code using NetBeans 6.5/6.7 IDE. So, I did that using 6.5 FCS and to my surprise, it worked as expected.

Although, Output Window opened in 6.5 FCS showed lots of exceptions (caused internally, not by the code) being thrown, warnings, etc. Still, the file got recognized as expected, multiview editor was opened, I was able to switch between the views using toggle buttons on its toolbar and it didn’t threw any exception.

Now, I will explore the code to experiment and learn the concepts, before beginning to create my own multiview editor for new type of files. Thanks, Vadiraj and Geertjan!

Stay tuned..