Toni Epple works as a consultant for Eppleton (http://www.eppleton.de) in Munich, Germany. In his spare time he's an active member of the Open Source community as a community leader for JavaTools community (http://community.java.net/javatools/), moderator of the XING NetBeans User Group (http://www.xing.com/group-20148.82db20), founder of the NetBeans User Group Munich (http://tinyurl.com/5b8tuu), member of the NetBeans Dream Team (http://wiki.netbeans.org/NBDTCurrentMembers) and blogger (http://www.eppleton.de/blog). Toni is a DZone MVB and is not an employee of DZone and has posted 51 posts at DZone. You can read more from them at their website. View Full User Profile

NetBeans IDE 7.1 Review: NetBeans Platform Support

01.24.2012
| 13804 views |
  • submit to reddit

NetBeans IDE 7.1 adds JavaFX 2.0 Support (see my review of that) and a lot of new features and improvements including improvements to the NetBeans Platform itself.

The NetBeans Platform is an application framework that can be used as a stable basis for mostly Java desktop applications. (Dozens of screenshots of applications using this framework can be found here.)

In this article, I'll focus on the changes to the NetBeans Platform in its newest release, i.e., NetBeans Platform 7.1.


Window System



The NetBeans Platform features a very powerful Window Management System, letting you declaratively define default window positions, resizing and docking/undocking windows, minimize/maximize, persist window state, group behavior, etc. Version 7.1 introduces a couple of new features here. You can see them in the IDE and reuse them in your NetBeans Platform applications.



The reason for the recent improvements is that the NetBeans team apparently has joined forces with the designers of another IDE, planning to reuse the NetBeans window system. From the press release:

The community working on NetBeans project is proud to announce the availability of new, improved and most flexible version of its window system - the docking framework behind the IDEs, as well as many other NetBeans Platform based applications. By joining forces of the teams working on the design of two large IDEs, we managed to marry the expertise, excellence and creativity of human interface designers, artists, look & feel experts, developers and architects to form a window system ready for the 21st century.

http://wiki.netbeans.org/WinSys71PressRelease

Note that the carefully crafted message above avoids to spell out the other IDE's name! Since it seems to not be very public information yet, I'll leave it to the dear reader to speculate. :-) The "other 
IDE" obviously missed some features in the NetBeans Platform window system. So they had to be introduced here before the "other IDE" could adopt the NetBeans Platform.



Perspectives



The most important enhancement seems to be "Perspectives", which are named "Roles" here as a way of switching between window layouts. When registering a window you can now add one or more roles to it in the Annotation, e.g.:



@TopComponent.Registration(mode = "editor", openAtStartup = true, role="admin")



To switch perspectives programmatically you only need to call the Window Manager:



WindowManager.getDefault().setRole("user");



In case you want to pick a Role during startup, there's also a new Listener interface you can use called WindowSystemListener which will receive events during the window system lifecycle (beforeLoad, afterLoad, beforeSave, afterSave). A very handy improvement over the existing system. For more details and a complete example have a look at Geertjan's blog post.



Window Layout Designer



One extremely useful new feature is the new Window Layout Designer allowing you to create new Layouts via drag and drop. You can invoke this functionality using the new "Layout of Windows" wizard. The Wizard will launch your application in a special mode, and allow you to create or change Window Positions, aka "Modes" and save the changes to a layer file and the files required for defining new Modes.

Image 1: Application started in Design Mode

If you've ever tried to create your own Mode, you'll find this feature extremely helpful!
 

 



Image 2: Automatically created Mode definitions

Window Group Behaviour



The docking system allows you to undock/dock single Windows. In NetBeans Platform 7.1 you can now do the same with a whole docking area. So you can now easily undock a group of Windows. This functionality is available from the context menu of the Window.

 

Image 3: A minimized Window Group

That's nice, but the second option, using a drag gesture for this is more intuitive and useful.
 The same improvement has been added for moving a whole docking area or Window Group to a new position. You can simply drag and drop it there, while visual guidelines will help you direct the reordering.



