com.javadocking.model
Class DefaultDockModel

java.lang.Object
  extended by com.javadocking.model.DefaultDockModel
All Implemented Interfaces:
DockModel
Direct Known Subclasses:
FloatDockModel

public class DefaultDockModel
extends java.lang.Object
implements DockModel

This is a basic dock model implementation.

Author:
Heidi Rakels.

Constructor Summary
DefaultDockModel()
          Constructs a dock model.
DefaultDockModel(java.lang.String source)
          Constructs a dock model with the given source.
 
Method Summary
 void addOwner(java.lang.String ownerId, java.awt.Window window)
          Adds the specified window as owner to this dock model.
 void addRootDock(java.lang.String rootKey, Dock dock, java.awt.Window owner)
          Adds a root dock with its key to this dock model.
 void addVisualizer(java.lang.String key, Visualizer visualizer, java.awt.Window owner)
          Adds a visualizer with its key to this dock model.
 java.util.Set getFloatDockKeys(java.awt.Window owner)
          Gets the keys of the root docks that are float dock of the given owner window.
 java.awt.Window getOwner(int index)
          Gets the owner window with the specified index in the dock model.
 int getOwnerCount()
          Gets the number of owner windows in this dock model.
 java.lang.String getOwnerID(java.awt.Window owner)
          Gets the ID of the given owner window.
 Dock getRootDock(java.lang.String rootKey)
          Gets the root dock of this dock model that has the given key associated to it.
 java.util.Iterator getRootKeys(java.awt.Window owner)
          Gets an iterator that iterates over the keys of all the root docks of the given owner window.
 java.lang.String getSource()
          Gets the name of the data source for this dock model; typically a file name or a URL.
 Visualizer getVisualizer(java.lang.String key)
          Gets the visualizers of this dock model that has the given key associated to it.
 java.util.Iterator getVisualizerKeys(java.awt.Window owner)
          Gets an iterator that iterates over the keys of all the visualizers of the given owner window.
 boolean isLoadOwnerRectangle()
          Determines if the position and size of every owner window of a dock model are decoded and the properties are set on the owner window of the dock model.
 void loadProperties(java.lang.String sourceName, java.lang.String prefix, java.util.Properties properties, java.util.Map dockablesMap, java.util.Map ownersMap, java.util.Map docksMap, java.util.Map visualizersMap)
           Loads the properties for this dock model.
 void removeOwner(java.awt.Window owner)
          Removes the specified window as owner from this dock model.
 void removeRootDock(Dock dock)
          Removes the root dock from the dock model.
 void removeVisualizer(Visualizer visualizerToRemove)
          Removes the visualizer from the dock model.
 void saveProperties(java.lang.String prefix, java.util.Properties properties, java.util.Map docks)
           Saves the properties of this dock model in the given properties object.
 void setLoadOwnerRectangle(boolean loadFrameRectangle)
          Sets if the position and size of every owner window of a dock model are decoded and the properties are set on the owner window of the dock model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDockModel

public DefaultDockModel()
Constructs a dock model.


DefaultDockModel

public DefaultDockModel(java.lang.String source)
Constructs a dock model with the given source.

Parameters:
source - The name of the data source for this dock model; typically a file name or a URL.
Method Detail

getSource

public java.lang.String getSource()
Description copied from interface: DockModel
Gets the name of the data source for this dock model; typically a file name or a URL.

Specified by:
getSource in interface DockModel
Returns:
The name of the data source for this dock model; typically a file name or a URL.

addOwner

public void addOwner(java.lang.String ownerId,
                     java.awt.Window window)
Description copied from interface: DockModel
Adds the specified window as owner to this dock model.

Specified by:
addOwner in interface DockModel
Parameters:
ownerId - The ID for the owner. All the owner window IDs have to be different.
window - The owner window.

getOwnerID

public java.lang.String getOwnerID(java.awt.Window owner)
Description copied from interface: DockModel
Gets the ID of the given owner window.

Specified by:
getOwnerID in interface DockModel
Returns:
The ID of the given owner window.

getOwnerCount

public int getOwnerCount()
Description copied from interface: DockModel
Gets the number of owner windows in this dock model.

Specified by:
getOwnerCount in interface DockModel
Returns:
The number of owner windows in this dock model.

getOwner

public java.awt.Window getOwner(int index)
Description copied from interface: DockModel
Gets the owner window with the specified index in the dock model. The windows with a lower index are more to the front.

Specified by:
getOwner in interface DockModel
Parameters:
index - The index of the owner window to retrieve.
Returns:
The owner with the specified index in the dock model.

removeOwner

public void removeOwner(java.awt.Window owner)
Description copied from interface: DockModel
Removes the specified window as owner from this dock model. The root docks that correspond with this owner are also removed.

Specified by:
removeOwner in interface DockModel
Parameters:
owner - The owner window to be removed.

addRootDock

public void addRootDock(java.lang.String rootKey,
                        Dock dock,
                        java.awt.Window owner)
Description copied from interface: DockModel
Adds a root dock with its key to this dock model.

