Integrate MyDoggy in Spring Rich Client 1.0.0

I did some basic introduction to SpringRC here and here.

Now it is time to leave the basics and hack into the details of the ‘gui architecture’ in Spring RC 1.0.0. So this more technical article is not really important for the ‘normal developer’ – only those who want to integrate its own docking framework.

To see a fully working example in action go to the resource section and load it down ;-)

I started the MyDoggy integration to avoid licensing issues with vldocking and jide, which are currently integrated into Spring RC. Another option would be flexdock, but this project is inactive since a long time. It would be great to see the integration of some more docking frameworks. Swing-Docking will be included in SpringRC 1.0.1, see this jira issue for more information.

To use the MyDoggy integration you will need at least Java 5 and the upcoming MyDoggy 1.5.0 (included in the example). This version offers much more features, which won’t be used from my integration.

I simply looked into the source code of vldocking to get started with MyDoggy. This code is located in the spring-rich-client-docking folder. The necessary classes were:

  1. MyDoggyApplicationPage extends AbstractApplicationPage
    From this class we normally have one instance (the JFrame) and we can add views to this page (south, north, …). For MyDoggy we will need only one view, but several Contents (the MyDoggy-term for PageComponent). Those components will have one header, where we can drag & dock them.
  2. MyDoggyApplicationPageFactory implements ApplicationPageFactory
    This class creates one instance of our MyDoggyApplicationPage and loads the layout from the xml file if possible.
  3. MyDoggyPageDescriptor extends MultiViewPageDescriptor
    With this class we can specify properties to create the page. In MyDoggy we will need to specify the xml file here only (as a Resource)

(Please keep in mind: in my implementation the SpringRC’s-specific terms ‘View’ and ‘PageComponent’ have the same meaning and are equivalent to the MyDoggy specifc term ‘Content’)

For all docking frameworks the ApplicationPage is the most important class. For a standalone usage you will create a JFrame and set the special layout manager. For SpringRC you can do this via implementing the following method of the ApplicationPage implementation and return the root component

protected JComponent createControl() {
 rootComponent = new JPanel();
 rootComponent.setLayout(new ExtendedTableLayout(new double[][]{{0, -1, 0}, {0, -1, 0}}));
 rootComponent.add(toolWindowManager, "1,1,");
 return rootComponent;

Put the rest of all the initialization (toolWindowManger etc.) in the constructor of ApplicationPage.

If you remove a the root component (normally on an application shudown) you want to save the layout. So, you need to implement the close method

public boolean close() {
  try { saveLayout(); } catch (IOException ex) { }
  return super.close(); }

The entry point to create a PageComponent is

protected void doAddPageComponent(PageComponent pageComponent)

For MyDoggy I added the created Content to the contentManager object.

I don’t know if the following code in doAddPageComponent is necessary, but the comment made it important:

   // trigger the createControl method of the PageComponent, so if a
   // PageComponentListener is added
   // in the createControl method, the componentOpened event is received.

Now we should revert the doAddPageComponent stuff in the following method

protected void doRemovePageComponent(PageComponent pageComponent) {
   contentManager.removeContent(e.getKey()); ... }

As one of the last steps we should inform SpringRC of MyDoggy-specific events like removing (closing a Content)

private class MyDoggyContentListener implements ContentManagerUIListener {
        public boolean contentUIRemoving(ContentManagerUIEvent cmEvent) {
            Content content = cmEvent.getContentUI().getContent();
            PageComponent pc = getPageComponent(content.getId());
            return false;
        public void contentUIDetached(ContentManagerUIEvent cmEvent) {}    }

Do not forget to register this listener in your docking framework

contentManagerUI.addContentManagerUIListener(new MyDoggyContentListener());


  • Another older, but very good tutorial is located here.
  • Here you can download the project (12.07.2008) with all the necessary jars. It is a NetBeans 6.1 project, so you can simply copy all spring-rc jars into the lib folder and open the project with NetBeans. Then resolve references via right click or change the references directly; in nbproject/
About these ads

2 thoughts on “Integrate MyDoggy in Spring Rich Client 1.0.0

  1. Hi,

    In number 2. (MyDoggyApplicationPageFactory extends ApplicationPageFactory)
    Instead of “extends” use “implements”.

    Cheers !

Comments are closed.