com.javadocking
Class DockingExecutor

java.lang.Object
  extended by com.javadocking.DockingExecutor

public class DockingExecutor
extends java.lang.Object

The docking executor is used to:

It does not only execute these actions, but it also informs the listeners of the dockable about the docking changes.

Information on using the docking executor is in How to Add, Move, and Remove Dockables in The Sanaware Developer Guide.

Author:
Heidi Rakels.

Constructor Summary
DockingExecutor()
           
 
Method Summary
 boolean changeDocking(Dockable dockable, Dock rootDock)
           Tries to dock the dockable in the tree of docks that has the given dock as root dock.
 boolean changeDocking(Dockable dockable, DockingPath dockingPath)
           Changes the docking of the dockable as good as possible with the information in the given docking path.
 boolean changeDocking(Dockable dockable, Dock destinationDock, java.awt.Point relativeLocation, java.awt.Point dockableOffset)
           Changes the docking of the dockable to the given location in the given destination dock.
 boolean changeDocking(Dockable dockable, LeafDock destinationDock, Position position)
           Changes the docking of the dockable to the given position in the given destination leaf dock.
 CompositeDock cleanDock(Dock dock, boolean ghost)
          The dock is cleaned up, if it is empty.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DockingExecutor

public DockingExecutor()
Method Detail

changeDocking

public boolean changeDocking(Dockable dockable,
                             Dock destinationDock,
                             java.awt.Point relativeLocation,
                             java.awt.Point dockableOffset)

Changes the docking of the dockable to the given location in the given destination dock. If the dockable is already docked in a different dock, the dockable is first removed.

No tests are performed, if these operations are allowed. These tests should have been done before calling this method.

First a DockableEvent is fired that informs the listeners of the dockable that the docking will change.

There are different possibilities:

Finally, a dockable event is fired that informs the listeners of the dockable that the docking has changed.

Parameters:
dockable - The dockable whose docking will be changed. Not null.
destinationDock - The dock to which the dockable will be added. Can be null, if the dockable has to be closed.
relativeLocation - The location where the dockable will be added. Can be null, if the destination dock is also null.
dockableOffset - The mouse location where the dragging started, relatively to the previous dock of the dockable. Can be null, if the destination dock is also null.
Returns:
True if the docking change was successfull, false otherwise.

changeDocking

public boolean changeDocking(Dockable dockable,
                             LeafDock destinationDock,
                             Position position)

Changes the docking of the dockable to the given position in the given destination leaf dock. If the dockable is already docked in a different dock, the dockable is first removed.

No tests are performed, if these operations are allowed. These tests should have been done before calling this method.

First a DockableEvent is fired that informs the listeners of the dockable that the docking will change.

There are different possibilities:

Finally, a dockable event is fired that informs the listeners of the dockable that the docking has changed.

Parameters:
dockable - The dockable whose docking will be changed. Not null.
destinationDock - The dock to which the dockable will be added. Can be null, if the dockable has to be closed.
position - The position where the dockable will be added. Can be null, if the destination dock is also null.
Returns:
True if the docking change was successfull, false otherwise.

changeDocking

public boolean changeDocking(Dockable dockable,
                             Dock rootDock)

Tries to dock the dockable in the tree of docks that has the given dock as root dock. The dockable will be docked in a dock that is not already full. The dockable will be docked in a position that is valid for this dockable. If the dockable is already docked in a dock, the dockable is removed, before it is added to a new dock.

If the root is a CompositeDock, it tries to add the dockable to a child tree that has a free place in a dock. If this didn't work, it tries to add the dockable to the root dock itself.

A DockableEvent is fired before and after the addition that informs the listeners of the dockable about the addition.

Parameters:
dockable - The dockable that will be docked in the dock or in one of its deeper children.
rootDock - The root of the docks where the dockable will be docked. Can be null, when the dockable only has to be removed.
Returns:
True if the dockable could be docked in the root dock or in one of its children, false otherwise.

changeDocking

public boolean changeDocking(Dockable dockable,
                             DockingPath dockingPath)

Changes the docking of the dockable as good as possible with the information in the given docking path. If the dockable is already docked in a dock, the dockable is removed, before it is added to a new dock.

If the root dock of the path is not in the dock model any more, the dockable is not added.

If the root dock of the path is still in the dock model, and there is somewhere a free place in a dock of the tree defined by this root, the dockable will always be added.

A DockableEvent is fired before and after the addition that informs the listeners of the dockable about the addition.

Parameters:
dockable - The dockable whose docking will be changed. Not null.
dockingPath - Contains the model, docks, and positions that define where the dockable should be docked. Not null.
Returns:
True if the docking change was successfull, false otherwise.

cleanDock

public CompositeDock cleanDock(Dock dock,
                               boolean ghost)
The dock is cleaned up, if it is empty.

Parameters:
dock - The dock to clean. Not null.
ghost - When true, there can be busy listeners on the dock that may not be removed. The dock may not be completely deleted. When false, the dock may be deleted, if empty.
Returns:
A dock with ghosts. Null when there are no ghosts.