com.javadocking.model
Interface DockModel

All Known Implementing Classes:
DefaultDockModel, FloatDockModel

public interface DockModel

A dock model represents a collection of docks that are used in an application.

Information on using dock models is in How to Use Dock Models in The Sanaware Developer Guide.

The dock model should be given to the docking manager with the method: DockingManager.setDockModel(DockModel).

This model is a collection of trees of docks:

This dock model contains the root docks. All docks of the model have one of the root docks as root. Every root dock of the model can be retrieved with a key.

For every root dock the owner window has to be specified. If the dock is a java.awt.Component, then the root dock should be its window ancestor. If the dock is a FloatDock, then the owner is the window that will own the floating windows.

Author:
Heidi Rakels.

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.
 FloatDock getFloatDock(java.awt.Window owner)
          Gets the root dock that is the float dock of the given owner window.
 java.lang.String getFloatDockKey(java.awt.Window owner)
          Gets the key of the root dock that is a 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 ownerWindow)
          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.
 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 visualizer)
          Removes the visualizer from the dock model.
 void saveProperties(java.lang.String prefix, java.util.Properties properties, java.util.Map dockKeys)
           Saves the properties of this dock model in the given properties object.
 

Method Detail

addOwner

void addOwner(java.lang.String ownerId,
              java.awt.Window window)
Adds the specified window as owner to this dock model.

Parameters:
ownerId - The ID for the owner. All the owner window IDs have to be different.
window - The owner window.
Throws:
java.lang.IllegalArgumentException - If there is already a window with this owner ID.

getOwnerID

java.lang.String getOwnerID(java.awt.Window ownerWindow)
Gets the ID of the given owner window.

Returns:
The ID of the given owner window.

getOwnerCount

int getOwnerCount()
Gets the number of owner windows in this dock model.

Returns:
The number of owner windows in this dock model.

getOwner

java.awt.Window getOwner(int index)
Gets the owner window with the specified index in the dock model. The windows with a lower index are more to the front.

Parameters:
index - The index of the owner window to retrieve.
Returns:
The owner with the specified index in the dock model.
Throws:
java.lang.IndexOutOfBoundsException - If the index is out of range (index < 0 || index >= getOwnerCount()).

removeOwner

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

Parameters:
owner - The owner window to be removed.
Throws:
java.lang.IllegalArgumentException - If the given window is not an owner window.

addRootDock

void addRootDock(java.lang.String rootKey,
                 Dock dock,
                 java.awt.Window owner)
Adds a root dock with its key to this dock model.

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.
Throws:
java.lang.IllegalArgumentException - If the specified owner is not an owner window of this model.
java.lang.IllegalArgumentException - If the specified dock is already a root dock in the model.
java.lang.IllegalArgumentException - If the specified dock is not a root dock.

getRootKeys

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.

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.

getRootDock

Dock getRootDock(java.lang.String rootKey)
Gets the root dock of this dock model that has the given key associated to it.

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

void removeRootDock(Dock dock)
Removes the root dock from the dock model.

Parameters:
dock - The root dock to remove.
Throws:
java.lang.IllegalArgumentException - If the specified dock is not a root dock of this dock model.

addVisualizer

void addVisualizer(java.lang.String key,
                   Visualizer visualizer,
                   java.awt.Window owner)
Adds a visualizer with its key to this dock model.

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.
Throws:
java.lang.IllegalArgumentException - If the specified owner is not an owner window of this model.
java.lang.IllegalArgumentException - If the specified visualizer is already a visualizer in the model.

getVisualizerKeys

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.

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.

getVisualizer

Visualizer getVisualizer(java.lang.String key)
Gets the visualizers of this dock model that has the given key associated to it.

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.

removeVisualizer

void removeVisualizer(Visualizer visualizer)
Removes the visualizer from the dock model.

Parameters:
visualizer - The visualizer to remove.
Throws:
java.lang.IllegalArgumentException - If the specified visualizer is not a visualizer of this dock model.

getFloatDock

FloatDock getFloatDock(java.awt.Window owner)
Gets the root dock that is the float dock of the given owner window.

Parameters:
owner - The owner window of the float dock.
Returns:
The root dock that is a float dock of the given owner window. If there is no root dock that is a float dock for the specified owner, then null is returned.

getFloatDockKey

java.lang.String getFloatDockKey(java.awt.Window owner)
Gets the key of the root dock that is a float dock of the given owner window.

Parameters:
owner - The owner window of the float dock.
Returns:
The key of the root dock that is a float dock of the given owner window. If there is no root dock that is a float dock for the specified owner, then null is returned.

getSource

java.lang.String getSource()
Gets the name of the data source for this dock model; typically a file name or a URL.

Returns:
The name of the data source for this dock model; typically a file name or a URL.

loadProperties

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

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.

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

void saveProperties(java.lang.String prefix,
                    java.util.Properties properties,
                    java.util.Map dockKeys)

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.

Parameters:
prefix - The prefix for the property names.
properties - The properties object to which the properties should be added.
dockKeys - 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).