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)

07.14.2008
| 37112 views |
  • submit to reddit

VLDocking Integration

In every possible sense, the VLDocking framework appears to be the docking framework of choice for Spring RCP. That is the case, firstly, because the VLDocking JAR is part of the Spring RCP distribution and secondly because the requisite classes for integrating VLDocking with Spring RCP are a standard part of the Spring RCP distribution too. The latter point is equally true for FlexDock (which is discussed in the next section) but, as can be seen from the screenshot in the previous section, the number of integration classes provided with the Spring RCP distribution is less than for VLDocking. On top of that, FlexDock does not appear to be undergoing active development, while VLDocking 2.1.8 was released just over a week ago.

Therefore, it makes sense to deal with VLDocking first. Let's use it to create a window layout that looks as follows:

At the same time, let's make sure that any layout changes made by the user (e.g., if the user moves some of the views to different positions) are restored upon restart of the application. How to do that? Obtain the layout from an XML file, which is a scenario supported by VLDocking.

First, in the richclient-application-context.xml:

<bean id="lifecycleAdvisor" class="simple.SimpleLifecycleAdvisor">
<property name="windowCommandBarDefinitions" value="ui/commands-context.xml" />
<property name="windowCommandManagerBeanName" value="windowCommandManager" />
<property name="menubarBeanName" value="menuBar" />
<property name="toolbarBeanName" value="toolBar" />
<property name="startingPageId" value="proxyPage" />
</bean>

<bean id="proxyPage"
class="org.springframework.richclient.application.docking.vldocking.VLDockingPageDescriptor">
<property name="initialLayout">
<bean class="org.springframework.core.io.ClassPathResource">
<constructor-arg type="java.lang.String">
<value>/layouts/vldocking.xml</value>
</constructor-arg>
</bean>
</property>
</bean>

<bean id="applicationPageFactory" depends-on="serviceLocator"
class="org.springframework.richclient.application.docking.vldocking.VLDockingApplicationPageFactory">
</bean>

 

Notice line 14 above, which assumes a project structure like this:

 

Then, define the layout in the "vldocking.xml" file as follows:

<?xml version="1.0"?>
<VLDocking version="2.1">
<DockingDesktop name="proxyPage">
<DockingPanel>
<Split orientation="1" location="0.2506361323155216">
<Dockable>
<Key dockName="NewSpringView2"/>
</Dockable>
<Split orientation="0" location="0.7484536082474227">
<TabbedDockable>
<Dockable>
<Key dockName="NewSpringView"/>
</Dockable>
<Dockable>
<Key dockName="NewSpringView1"/>
</Dockable>
</TabbedDockable>
<Dockable>
<Key dockName="NewSpringView3"/>
</Dockable>
</Split>
</Split>
</DockingPanel>
<TabGroups>
<TabGroup>
<Dockable>
<Key dockName="NewSpringView"/>
</Dockable>
<Dockable>
<Key dockName="NewSpringView1"/>
</Dockable>
</TabGroup>
</TabGroups>
</DockingDesktop>
</VLDocking>

 

Do you need to be some kind of VLDocking expert to create the above layout file? Do you need some special tools to create it? Do you need any special kind of knowledge about the above XML syntax? No. Simply run the application once, with the above layout file, and then move the views around to the positions you'd like them to be in, such as something like this:

Now switch to the Files window and look at the layout file that is in the "build" folder, as shown here:

Open that file and notice that it is DIFFERENT to the file in your own source structure. It looks like this (assuming you moved the views around as shown above):

<?xml version="1.0"?>
<VLDocking version="2.1">
<DockingDesktop name="proxyPage">
<DockingPanel>
<Split orientation="1" location="0.5012722646310432">
<Split orientation="0" location="0.5030927835051546">
<Dockable>
<Key dockName="NewSpringView"/>
</Dockable>
<Dockable>
<Key dockName="NewSpringView2"/>
</Dockable>
</Split>
<Split orientation="0" location="0.5030927835051546">
<Dockable>
<Key dockName="NewSpringView1"/>
</Dockable>
<Dockable>
<Key dockName="NewSpringView3"/>
</Dockable>
</Split>
</Split>
</DockingPanel>
<TabGroups>
</TabGroups>
</DockingDesktop>
</VLDocking>

 

In other words, the "build" folder will contain the layout of the views at the point where you close the application. So you can then copy the above layout into the layout file in your project structure and, in the process, use the application itself as the designer of its own layout!

Further reading:

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

Comments

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 http://www.assembla.com/wiki/show/biobrowser. 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.

thanks

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.