Dynamically adding a CDockable to a stack

Question 1:

Given a JDialog using the common framework, I want to be able to dynamically add CDockables such that they are stacked in tabs. This would not be a one time layout. CDockables could be added at different points in time. What is the best way to go about implementing this? I am having problems adding the CDockable so that it joins the stack. Chapter 6 of the commons documentation shows an example of setting a dockable location using CGridAreaLocation, but I haven’t been able to figure out how to obtain a CGridAreaLocation.

Question 2:

If this JDialog were to be closed, is there a way to keep the externalized dockables open while closing all others? It appears that the externalized dockables close when the dialog closes.

Call CDockable.getBaseLocation() to get a CLocation-object. Then call “aside()” on this location to get a new location that is “one index higher”. Then you can call CDockable.setLocation on your second dockable, and it will lay near the first one (for most locations, “aside” means on the same stack. An exception are minimized Dockables).

To get a CGridAreaLocation you can use one of the static methods provided by CLocation, or just “new CGridAreaLocation”. You just need a reference to the grid-area where you want to drop your Dockable. That statements holds true for almost all the other implementations of CLocation as well.

For the dialog: any chance of just using another frame for the CControl? Because once the dialog for an externalized Dockable is created it remains bound to the root-window of the CControl.

To be more exact: visibility of the externalized Dockables is always the same as the root-window. But you can exchange the root-window: give the CControl a “WindowProvider” instead of a dialog/frame. There are different implementations of the interface, just take one that fits your needs. If you change the root-window from the invisible dialog to e.g. a visible frame, then the Dockables should reappear.