Specified by:
addRootDock in interface DockModel
Parameters:
rootKey - The key for the root dock. These keys should be different for all root docks and visualizers.
dock - The root dock that is added.
owner - The window that owns this dock.

getRootDock

public Dock getRootDock(java.lang.String rootKey)
Description copied from interface: DockModel
Gets the root dock of this dock model that has the given key associated to it.

Specified by:
getRootDock in interface DockModel
Parameters:
rootKey - The key of the root dock that is retrieved.
Returns:
The root dock of this dock model that has the given key associated to it. If there is no root dock for this key, null is returned.

removeRootDock

public void removeRootDock(Dock dock)
Description copied from interface: DockModel
Removes the root dock from the dock model.

Specified by:
removeRootDock in interface DockModel
Parameters:
dock - The root dock to remove.

getRootKeys

public java.util.Iterator getRootKeys(java.awt.Window owner)
Description copied from interface: DockModel
Gets an iterator that iterates over the keys of all the root docks of the given owner window.

Specified by:
getRootKeys in interface DockModel
Returns:
An iterator that iterates over the keys of all the root docks of the given owner window. The entries of the iterator are java.lang.String objects.

addVisualizer

public void addVisualizer(java.lang.String key,
                          Visualizer visualizer,
                          java.awt.Window owner)
Description copied from interface: DockModel
Adds a visualizer with its key to this dock model.

Specified by:
addVisualizer in interface DockModel
Parameters:
key - The key for the visualizer. These keys should be different for all root docks and visualizers.
visualizer - The visualizer that is added.
owner - The window that owns this visualizer.

getVisualizer

public Visualizer getVisualizer(java.lang.String key)
Description copied from interface: DockModel
Gets the visualizers of this dock model that has the given key associated to it.

Specified by:
getVisualizer in interface DockModel
Parameters:
key - The key of the visualier that is retrieved.
Returns:
The visualizer of this dock model that has the given key associated to it. If there is no visualier for this key, null is returned.

getVisualizerKeys

public java.util.Iterator getVisualizerKeys(java.awt.Window owner)
Description copied from interface: DockModel
Gets an iterator that iterates over the keys of all the visualizers of the given owner window.

Specified by:
getVisualizerKeys in interface DockModel
Returns:
An iterator that iterates over the keys of all the visualizers of the given owner window. The entries of the iterator are java.lang.String objects.

removeVisualizer

public void removeVisualizer(Visualizer visualizerToRemove)
Description copied from interface: DockModel
Removes the visualizer from the dock model.

Specified by:
removeVisualizer in interface DockModel
Parameters:
visualizerToRemove - The visualizer to remove.

getFloatDockKeys

public java.util.Set getFloatDockKeys(java.awt.Window owner)
Description copied from interface: DockModel
Gets the keys of the root docks that are float dock of the given owner window.

Specified by:
getFloatDockKeys in interface DockModel
Parameters:
owner - The owner window of the float docks.
Returns:
The keys of the root docks that are float docks of the given owner window. If there are no keys, an empty set is returned.

loadProperties

public void loadProperties(java.lang.String sourceName,
                           java.lang.String prefix,
                           java.util.Properties properties,
                           java.util.Map dockablesMap,
                           java.util.Map ownersMap,
                           java.util.Map docksMap,
                           java.util.Map visualizersMap)
                    throws java.io.IOException
Description copied from interface: DockModel

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

The dockables that should be docked in this dock model are added to this dock model. They can be found in the given dockables mapping. The owner windows with their IDs can be found in the given owners mapping.

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

Specified by:
loadProperties in interface DockModel
Parameters:
sourceName - The name of a data source; typically a file name or a URL.
prefix - The prefix for the property names.
properties - The properties object that contains the properties for this dock model. It can contain also properties for other objects, but they will have another prefix.
dockablesMap - A map with the dockables for the model.
  • map key: the ID of the dockable (java.lang.String).
  • map value: the dockable (Dockable).
ownersMap - A map with the owner windows.
  • map key: the ID of the owner window (java.lang.String).
  • map value: the owner window (java.awt.window).
docksMap - The decoded docks should be added to this map. The keys are the keys that were used for encoding 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).
visualizersMap - A map with the visualizers.
  • map key: the key of the visualizer (java.lang.String).
  • map value: the visualizer (java.awt.window).
Throws:
java.io.IOException - If an error occurs while decoding the data.

saveProperties

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

Saves the properties of this dock model in the given properties object.

The property names for this dock model should start with the given prefix.

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

isLoadOwnerRectangle

public boolean isLoadOwnerRectangle()
Determines if the position and size of every owner window of a dock model are decoded and the properties are set on the owner window of the dock model.

Returns:
True if the position and size of every owner window of a dock model are decoded and the properties are set on the owner window of the dock model.

setLoadOwnerRectangle

public void setLoadOwnerRectangle(boolean loadFrameRectangle)
Sets if the position and size of every owner window of a dock model are decoded and the properties are set on the owner window of the dock model.

Parameters:
loadFrameRectangle - True if the position and size of every owner window of a dock model are decoded and the properties are set on the owner window of the dock model.