Meet a NetBeans Module Writer: Sandip Chitale
|Download Sandip's modules!
Binary NBM Files:
NetBeans recently met with Sandip Chitale, who is a Senior Staff Engineer for Sun Java Studio Creator. He has over 17 years of experience in software development and has been working with Java since 1996. He's also someone who has written—and continues to write—NetBeans modules.
Sandip, how did you come to be involved in NetBeans module development?
I am interested in Graphical User Interfaces and Software Development Tools i.e., Integrated Development Environments (IDEs). I have worked on several IDEs. My current interests—refactoring and language modeling in IDEs. I am currently working in Sun Java Studio Creator (an IDE for developing JSF based applications) development group. I am working on support for refactoring and two way editing of JSF artifacts (JSP, Java and faces configuration files). Sun Java Studio Creator is based on the NetBeans Platform. That is how I got into NetBeans IDE. In the past I have worked with Eclipse IDE and Eclipse RCP. I developed several Eclipse modules and a prototype Eclipse RCP application. NetBeans IDE is one of the first IDEs with a completely modular architecture. In NetBeans IDE everything is a module. That is very cool!
What are some of the most recent NetBeans modules that you've been working on?
The Java File Structure module shows the structure of Java files. The Java Type Hierarchy module shows the hierarchy of Java Types.
What do they do?
The Java Type Hierarchy module adds a menu item to the View menu as well as a toolbar button and keyboard shortcuts. When you choose the menu item or press the shortcut, the hierarchy of the Java type under the cursor is displayed, as shown in this illustration (click to enlarge):
On the other hand, the Java File Structure module pops up to show a tree structure of a selected Java file. For example, all its classes, interfaces, methods, and fields are shown (click to enlarge):
So how are these modules different from the Navigator in NetBeans IDE?
I was asked the same question when I demoed these in our Sun Java Studio Creator group meeting. So I am prepared to answer this! The biggest difference is that both the modules can show the structure or hierarchy of the type under the cursor, aside from the currently open file. Both the modules show JavaDoc when available. The JavaDoc is shown in a JEditorPane, which allows scrolling. Both the modules have an ability to load arbitrary classes using the Java Type Name text field at the bottom. To some people the popup behaviour is more appealing. The Java File Structure filter works by narrowing the tree to match the methods and fields, thus focusing on the thing of interest. The Java Type Hiererachy module can not only show super classes but also sub classes. This is very important. Having said that, these modules can also be thought of as being complementary to the NetBeans IDE's Navigator.
You've also made the Module Info Task module. What's that about?
The Module Info Task module generates an HTML file which shows the details of all the modules installed in NetBeans IDE. This information is very useful while developing modules, which is why I developed it. The module info file can be generated by invoking the "Tools > Generate Module Info" menu item or a tool bar button. The same functionality can be invoked using an Ant task. The Ant task must be invoked from within the NetBeans IDE. Here is a a sample output file which shows info about the relationship between all the modules in NetBeans IDE 5.0 Beta2.
The modules can be downloaded from this page. Can you tell us what state they're in?
They are in fairly good shape. However, they are not part of the NetBeans IDE and thus have not gone through rigorous testing. I have tested them only on my Windows XP laptop.
What did you find the most interesting thing while developing the modules?
Firstly, the notion of public packages which export only certain packages of a module to other modules. This takes getting use to, as it is different from the standard notion of Java classpath. On the other hand it forces you to think about what are the public interfaces that are exported from your module and what are the private implementations.
Secondly, the notion of layer files to declaratively configure services of a module is very interesting. The layer file describes a hierarchical, virtual file system which configures the functionality of NetBeans modules and applications based on the NetBeans Platform.
Thirdly, the new support for module development in NetBeans IDE 5.0 makes it very easy to get started with module development. The new tutorials also provide great help to the developers starting on NetBeans module development. The new NetBeans module development support is another great resource for module developers.
Finally, there is very powerful support for Java Language Modeling hidden inside NetBeans IDE. It not only models Java Class files but also the Java Source code in real time. I discovered this while working on the Sun Java Studio Creator project. That provided me inspiration to develop the Java File Structure and Java Type Hierarchy modules.
What was hardest, Sandip?
I started developing modules using NetBeans Platform 4.1. In those days it was hard to find the documentation of module development. That was then. That is all changing in NetBeans IDE 5.0—which has excellent support for module development.
The Module APIs documentation is slightly hard to navigate.
The documentation of what goes in the layer files is spread across documentation of various modules. The view in the module project—under Important files:XML Layer helps in visualizing how your modules layer file participates in the target platform.
How did you overcome obstacles?
It was hard to find how modules related to each other and what was exported by which module. Also it was hard to correlate the NetBeans API documentation to the actual usage of the API. When I wrote the Module Info Task module, it helped me to correlate the NetBeans API documentation to the actual usage of the modules. The filter functionality in the Add Library dialog also helps somewhat.
It was hard to learn about the Java Language Modeling support. I had to refer to the source code of several modules and look at how the APIs were used in the NetBeans IDE itself to understand how to use the Java Language Modeling support APIs.
What are your key learnings?
The modular architecture is a boon to developers who want to contribute additional cool functionality to an already powerful, open source NetBeans Platform. The new module development support makes it very easy to get started.
Based on my experience with developing modules for Eclipse IDE I can safely say that module development is as easy (if not more so) using the NetBeans Platform.
Recently you introduced James Gosling to NetBeans module development. That must have been an interesting experience. Can you tell us something about it?
Yes, I recently demoed the Java File Structure and Java Type Hiererachy modules at a Sun Tools All Hands meeting.
I demonstrated how easy it is to build NetBeans modules using the support for building modules in NetBeans IDE 5.0. James Gosling was in the audience. Here is what he had to say after the demo:
"After your talk I went back to my office and tried building a module: Worked totally smoothly... Took less than a minute to get 'hello world' to work. Great job folks! What makes it especially cool to me is that I tried this exercise a couple of years ago and banged my head against NB3.6 for quite a while before giving up. It was a really obscure process, especially since I wanted to do it without asking for help (asking The Gods for help seemed like cheating) What a difference!"
If you could improve one thing about module development in NetBeans IDE, what would it be?
The module support documentation could be improved. Better documentation of layer files is definitely required. Alternatively the user should never be required to edit these files. That would be fantastic! However, what that means is that all the Module Development support wizards will have to be re-entrant.
Tell us about a few things you're thinking of doing with NetBeans module development in the future?
Currently I am working on a module to better integrate NetBeans IDE with the rest of the desktop. It should be possible to open file or folder nodes (using D&D or context menu item) in various NetBeans IDE explorers using other applications. For example, by clicking on an XML file I should be able to open it in the XML editor registered with the OS.
I am also thinking of developing some additional Java refactorings.
For information about creating and developing modules, see the following resources: