com.javadocking.model
Class DefaultDockingPath

java.lang.Object
  extended by com.javadocking.model.DefaultDockingPath
All Implemented Interfaces:
DockingPath

public class DefaultDockingPath
extends java.lang.Object
implements DockingPath

This is the default implementation for a docking path.

Author:
Heidi Rakels.

Constructor Summary
DefaultDockingPath()
          Constructs a docking path, which is not initialized.
DefaultDockingPath(java.lang.String id, java.lang.String rootDockKey, Dock[] docks, Position[] positions)
          Constructs a docking path with the given properties.
 
Method Summary
static DefaultDockingPath copyDockingPath(Dockable dockableForPath, DockingPath dockingPathToCopy)
          Creates a docking path for the given dockable, that is almost a copy of the given docking path.
static DefaultDockingPath copyDockingPath(java.lang.String id, DockingPath dockingPathToCopy)
          Creates a docking path for the given id, that is almost a copy of the given docking path.
static DefaultDockingPath createDockingPath(Dockable dockable)
          Creates a docking path with the information how the given dockable is docked now in the dock model of the docking manager.
 boolean equals(java.lang.Object object)
          Returns true if the given object is a DockingPath with the same ID as this docking path.
 Dock getDock(int index)
           Gets the dock with the given index in the path.
 int getDockCount()
          Gets the number of docks in the path.
 java.lang.String getID()
          Gets the ID of this docking path.
 Position getPositionInDock(int index)
          Gets the position of the dockable or child dock in the dock with the given index in the path.
 java.lang.String getRootDockKey()
          Gets the key of the root dock of this path in the DockModel.
 int hashCode()
           
 void loadProperties(java.lang.String prefix, java.util.Properties properties, java.util.Map idDockMap)
           Loads the properties for this docking path.
 void saveProperties(java.lang.String prefix, java.util.Properties properties, java.util.Map dockIds)
           Saves the properties of this docking path in the given properties object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDockingPath

public DefaultDockingPath()
Constructs a docking path, which is not initialized.


DefaultDockingPath

public DefaultDockingPath(java.lang.String id,
                          java.lang.String rootDockKey,
                          Dock[] docks,
                          Position[] positions)
Constructs a docking path with the given properties.

Parameters:
id - The ID of the docking path.
rootDockKey - The key of the root dock of this path.
docks - The docks of the path. The dock with index 0 is the root dock. Cannot be null.
positions - The positions of the docks or the in this path. Cannot be null. The last position can be the position of a dockable in a leaf dock.
Throws:
java.lang.IllegalArgumentException - If the lengths of the given array of docks and the given array of positions are different.
java.lang.NullPointerException - If one of the docks or one of the positions in the array is null.
Method Detail

createDockingPath

public static DefaultDockingPath createDockingPath(Dockable dockable)
Creates a docking path with the information how the given dockable is docked now in the dock model of the docking manager. The ID of the docking path is the ID of the dockable.

Parameters:
dockable - The dockable for which a docking path is created about its current position in a dock model. This may not be a composite dockable.
Returns:
The docking path with the information how the given dockable is docked now in the dock model.
Throws:
java.lang.IllegalArgumentException - If the dockable is not docked in a dock, or if the dockable does not belong to the given dock model.
java.lang.IllegalArgumentException - If the given dockable is a composite dockable.

copyDockingPath

public static DefaultDockingPath copyDockingPath(Dockable dockableForPath,
                                                 DockingPath dockingPathToCopy)
Creates a docking path for the given dockable, that is almost a copy of the given docking path. Only the ID of the docking path will be different.

Parameters:
dockableForPath - The dockable for which a docking path is created. This may not be a composite dockable.
dockingPathToCopy - The docking path that will be used to create a new path.
Returns:
The docking path with the information how the given dockable has to be docked in the dock model.
Throws:
java.lang.IllegalArgumentException - If there does not exist a path in the docking path model of the docking manager for the dockable whose path is used.
java.lang.IllegalArgumentException - If one of the given dockables is a composite dockable.

copyDockingPath

