Stacked dockable in SplitDockStation under Eclipse-Theme

Hi,

I started to used dock and I am very pleased.
Awesome and stunning job for a singled developer!

A thing I did not get to work yet (with the API-methods I considered):

I am using a SplitDockStation under the Eclispe theme and
I programmatically add two dockables.
It works with each of the following methods on SplitDockStation:

SplitDockStation.drop( Dockable dockable, SplitDockPathProperty property );
SplitDockStation.drop( Dockable dockable, SplitDockProperty property );
SplitDockStation.addDockable( Dockable dockable );
```However, I want the dockables to be stacked from the start.
But regardless of what arguments I passed in to the above
methods, the split dock station always puts the dockables
next to each other (in some way).
(In prinicipal,  I can stack the dockables manually 
using the mouse and drag&drop - but I would like to get
the stack without user interaction!)

One attempt which works "half" was:

mySplitDockStation.drop(dockable, new SplitDockProperty(0, 0, 1, 1));

it looses its displayed content and appears empty.

Does anybody know how to do it right (preferrably with
one of the above mentioned methods)?

Greetings,

Daniel
  1. Loosing the content: That’s a bug and I think only present with EclipseTheme. It should be repaired in the next preview version, which will be available within the next 7 days.
  2. drop is not always able to put the Dockable at the exact location you told with SplitDock(Path)Property. Ask the station for the exact location of the first Dockable (with the method getDockableProperty) and use the result of this method as location for the second Dockable. That should leave the station no option but to put them over each other.

Wow that was quick! I will wait for the preview then.

Maybe that will also fix another bug:
When I save the state of the SplitDockStation to file
after I stacked the related dockables (manually) and restore the
state, then there also appears zero content in the split dock station.
This happens independent of the theme, though

I save the docking state in the following way via the Swing Application framework:
(The code is a cumbersome because it bridges the persistence approach from the Swing application framework (via SessionState) and the one from DockFrontend.)


        property = new SessionStorage.Property() {
            @Override
            public Object getSessionState(Component component) {
                try {
                    ByteArrayOutputStream stream = new ByteArrayOutputStream();
                    dockFrontend.write(new DataOutputStream(stream));
                    return stream.toByteArray();
                } catch (IOException e) {
                    log.warn("Saving docking settings failed", e);
                    return null;
                }
            }

            @Override
            public void setSessionState(Component component, Object obj) {
                try {
                    ByteArrayInputStream stream = new ByteArrayInputStream(
                            (byte[]) obj);
                    dockFrontend.read(new DataInputStream(stream));
                } catch (IOException e) {
                    log.warn("Loading docking settings failed", e);
                }
            }
        };
        try {
            getContext().getSessionStorage().putProperty(
                    SplitDockStation.class, property);
            getContext().getSessionStorage().restore(mainFrame,
                    SESSION_FILE_NAME);
        } catch (Throwable e) {
            log.warn("Could not restore application's GUI state at start up.",
                    e);
        }

I

Alright, I guess you are using the newest version. The Demo applications on the homepage also load their layout with these methods, and they work.

There are no exceptions?
What is the size of the SplitDockStation, you are using a LayoutManager that does not assign a size of 0/0? (This error has happened more than once).
Do you register the Dockables, or factories for them, before loading the layout?

Could you give me a minimalistic, but compiling and running, example that has this faulty behavior?

Thanks for all those hints. I will check them all before
I reply. It may take a few days…

Just a quick update on the mentioned issues:

  • I could not reproduce the second reported problem
    in a small demo application :mad:. I also could not determine
    what the structural difference was between the small demo that should present the error and the real world application I am working on (with regard to the docking framework).
  • Still I had followed all the points that you hinted at (like “basic mistakes”) right from the start - so that was/is not the issue…
  • I tried the same with the 1.0.8-preview: The docking system runs slightly different but still seems buggy (assuming the bug is somewhre in the docking framework).
  • In 1.0.8-preview still cannot configure dockables so that they appear stacked from the start (instead of being layed out) next to each other
  • In 1.0.8-preview it seems that the feature that was formerly
    enbabled via

        dockFrontend.getDockProperties().set(EclipseTheme.PAINT_ICONS_WHEN_DESELECTED, Boolean.TRUE);

does not work anymore.

[QUOTE=Unregistered]Just a quick update on the mentioned issues:

  • I could not reproduce the second reported problem
    in a small demo application :mad:. I also could not determine
    what the structural difference was between the small demo that should present the error and the real world application I am working on (with regard to the docking framework).
  • Still I had followed all the points that you hinted at (like „basic mistakes“) right from the start - so that was/is not the issue…
  • I tried the same with the 1.0.8-preview: The docking system runs slightly different but still seems buggy (assuming the bug is somewhre in the docking framework).[/quote]
    I’ve just tried this with one of my older apps and could not reproduce the bug. At this point it could be interessting to see your whole application. Any chance of sending me a zip-file? (Maybe through mail, if you don’t want the whole world to see it).

The same answer applies to the next problem:

In 1.0.8-preview still cannot configure dockables so that they appear stacked from the start (instead of being layed out) next to each other

If I use code that looks like this one, it definitely works:

	public static void main( String[] args ){
		JFrame frame = new JFrame( "Demo" );
		DockFrontend frontend = new DockFrontend( frame );
		SplitDockStation station = new SplitDockStation();

		frame.add( station.getComponent() );
		frontend.addRoot( "station", station );

		Dockable yellow =  createDockable( "Yellow", Color.YELLOW );

		SplitDockGrid grid = new SplitDockGrid();
		grid.addDockable( 0, 0, 1, 1, createDockable( "Red", Color.RED ) );
		grid.addDockable( 0, 1, 1, 1, createDockable( "Green", Color.GREEN ) );
		grid.addDockable( 1, 0, 1, 1, createDockable( "Blue", Color.BLUE ) );
		grid.addDockable( 1, 1, 1, 1, yellow );
		station.dropTree( grid.toTree() );

		// now add a stacked dockable
		Dockable add = createDockable( "Orange", Color.ORANGE );
		station.drop( add, station.getDockableProperty( yellow ) );

		frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
		frame.setBounds( 20, 20, 400, 400 );
		frame.setVisible( true );
	}

	public static Dockable createDockable( String title, Color color ){
		JPanel panel = new JPanel();
		panel.setOpaque( true );
		panel.setBackground( color );
		return new DefaultDockable( panel, title );
	}
}
  • In 1.0.8-preview it seems that the feature […] EclipseTheme.PAINT_ICONS_WHEN_DESELECTED […] does not work anymore.

Uh, yes, that is true. That’ll be repaired soon.