com.javadocking.dockable
Class DefaultCompositeDockable

java.lang.Object
  extended by com.javadocking.dockable.DefaultCompositeDockable
All Implemented Interfaces:
CompositeDockable, Dockable

public class DefaultCompositeDockable
extends java.lang.Object
implements CompositeDockable

The default composite dockable implementation that keeps its dockables in an array.

Its content component, title, icon and actions are null.

Author:
Heidi Rakels.

Constructor Summary
DefaultCompositeDockable(Dockable[] dockablesArray)
           Constructs a composite dockable with the given array of dockables.
DefaultCompositeDockable(Dockable[] dockablesArray, int selectedIndex)
           Constructs a composite dockable with the given array of dockables.
 
Method Summary
 void addDockingListener(DockingListener listener)
          Adds a listener for docking events of this dockable.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a java.beans.PropertyChangeListener.
 boolean equals(java.lang.Object object)
          Returns true if the given object is a Dockable with the same ID as this dockable.
 void fireDockingChanged(DockableEvent dockableEvent)
          Notifies all listeners that have registered interest for notification on this event type.
 void fireDockingWillChange(DockableEvent dockableEvent)
          Notifies all listeners that have registered interest for notification on this event type.
 javax.swing.Action[][] getActions()
          Always returns null.
 java.awt.Component getContent()
          Always returns null.
 java.lang.String getDescription()
          Always returns null.
 LeafDock getDock()
          Gets the dock in which the dockable is docked.
 Dockable getDockable(int index)
          Gets the child dockable with the specified index.
 int getDockableCount()
          Gets the number of child dockables of this composite dockable.
 int getDockingModes()
           Calculates the docking modes with the values of the child dockables by using a bitwise and-operation.
 javax.swing.Icon getIcon()
          Always returns null.
 java.lang.String getID()
           Generates an ID with the IDs of the child dockables (separated by a space).
 int getLastDockingMode()
           The default value is taken from the first child dockable.
 int getPossibleStates()
           Gets the possible states of the dockable.
 Dockable getSelectedDockable()
          Gets the selected dockable.
 int getSelectedIndex()
          Gets the index of the selected dockable.
 int getState()
          Gets the state of the dockable.
 java.lang.String getTitle()
          Always returns null.
 java.lang.Object getVisualizer()
          Gets the object that currently shows the content of the dockable.
 int hashCode()
           
 boolean isWithHeader()
          Always returns true.
 void removeDockingListener(DockingListener listener)
          Removes a listener for docking events of this dockable.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a java.beans.PropertyChangeListener.
 void setDock(LeafDock dock)
          Sets the dock in which the dockable is docked.
 void setLastDockingMode(int lastDockingMode)
          Sets the mode how the dockable is docked in its current dock or how it was docked the last time it was in a dock.
 void setPossibleStates(int possibleStates)
          Sets the possible states of the dockable.
 void setSelectedIndex(int selectedIndex)
          Sets the index of the selected dockable.
 void setState(int state, java.lang.Object visualizer)
           Tries to set the new state of the dockable.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultCompositeDockable

public DefaultCompositeDockable(Dockable[] dockablesArray)

Constructs a composite dockable with the given array of dockables.

No dockable will be selected.

Parameters:
dockablesArray - The array of dockables for the composite dockable.

DefaultCompositeDockable

public DefaultCompositeDockable(Dockable[] dockablesArray,
                                int selectedIndex)

Constructs a composite dockable with the given array of dockables.

The dockable with the given index will be selected.

Parameters:
dockablesArray - The array of dockables for the composite dockable.
selectedIndex - The index of the selected dockable in the given array.
Method Detail

getDockable

public Dockable getDockable(int index)
                     throws java.lang.IndexOutOfBoundsException
Description copied from interface: CompositeDockable
Gets the child dockable with the specified index.

Specified by:
getDockable in interface CompositeDockable
Returns:
The child dockable with the specified index.
Throws:
java.lang.IndexOutOfBoundsException - If the index is out of range (index < 0 || index >= getDockableCount()).

getDockableCount

public int getDockableCount()
Description copied from interface: CompositeDockable
Gets the number of child dockables of this composite dockable.

Specified by:
getDockableCount in interface CompositeDockable
Returns:
The number of child dockables of this composite dockable.

getSelectedDockable

public Dockable getSelectedDockable()
Description copied from interface: CompositeDockable
Gets the selected dockable. This dockable should be one of the child dockables. If no dockable is selected, null is returned.

Specified by:
getSelectedDockable in interface CompositeDockable
Returns:
The selected dockable. Null if no dockable is selected.

getID

public java.lang.String getID()

Generates an ID with the IDs of the child dockables (separated by a space).

Specified by:
getID in interface Dockable
Returns:
The ID of the dockable.

getContent

public java.awt.Component getContent()
Always returns null. This dockable does not have a content component. It contains multiple dockables. Each dockable has it's own content.

Specified by:
getContent in interface Dockable
Returns:
Always null.

setDock

public void setDock(LeafDock dock)
Description copied from interface: Dockable
Sets the dock in which the dockable is docked.

Specified by:
setDock in interface Dockable
Parameters:
dock - The dock in which the dockable is docked. This can be null, if the dockable is not docked.

getDock

public LeafDock getDock()
Description copied from interface: Dockable
Gets the dock in which the dockable is docked.

Specified by:
getDock in interface Dockable
Returns:
The dock in which the dockable is docked. This can be null, if the dockable is not docked.

getTitle

public java.lang.String getTitle()
Always returns null.

