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

Getting Even Further with Spring RCP (2)

07.14.2008
| 36249 views |
  • submit to reddit

MyDoggy Integration

Peter Karich recently mentioned his MyDoggy integration, while also providing a NetBeans project containing, among other things, the integration code as well as code demonstrating how to use his integration. I extracted the MyDoggy/Spring RCP integration classes and created a separate Java library for them:

Then I put the resulting JAR on my own application's classpath and used it as described below to create a simple layout like this:

Here are the relevant MyDoggy pieces in my richclient-application-context.xml. In the first bean, notice that "startingPageId" property, which points to the "startPage" bean. In the "startPage" bean, the initial layout is defined in an external layout.xml file or (if that file is not there or if it is empty) by displaying two of the views injected by the referenced beans:

<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="startPage"/>
</bean>

<bean id="startPage" class="org.mydoggy.MyDoggyPageDescriptor">
<!-- EITHER use this file if not empty/absent: -->
<property name="initialLayout">
<bean class="org.springframework.core.io.FileSystemResource">
<constructor-arg type="java.lang.String">
<value>resources/ctx/layout.xml</value>
</constructor-arg>
</bean>
</property>
<!-- OR use these initial views: -->
<property name="viewDescriptors">
<list>
<value>NewSpringView1</value>
<value>NewSpringView2</value>
</list>
</property>
</bean>

<bean id="applicationPageFactory"
class="org.mydoggy.MyDoggyApplicationPageFactory">
</bean>

 

As indicated in line 14, there's a layout file in XML format, which follows a MyDoggy layout format:

Just like in the case of the VLDocking integration, described earlier, when you move the views in the deployed application around, the layout.xml file is regenerated. The difference is that, while in the case of VLDocking the newly generated file was found in the "build" folder, the regenerated XML file simply replaces the original file in the current version of Peter Karich's MyDoggy integration.

Note: Simply create an empty XML file, in the location and with the name defined by your equivalent of line 14 in the richclient-application-context.xml above. Then, run the application. No views will be shown because the XML file is empty. Then open some of the views. Then close the application. Now... you will see that your XML file is filled with generated code, meaning that you don't need to know anything at all about the tags that constitute the file. You should therefore never need to touch the file at all, unless you know enough about it and want to manually tweak it in some way.

In summary, Peter Karich's MyDoggy integration is really cool. Here's hoping he'll (once he's happy with it) create a project page just like the one by Jonny Wray, so that it becomes easier to get hold of the MyDoggy JAR for integration with Spring RCP.

 

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.