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

Getting Even Further with Spring RCP (2)

  • submit to reddit

Rolling Your Own

There are several more docking frameworks than have been discussed so far and, more than likely, the future will bring even more. For those who would like to integrate one or more of these alternative docking frameworks with Spring RCP, here's a brief introduction of what you'd need to do.

As an example, we'll use the TabbedContainer component, simply because it is very simple. The TabbedContainer component was discussed several years ago on Javalobby, by Scott Delap. One can obtain it in several ways, one of which is by downloading the JDocking framework, which is an (old) fork of parts of the NetBeans Platform. Another way is to get it from the NetBeans Platform itself, of which it is still a part, and where it also has related Javadoc. I wouldn't recommend using it instead of any of the others discussed so far, however, because the alternative docking frameworks presented earlier are more sophisticated.

At the end of this section, we'll have this very simple window layout, by integrating the TabbedContainer component as our docking framework:

Of the several classes that we could extend/implement/call, we will only focus on those that deal with application-level matters for now:

  • org.springframework.richclient.application.ApplicationPageFactory
  • org.springframework.richclient.application.ApplicationPage
  • org.springframework.richclient.application.PageDescriptor
  • org.springframework.richclient.application.ApplicationWindow

Only the two classes in the "docking" package below will be created in this section, to provide a really simple though clear example of how you'd do the same for any other docking framework:

Simply put, to start with you need to create this bean in your richclient-application-context.xml file, which refers to the factory you see in the screenshot above:

<bean id="applicationPageFactory" class="docking.TabbedContainerApplicationPageFactory"/>


...and inject it with this content:

import org.springframework.richclient.application.ApplicationPage;
import org.springframework.richclient.application.ApplicationPageFactory;
import org.springframework.richclient.application.ApplicationWindow;
import org.springframework.richclient.application.PageDescriptor;

