« prev next »
Java Docking Home> Developer Guide> How to Use Docking Paths

How to Use Docking Paths

:: Keeping the history about a dockable in a docking path ::

When you don't need a dockable anymore, you can close it. It will be removed from the dock model. It is possible that, later, you want to display the content of the dockable again. Normally you want to put the dockable again, where it was, when it was removed. This is possible by using DockingPaths. A docking path keeps all the information about, where the dockable is in a dock model.

		DockingPath dockingPath = DefaultDockingPath.createDockingPath(dockable, dockModel);

:: Docking Path Model ::

The DockingPathModel of the DockingManager will keep track of all your docking paths:

		DockingPathModel dockingPathModel = DockingManager.getDockingPathModel();
Add all your docking paths to the docking path model:

:: Dockable State Action ::

When you close a dockable with a DefaultDockableStateAction a docking path will be created. It contains the information, where the dockable is docked now in the dock model. This docking path is added to the docking path model of the docking manager. When the dockable is restored with a dockable state action, it will be docked as good as possible where it was docked before.

			closeAction = new DefaultDockableStateAction(dockable, DockableState.CLOSED);
			restoreAction = new DefaultDockableStateAction(dockable, DockableState.NORMAL);
			// Close the dockable.
			closeAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Close"));
			// Restore the dockable.
			restoreAction.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "Restore"));

When you want to use the restore action for a dockable that was not already docked in the dock model, you have to create a docking path for the dockable by your self. You can create that docking path by using the positions of a dockable that is already docked in the dock model.

			// Add the path of the dockables that are not docked already.
			// We want dockable 5 to be docked, when it is made visible, where dockable 1 is docked.
			DockingPath dockingPathToCopy1 = DockingManager.getDockingPathModel().getDockingPath(dockable1.getID());
			DockingPath dockingPath5 = DefaultDockingPath.copyDockingPath(dockable5, dockingPathToCopy1);

The source code of the samples can be found in:

CodecExampleShows the usage, encoding and decoding of dock models.
WorkspaceExampleShows the usage, the encoding, and the decoding of dock models.

« prev next »