Specified by:
getTitle in interface Dockable
Returns:
Always null.

getDescription

public java.lang.String getDescription()
Always returns null.

Specified by:
getDescription in interface Dockable
Returns:
Always null.

getIcon

public javax.swing.Icon getIcon()
Always returns null.

Specified by:
getIcon in interface Dockable
Returns:
Always null.

getDockingModes

public int getDockingModes()

Calculates the docking modes with the values of the child dockables by using a bitwise and-operation.

When there are no child dockables, DockingMode.ALL is returned.

Specified by:
getDockingModes in interface Dockable
Returns:
The possible docking modes of the dockable. This integer should be combination of constants defined by DockingMode.

setLastDockingMode

public void setLastDockingMode(int lastDockingMode)
Description copied from interface: Dockable
Sets the mode how the dockable is docked in its current dock or how it was docked the last time it was in a dock.

Specified by:
setLastDockingMode in interface Dockable
Parameters:
lastDockingMode - The mode how the dockable is docked in its current dock or how it was docked the last time it was in a dock. This integer should be a constant defined by DockingMode.

getLastDockingMode

public int getLastDockingMode()

The default value is taken from the first child dockable. Typically, the last docking modes of all the child dockables are the same.

Specified by:
getLastDockingMode in interface Dockable
Returns:
The mode how the dockable is docked in its current dock or how it was docked the last time it was in a dock. This integer should be a constant defined by DockingMode.

isWithHeader

public boolean isWithHeader()
Always returns true.

Specified by:
isWithHeader in interface Dockable
Returns:
Always true.

getActions

public javax.swing.Action[][] getActions()
Always returns null.

Specified by:
getActions in interface Dockable
Returns:
Always null.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: Dockable
Adds a java.beans.PropertyChangeListener. The listener is registered for the dock property.

Specified by:
addPropertyChangeListener in interface Dockable
Parameters:
listener - The property change listener to be added.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: Dockable
Removes a java.beans.PropertyChangeListener. This removes a listener.

Specified by:
removePropertyChangeListener in interface Dockable
Parameters:
listener - The property change listener to be removed

addDockingListener

public void addDockingListener(DockingListener listener)
Description copied from interface: Dockable
Adds a listener for docking events of this dockable.

Specified by:
addDockingListener in interface Dockable
Parameters:
listener - A docking listener that will be notified, when this dockable is added, moved, or removed.

removeDockingListener

public void removeDockingListener(DockingListener listener)
Description copied from interface: Dockable
Removes a listener for docking events of this dockable.

Specified by:
removeDockingListener in interface Dockable
Parameters:
listener - A docking listener to remove.

fireDockingWillChange

public void fireDockingWillChange(DockableEvent dockableEvent)
Description copied from interface: Dockable
Notifies all listeners that have registered interest for notification on this event type.

Specified by:
fireDockingWillChange in interface Dockable
Parameters:
dockableEvent - Gives more information about the origin dock, the destination dock, and the object whose docking state changed.

fireDockingChanged

public void fireDockingChanged(DockableEvent dockableEvent)
Description copied from interface: Dockable
Notifies all listeners that have registered interest for notification on this event type.

Specified by:
fireDockingChanged in interface Dockable
Parameters:
dockableEvent - Gives more information about the origin dock, the destination dock, and the object whose docking state changed.

setState

public void setState(int state,
                     java.lang.Object visualizer)

Tries to set the new state of the dockable.

When the given state is DockableState.CLOSED, the dock of this dockable will be set to null.

When the given state is DockableState.NORMAL, the visualizer should be the LeafDock where the dockable is docked in. The dock of this dockable will be set.

For other states the visualizer can have another type, but these types are not obligatory. The visualizer can even be null.

Specified by:
setState in interface Dockable
Parameters:
state - The new state of the dockable. This should be a constant defined by DockableState.
visualizer - The object that currently shows the content of the dockable. Can be null, i.e. when the state of the dockable is DockableState.CLOSED.

getVisualizer

public java.lang.Object getVisualizer()
Description copied from interface: Dockable
Gets the object that currently shows the content of the dockable. Can be null, i.e. when the state of the dockable is DockableState.CLOSED.

Specified by:
getVisualizer in interface Dockable
Returns:
The object that currently shows the content of the dockable.

getState

public int getState()
Description copied from interface: Dockable
Gets the state of the dockable.

Specified by:
getState in interface Dockable
Returns:
The current state of the dockable. This should be a constant defined by DockableState.

getPossibleStates

public int getPossibleStates()

Gets the possible states of the dockable. This can be a combination of constants defined by DockableState. A combination is made by the bitwise or-operation on the integer constants.

The default states are DockableState.CLOSED | DockableState.NORMAL | DockableState.MAXIMIZED | DockableState.MINIMIZED.

Specified by:
getPossibleStates in interface Dockable
Returns:
The possible states of the dockable.

setPossibleStates

public void setPossibleStates(int possibleStates)
Sets the possible states of the dockable.

Parameters:
possibleStates - The possible states of the dockable.
See Also:
getPossibleStates()

getSelectedIndex

public int getSelectedIndex()
Gets the index of the selected dockable.

Returns:
The index of the selected dockable.

setSelectedIndex

public void setSelectedIndex(int selectedIndex)
                      throws java.lang.IndexOutOfBoundsException
Sets the index of the selected dockable.

Parameters:
selectedIndex - The index of the selected dockable.
Throws:
java.lang.IndexOutOfBoundsException - If the index is out of range (index < 0 || index >= getDockableCount()).

equals

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

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

hashCode

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

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object