Getting Even Further with Spring RCP (2)
FlexDock Integration
Let's use the FlexDock docking framework now. FlexDock, according to its site, is a docking framework for use in cross-platform Swing applications and offers features you'd expect in any desktop docking framework such as tabbed & split layouts, drag-n-drop capability, floating windows, collapsible containers, and layout persistence. (Although, I haven't figured out layout persistence yet... can someone help?)
We'll use it to create a window layout that looks as follows:
In a nutshell, you need to implement a FlexDock "PerspectiveFactory" that supplies the initial view layout and then inject it into the "ApplicationPageFactory" bean in the richclient-application-context.xml file. Here are the related snippets from the richclient-application-context.xml file:
<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" />
</bean>
<bean id="applicationPageFactory" depends-on="serviceLocator"
class="org.springframework.richclient.application.docking.flexdock.FlexDockApplicationPageFactory">
<property name="floatingEnabled" value="true" />
<property name="defaultPerspective" value="defaultPerspective" />
<property name="perspectiveFactory">
<bean class="simple.DemoPerspectiveFactory">
<property name="dockableIds">
<list>
<value>NewSpringView</value>
<value>NewSpringView1</value>
<value>NewSpringView2</value>
<value>NewSpringView3</value>
</list>
</property>
</bean>
</property>
</bean>
Note: Above we're not making use of the "startingPageId" property. Instead, we'll let the "applicationPageFactory" handle all of the layout for us. Line 13 refers to this class that I created in the "simple" package:
import java.util.List;
import org.flexdock.perspective.LayoutSequence;
import org.flexdock.perspective.Perspective;
import org.flexdock.perspective.PerspectiveFactory;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.Assert;
public class DemoPerspectiveFactory implements PerspectiveFactory, InitializingBean {
private List<String> dockableIds;
public Perspective getPerspective(String perspectiveId) {
Perspective perspective = new Perspective(perspectiveId, perspectiveId);
LayoutSequence sequence = perspective.getInitialSequence(true);
String prevDockableId = null;
for (String dockableId : this.dockableIds) {
sequence.add(dockableId, prevDockableId);
prevDockableId = dockableId;
}
return perspective;
}
public void afterPropertiesSet() throws Exception {
Assert.notEmpty(this.dockableIds, "No dockable ids specified");
}
public List<String> getDockableIds() {
return dockableIds;
}
public void setDockableIds(List<String> dockableIds) {
this.dockableIds = dockableIds;
}
}
Further reading:
- http://forum.springframework.org/showthread.php?t=32457
- http://www.nabble.com/Re:-Spring-Rich-and-FlexDock-p6425472.html
- http://article.gmane.org/gmane.comp.java.springframework.rcp.devel/3981
| Attachment | Size |
|---|---|
| figure-1.png | 13.51 KB |
| figure-2.png | 45.75 KB |
| figure-3.png | 14.14 KB |
| figure-4.png | 18.86 KB |
| figure-5.png | 13.44 KB |
| figure-6.png | 21.21 KB |
| figure-7.png | 22 KB |
| figure-8.png | 20.1 KB |
| figure-9.png | 46.98 KB |
| figure-10.png | 26.82 KB |
| figure-11.png | 105.56 KB |
| figure-12.png | 20.17 KB |
| figure-13.png | 97.26 KB |
| figure-14.png | 39.5 KB |
| figure-15.png | 27.79 KB |
| figure-16.png | 47.22 KB |
- Login or register to post comments
- 12732 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)










Comments
Peter Karich 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:
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.
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