Pluggable MultiViews

In case you're using the MultiView API, there's a very interesting enhancement. You can now register a MultiView for an existing MimeType. It will be available from MimeLookup and can be located by MultiViews.createCloneableMultiView, a factory method that creates a multiview for a given mime type. So any existing MultiView Editor registered for a MimeType automatically has an extension point and can be enhanced.

Image 4: A custom multiview tab in the standard Java Editor

Again Geertjan has a blog entry with a sample for this new functionality.



SaveCookie Replacement



Up to Version 7.1 the System for tracking savable changes in TopComponents was based on the DataSystems API. In order to activate the save Button, a TopComponent was basically forced to be backed by a DataObject and a File. This was in the way of reuse. You couldn't easily plug things like database changes into such a system and caused some issues with the displayName. 7.1 introduces Saveable as a replacement for SaveCookie and AbstractSaveable to help you implement it. 



Visual Debugger

I already described this in my review of the JavaFX support. NetBeans IDE 7.1 has a visual debugger allowing you to take UI snapshots and examine them in the IDE. This feature also works for NetBeans Platform applications. Even when you open multiple windows and undock some of them the it works as expected. The undocked windows will be saved as a separate snapshot in the Editor and you can dig through the component hierarchy, check registered listeners and even attach special Event logging Listeners. I guess that alone should be investigated in an article of it's own. I'm really deeply impressed with this feature. 



Configurable Cache Directory



One thing we often had problems with during our trainings at universities and conferences was the performance of the IDE and NetBeans Platform when the cache dir is on a slow network drive. With the new command line switch "--cachedir", you can override the default location. It has a nice impact on performance if the cache dir is on a fast local disk.



Downloadable NetBeans Platform for ANT builds



NetBeans Platform really has one nice benefit over it's main competitor Eclipse RCP, and that is the use of standard build systems. With NetBeans and Maven setting up a continuous build is a click in a context menu, in Eclipse this is a topic of advanced RCP trainings. One other nice benefit of Maven is the ability to define which platform should be used in an application. This way there's a clearly defined Version hosted in a repository that all developers use.

With ANT it has often been a hassle to really configure everything correctly, so every developer works with the same APIs, and depending on the setup, a single developer updating the IDE could break the build for all team members by setting a module dependency after the update. So you had to be careful what you do and setup policies for which platform to use, e.g. by putting it under version control.

With 7.1 the build harness has been updated to support downloading a specified version of the platform as part of the build process.
It's actually very simple. In your NetBeans Platform Application project you just need to locate the platform.properties file and replace the line specifying your platform which usually is:



nbplatform.active=default



with this:

suite.dir=${basedir}
nbplatform.active.dir=${suite.dir}/netbeans701
harness.dir=${nbplatform.active.dir}/harness
bootstrap.url=http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/netbeans/harness/tasks.jar
autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/7.0.1/uc/final/distribution/catalog.xml.gz



If you do a clean and build ANT will download the platform automatically.

Registration and Layers

In an attempt to convert most of the layer based registry to Annotations and AnnotationProcessors, the registration of File Templates has now been changed. The new Annotation @TemplateRegistration can be used for that. Many of you will probably remember the build warning that the use of an empty layer is highly inefficient. :-).