public class TabbedContainerApplicationPageFactory implements ApplicationPageFactory {

public ApplicationPage createApplicationPage
(ApplicationWindow window, PageDescriptor descriptor) {
TabbedContainerApplicationPage page = new TabbedContainerApplicationPage(window);
return page;


And here is the "ApplicationPage" class that is referred to above:

import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;

import org.jdocking.swing.tabcontrol.DefaultTabDataModel;
import org.jdocking.swing.tabcontrol.TabData;
import org.jdocking.swing.tabcontrol.TabDataModel;
import org.jdocking.swing.tabcontrol.TabbedContainer;

import org.springframework.richclient.application.ApplicationWindow;
import org.springframework.richclient.application.PageComponent;

public class TabbedContainerApplicationPage extends AbstractApplicationPage {

private TabbedContainer tabbedContainer;
private TabDataModel tabDataModel;
private TabData tabData;
private ApplicationWindow window;

TabbedContainerApplicationPage(ApplicationWindow window) {
this.window = window;

//Called at startup.
//In this case our initial view will be an empty JPanel,
//which we use to initialize the TabData,
//which in turn is used to initialize the TabDataModel,
//which then is used in the initialization of the TabbedContainer,
//which is then added to the Spring RCP window's ContentPane:
protected JComponent createControl() {
JPanel welcomePanel =
new JPanel();
tabData =
new TabData(welcomePanel, /*icon: */ null, "Welcome!",
"This is a tooltip");
tabDataModel =
new DefaultTabDataModel(new TabData[]{tabData});
tabbedContainer =
new TabbedContainer(tabDataModel, TabbedContainer.TYPE_VIEW);
return welcomePanel;

//Called whenever a new view is opened:
protected void doAddPageComponent(PageComponent pageComponent) {
//From the PageComponent, get the view's content:
JPanel content = (JPanel) pageComponent.getControl();
//From the PageComponent, get the view's display name:
String name = pageComponent.getDisplayName();
//From the PageComponent, get the view's icon:
Icon icon = pageComponent.getIcon();
//Initialize a new TabData, with the retrieved items above:
tabData = new TabData(content, icon, name, "This is a tooltip");
//Add the TabData to the TabDataModel:
tabDataModel.addTab(/*position: */1, tabData);

//Called for each view that is open,
//when the application closes:
protected void doRemovePageComponent(PageComponent arg0) {

//Called to give focus to something:
protected boolean giveFocusTo(PageComponent pageComponent) {
return pageComponent.getControl().requestFocusInWindow();



One tweak in line 41 above:

new TabbedContainer(tabDataModel, TabbedContainer.TYPE_EDITOR);


...and the code will result in a slightly different layout, together with a control on the right hand side for flipping through the open views:

Another tweak in line 41...

new TabbedContainer(tabDataModel, TabbedContainer.TYPE_TOOLBAR);


...and you have buttons instead of tabs for switching between the views:

One can see that, though the TabbedContainer component is quite simple (it doesn't provide the typical support common to docking frameworks, such as dock/undock, maximize/minimize, etc), it's quite useful in presenting the main aspects of docking integration with Spring RCP. The earlier integrations (VLDocking, FlexDock, JIDE, and MyDoggy) illustrate that you can go a lot further and provide features on lower levels, i.e., above we have only looked at application-level docking, while we could, in addition, provide specific features on the level of individual windows within the application, such as whether/not a window can be docked/undocked, maximized/minimized, etc. Lessons relating to these aspects can be extrapolated from the source code of the other integrations and will be discussed in another instalment of this series.



We've covered the integration of several docking frameworks with Spring RCP. VLDocking and FlexDock are officially supported by Spring RCP. In fact, the VLDocking JAR is part of the Spring RCP distribution, although FlexDock seems to not be under active development anymore. One can conclude that VLDocking is the docking framework of choice when it comes to providing a windowing system for applications built on top of the Spring RCP. However, both JIDE and MyDoggy are well represented by Jonny Wray and Peter Karich and I believe both are in a very good position to be integrated. Other frameworks, including the NetBeans Platform, via its TopComponents, should also be integratable (which I'll discuss in an article soon, hopefully), via the classes that I introduced in the final section of this article.

Spring RCP clearly presents a very versatile approach: you can pick and choose whichever docking framework works best for you and then bolt it onto you Spring RCP application without too much trouble. I hope this article has given a relatively solid introduction, with starting points for further exploration via the further reading suggestions and links within the various sections.

Published at DZone with permission of its author, Geertjan Wielenga.


Peter Karussell replied on Tue, 2008/07/15 - 5:29pm

Hi Geertjan,

this was a great effort! To compare all the stuff.

I have some additional information:

  • There is one more 'important' docking framework: swing dockings! You can find some screenshots here and here (Swing-Docking requires jre1.6).
    Why is this an 'important' one? Because it will be integrated into SpringRC 1.0.1 and it is Apache 2.0 licensed (see this jira issue). And of course it looks good :-)
  • For MyDoggy we should thank the author Angelo De Caro for his work! What I didn't mentioned in my post: MyDoggy even supports perspectives (via groups) like in Eclipse. And the latest version of the integration does not require to create an empty xml file. And now the initial view (no layout.xml) should contain the views specified in the xml ...

    Hopefully my jira issue for the integration will be accepted.

  • Some raw comments for the MyDoggy-SpringRC-integration you can find here.

Jonny Wray replied on Wed, 2008/07/16 - 1:32am

Hi Geertjan,

thanks for a great article. The example of swaping out docking implementations via simple changes in the configuration code is a good one for highlighting the power of the Spring RCP approach.

Just to address a couple of points raised with the JIDE integration. Your point about making the jars available is well taken and I should do this. I initially held off until a stable release of SRCP was produced but now that's done I've no excuse.

Also, I realise the google web service example isn't the best one since they've stopped giving out keys and may well stop the service. Also, the use of JNDI embedded browser makes it a little hard to run. That was one of my motivations behind a revamp of my biobrowser application which also serves as an example of Spring RCP with JIDE. It is fully open source and is available from subversion or as a web start launch at the project page If anyone tries it note that the wiki has an 'Instructions' subpage which has an illustrated guide to its use, as it assumes a bit of domain knowledge otherwise.


Jonny Wray

Geertjan Wielenga replied on Thu, 2008/07/17 - 3:29am

Hi Peter and Jonny! Thanks so much for your support and the interesting additional comments. All this stuff is really interesting isn't it.

Comment viewing options

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