Geertjan is a DZone Zone Leader and has posted 457 posts at DZone. You can read more from them at their website. View Full User Profile

IDE-Agnostic Swing RCP Development

05.24.2008
| 21496 views |
  • submit to reddit

In a team of developers, especially if distributed, there's a good chance that different IDEs are used by different members of the team. But projects from one IDE can't (easily, if at all) be opened in another IDE. Maven offers a valid outcome, since projects built on Maven can be opened in any IDE, without any tweaking or funky post processing steps being required. Here we look at one scenario: Swing RCP development on the NetBeans Platform in IntelliJ, NetBeans IDE, and Eclipse.

The NetBeans Platform is a modular Swing application framework. It offers very robust and advanced features for large Swing applications, such as an out of the box docking system, lifecycle management, and a pluggable infrastructure. Typically, if you want to develop your desktop applications atop the NetBeans Platform, you need to use NetBeans IDE. Why? Because NetBeans IDE has a very useful and extendable collection of code generating wizards that are essential when you're getting started with the NetBeans Platform. However, after that stage, i.e., at the point where you've generated the basic boilerplate code of your application, and you're coding the business layers, with all its algorithms and so on, you could be using any IDE at all.

Except... you're not able to open a NetBeans module project into any IDE other than NetBeans IDE. Both IntelliJ and Eclipse require certain (and different) project metadata that NetBeans IDE projects don't provide. But what if we were using a NetBeans Platform Maven archetype instead? That's possible in NetBeans IDE since NetBeans IDE 6.1 (as explained here in my blog). There's also a Maven archetype for NetBeans modules. Here I've created a basic application structure, consisting of some windows, a branding module, and an action, each of which is contributed by a Maven archetype:

When I run the NetBeans Platform Maven archetype that you see above, I get a basic application, without much content, but with all the typical features of an application built atop the NetBeans Platform, such as a windowing system, lifecycle management, and a pluggable infrastructure:

However, since I am using Maven, I can—without doing anything special—simply open the Maven projects (via the universal pom.xml file) into IntelliJ and work on them there:

Similarly, another team member, who might prefer Eclipse, can open the Maven projects into Eclipse and continue working seamlessly there:

It's not a magic bullet, of course. Not everything is possible across all IDEs. For example, the form files created in NetBeans IDE by its Matisse GUI Builder cannot be opened in other IDEs. On the other hand, if you're using different IDEs in your team for Swing development, the IDE you'd use for GUI design is probably going to be NetBeans IDE anyway. Therefore, GUI design would be done in NetBeans IDE, while finetuning of pom.xml files might be done in Eclipse because of its cool structured editor for pom.xml files, and so on.

Using Maven, you can truly liberate your applications from IDE lock in. Of course, Maven has problems of its own and I'm not saying Maven is the answer to everything. However, if your development team is comfortable with Maven, a lot of possibilities are suddenly open to you. In the case of the NetBeans Platform, you'd use NetBeans IDE to generate the basic infrastructure of your application and then each member of the team would be able to choose for themselves which IDE they want to use for editing purposes. Given that you're dealing with a modular application, each developer could be working on a distinct module, within the IDE of their choice. You'd probably return to NetBeans IDE for deployment purposes and ancillary matters, since several features specific to the NetBeans Platform can be found there. (Though someone knowledgeable about their IDE's APIs could easily add those features to their own IDE.) However, since most of your time is spent coding, the scenario of multiple IDEs working on the same NetBeans Platform application is certainly conceivable. As a result, you end up with a toolbox consisting of multiple IDEs and you'd simply pick and choose whichever does a particular task best. The best of all worlds... not bad!

AttachmentSize
maven-agnostic-rcp-app=1.png26.63 KB
maven-agnostic-rcp-app=2.png28.14 KB
maven-agnostic-rcp-app=3.png96.92 KB
maven-agnostic-rcp-app=4.png109.77 KB
Published at DZone with permission of its author, Geertjan Wielenga.

Comments

Bryan Low replied on Sun, 2013/02/24 - 4:55am

Great Post. I have not been visiting the site recently. Took a visit again and there were some great comments on the site. Excellent post. Keep up the good work.

Bartley Ridge Floor Plans

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.