Now the main reason for this, the checkbox in the Module Project Wizard has been removed. If you still need to register something in the layer, and you're too lazy to write your own AnnotationProcessor, or can't use one for other reasons (there are some corner cases where Annotations won't work), there's now a wizard for creating a layer.

And as another enhancement to the registry, the "this layer in context" UI for investigateing and manipulating the layer file has been fixed to work as expected for Maven based projects, the IDE will download the required JARs from the repository when needed, without the need to a build the suite. 



Conclusion

The NetBeans Platform has received some very useful updates. Primarily, the Window System, which was one of the best on the market before, and at least the best free one, has been further enhanced.

What I really like is that also the tooling has become better. When talking to users who know both Eclipse RCP and NetBeans most of them like the NetBeans APIs (and the build process) better, but they point out that Eclipse RCP tooling is better. So any improvement here really is appreciated.

Congratulations to the NetBeans Team for a great release!

Published at DZone with permission of Toni Epple, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Jason Midkiff replied on Tue, 2012/01/24 - 11:06am

Nice post Toni. I wasn't aware of the new Role functionality. I'll definitely need to work that into our current products.

Javier Ortiz replied on Tue, 2012/01/24 - 11:32am

Great article! I am really interested in Downloadable NetBeans Platform for ANT builds

 section and have a question. How will this work with custom platforms? For example my project works with the NB platform and some additional projects? I'm still trying to figure out the correct properties from the section, they come out really ugly from the post.

Javier Ortiz replied on Tue, 2012/01/24 - 11:52am

This is what I ended with:



suite.dir=${basedir}

nbplatform.active.dir=${suite.dir}/netbeans701

harness.dir=${nbplatform.active.dir}/harness

bootstrap.url=http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/netbeans/harness/tasks.jar

autoupdate.catalog.url=http://updates.netbeans.org/netbeans/updates/7.0.1/uc/final/distribution/catalog.xml.gz

But I'm getting an error:

platform.download:
Created dir: C:\Users\jortiz00\Desktop\suite1\${suite.dir}\netbeans701
\harness

Downloading clusters apisupport|cnd|dlight|enterprise|ergonomics|extra|groovy|harness|ide|java|javacard|javafx|mobility|nb|php|platform|profiler|sappy|stableuc|websvccommon
Getting: http://deadlock.netbeans.org/hudson/job/nbms-and-javadoc/lastSuccessfulBuild/artifact/nbbuild/netbeans/harness/tasks.jar

To: C:\Users\jortiz00\AppData\Local\Temp\tasks.jar
local file date : Tue Jan 24 06:31:01 CST 2012
Not modified - so not downloaded
Downloading http://updates.netbeans.org/netbeans/updates/7.0.1/uc/final/distribution/catalog.xml.gz
org.netbeans.lib.profiler is not present, downloading version 1.14.1
Getting: http://updates.netbeans.org/netbeans/updates/7.0.1/uc/final/distribution/patch2/profiler/org-netbeans-lib-profiler.nbm
To: C:\Users\jortiz00\AppData\Local\Temp\org-netbeans-lib-profiler1974825824638273046.nbm
http://updates.netbeans.org/netbeans/updates/7.0.1/uc/final/distribution/patch2/profiler/org-netbeans-lib-profiler.nbm moved to http://dlc.sun.com.edgesuite.net/netbeans/updates/7.0.1/uc/final/distribution/patch2/profiler/org-netbeans-lib-profiler.nbm
C:\Users\jortiz00\Desktop\suite1\build.xml:7: The following error occurred while executing this line:
C:\Users\jortiz00\Desktop\suite1\nbproject\build-impl.xml:41: The following error occurred while executing this line:
C:\Users\jortiz00\Desktop\suite1\nbproject\platform.xml:29: java.io.FileNotFoundException: C:\Users\jortiz00\Desktop\suite1\${suite.dir}\netbeans701
\profiler\lib\jfluid-server-15.jar (The system cannot find the file specified)

Any ideas?

Toni Epple replied on Tue, 2012/01/24 - 12:09pm in response to: Javier Ortiz

You're right, they were scrambled. Thanks for the hint, I corrected it.

Toni Epple replied on Tue, 2012/01/24 - 12:16pm in response to: Javier Ortiz

Hi Javier,

it looks as if suite.dir isn't set in your platform.properties file. If you look at the paths that are echoed, you can see that ${suite.dir} isn't resolved correctly. If I remove this line from my platform.properties:

suite.dir=${basedir}

 I'm getting a similar error.

 Regards

Toni

Javier Ortiz replied on Wed, 2012/01/25 - 6:09pm

I found a work around. Take a look at this article when its approved.

Matt Coleman replied on Tue, 2012/07/31 - 1:42am in response to: Toni Epple

It works now..thanks,,
web designer buffalo

Comment viewing options

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