public static DefaultDockingPath copyDockingPath(java.lang.String id,
                                                 DockingPath dockingPathToCopy)
Creates a docking path for the given id, that is almost a copy of the given docking path. Only the ID of the docking path will be different.

Parameters:
id - The id for the path.
dockingPathToCopy - The docking path that will be used to create a new path.
Returns:
The docking path with the information how the given dockable has to be docked in the dock model.
Throws:
java.lang.IllegalArgumentException - If there does not exist a path in the docking path model of the docking manager for the dockable whose path is used.
java.lang.IllegalArgumentException - If one of the given dockables is a composite dockable.

getID

public java.lang.String getID()
Description copied from interface: DockingPath
Gets the ID of this docking path. A docking path usually describes the position of a Dockable in a DockModel. The ID of this docking path can be the ID of this dockable, but this is not obligatory.
WARNING: All the docking paths used in an application should have a different ID.

Specified by:
getID in interface DockingPath
Returns:
The ID of the docking path. Not null.

getRootDockKey

public java.lang.String getRootDockKey()
Description copied from interface: DockingPath
Gets the key of the root dock of this path in the DockModel. The path belongs to a dock tree. This key defines the root of this tree in the dock model.

Specified by:
getRootDockKey in interface DockingPath
Returns:
The key of the root dock of this path. Not null.

getPositionInDock

public Position getPositionInDock(int index)
Description copied from interface: DockingPath
Gets the position of the dockable or child dock in the dock with the given index in the path.

Specified by:
getPositionInDock in interface DockingPath
Parameters:
index - The index of the dock in the path.
Returns:
The position of the dock with index index + 1 in the dock with index index if the given index is smaller than getDockCount() - 1. The last position is usually the position of the dockable in the deepest dock of the path, if this deepest dock is a leaf dock. Not null.

getDock

public Dock getDock(int index)
Description copied from interface: DockingPath

Gets the dock with the given index in the path.

The root dock has index 0. The dock with index getDockCount() - 1 can be a LeafDock, but this is not obligatory. The other docks are CompositeDocks.

Specified by:
getDock in interface DockingPath
Parameters:
index - The index of the dock in the path.
Returns:
The dock with the given index in the path. Not null.

getDockCount

public int getDockCount()
Description copied from interface: DockingPath
Gets the number of docks in the path. Can be 0.

Specified by:
getDockCount in interface DockingPath
Returns:
The number of docks in the path.

saveProperties

public void saveProperties(java.lang.String prefix,
                           java.util.Properties properties,
                           java.util.Map dockIds)
Description copied from interface: DockingPath

Saves the properties of this docking path in the given properties object.

The property names for this docking path should start with the given prefix.

Specified by:
saveProperties in interface DockingPath
Parameters:
prefix - The prefix for the property names.
properties - The properties object to which the properties should be added.
dockIds - A mapping between the docks that are already saved and the keys that are used for the save.
  • map key: a dock that is already saved (Dock).
  • map value: the key that is used for saving the dock (java.lang.String).

loadProperties

public void loadProperties(java.lang.String prefix,
                           java.util.Properties properties,
                           java.util.Map idDockMap)
Description copied from interface: DockingPath

Loads the properties for this docking path. The properties can be found in the given properties object and the property names start with the given prefix.

The docks that should be used inside this docking path can be found in the given docks mapping.

This method should be called after the empty constructor to create the content of the docking path. Don't call this method for a docking path that already has a content.

Specified by:
loadProperties in interface DockingPath
Parameters:
prefix - The prefix of the names of the properties that have been intended for this docking path.
properties - The properties object that contains the properties for this docking path. It can contain also properties for other objects, but they will have another prefix.
idDockMap - A mapping between the dock keys of the docks that are already loaded and the docks.
  • map key: the key that is used for saving the dock (java.lang.String).
  • map value: a dock that is already loaded (Dock).

equals

public boolean equals(java.lang.Object object)
Returns true if the given object is a DockingPath with the same ID as this docking path.

Overrides:
equals in class java.lang.Object
Parameters:
object -
Returns:
True if the given object is a DockingPath with the same ID as this docking path, false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object