com.javadocking.dockable
Class DefaultDockable

java.lang.Object
  extended by com.javadocking.dockable.DefaultDockable
All Implemented Interfaces:
Dockable

public class DefaultDockable
extends java.lang.Object
implements Dockable

The default implementation for a dockable. The content component may not be null.

By default it can be docked anywhere, except in tool bars and tool grids.

It can have a title, an icon, but it doesn't have any actions associated with it.

Author:
Heidi Rakels.

Constructor Summary
DefaultDockable(java.lang.String id, java.awt.Component content)
          Constructs a new dockable with the specified ID and content.
DefaultDockable(java.lang.String id, java.awt.Component content, java.lang.String title)
          Constructs a new dockable with the specified id, component and title.
DefaultDockable(java.lang.String id, java.awt.Component content, java.lang.String title, javax.swing.Icon icon)
          Constructs a new dockable with the specified id, component, title and icon.
DefaultDockable(java.lang.String id, java.awt.Component content, java.lang.String title, javax.swing.Icon icon, int dockingModes)
          Constructs a new dockable with the specified id, content, title, icon and docking modes.
 
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()
          Returns null.
 java.awt.Component getContent()
          Gets the content of the dockable.
 java.lang.String getDescription()
          Gets the description of the dockable.
 LeafDock getDock()
          Gets the dock in which the dockable is docked.
 int getDockingModes()
           Gets the modes how this dockable can be docked.
 javax.swing.Icon getIcon()
          Gets the icon of the dockable.
 java.lang.String getID()
          Gets the ID of the dockable.
 int getLastDockingMode()
          Gets the mode how the dockable is docked in its current dock or how it was docked the last time it was in a dock.
 int getPossibleStates()
           Gets the possible states of the dockable.
 int getState()
          Gets the state of the dockable.
 java.lang.String getTitle()
          Gets the title of the dockable.
 java.lang.Object getVisualizer()
          Gets the object that currently shows the content of the dockable.
 int hashCode()
           
 boolean isWithHeader()
          Returns whether the dockable will have a header when it is docked alone.
 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 setDescription(java.lang.String description)
          Sets the description of the dockable.
 void setDock(LeafDock dock)
          Sets the dock in which the dockable is docked.
 void setDockingModes(int dockingModes)
          Sets the modes how this dockable can be docked.
 void setIcon(javax.swing.Icon icon)
          Sets the icon of the dockable.
 void setLastDockingMode(int dockPosition)
          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 setState(int state, java.lang.Object visualizer)
           Tries to set the new state of the dockable.
 void setTitle(java.lang.String title)
          Sets the title of the dockable.
 void setWithHeader(boolean withHeader)
          Sets whether the dockable will have a header, when it is docked alone.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultDockable

public DefaultDockable(java.lang.String id,
                       java.awt.Component content)
Constructs a new dockable with the specified ID and content. The possible docking modes are DockingMode.ALL.

Parameters:
id - The ID of the dockable. The IDs of all dockables should be different.
content - The content of the dockable.
Throws:
java.lang.IllegalArgumentException - If the given ID is null.

DefaultDockable

public DefaultDockable(java.lang.String id,
                       java.awt.Component content,
                       java.lang.String title)
Constructs a new dockable with the specified id, component and title. The possible docking modes are DockingMode.ALL.

Parameters:
id - The ID of the dockable. The IDs of all dockables should be different.
content - The content of the dockable.
title - The title of the dockable.
Throws:
java.lang.IllegalArgumentException - If the given ID is null.

DefaultDockable

public DefaultDockable(java.lang.String id,
                       java.awt.Component content,
                       java.lang.String title,
                       javax.swing.Icon icon)
Constructs a new dockable with the specified id, component, title and icon. The possible docking modes are DockingMode.ALL.

Parameters:
id - The ID of the dockable. The IDs of all dockables should be different.
content - The content of the dockable.
title - The title of the dockable.
icon - The icon of the dockable.
Throws:
java.lang.IllegalArgumentException - If the given ID is null.

DefaultDockable

public DefaultDockable(java.lang.String id,
                       java.awt.Component content,
                       java.lang.String title,
                       javax.swing.Icon icon,
                       int dockingModes)
Constructs a new dockable with the specified id, content, title, icon and docking modes.

Parameters:
id - The ID of the dockable. The IDs of all dockables should be different.
content - The content of the dockable.
title - The title of the dockable.
icon - The icon of the dockable.
dockingModes - The possible docking modes of the dockable. This integer should be combination of constants defined by DockingMode.
Throws:
java.lang.IllegalArgumentException - If the given ID is null.
Method Detail

getID

public java.lang.String getID()
Description copied from interface: Dockable
Gets the ID of the dockable.
WARNING: All the dockables used in an application should have a different ID.

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

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.

getContent

public java.awt.Component getContent()
Description copied from interface: Dockable
Gets the content of the dockable. This is a graphical component. The dockable is a wrapper around this content component. The dockable is used to move this content from dock to dock.

Specified by:
getContent in interface Dockable
Returns:
The content of the dockable.

getTitle

public java.lang.String getTitle()
Description copied from interface: Dockable
Gets the title of the dockable.

Specified by:
getTitle in interface Dockable
Returns:
The title of the dockable.

getDescription

public java.lang.String getDescription()
Description copied from interface: Dockable
Gets the description of the dockable.

Specified by:
getDescription in interface Dockable
Returns:
The description of the dockable.

getIcon

public javax.swing.Icon getIcon()
Description copied from interface: Dockable
Gets the icon of the dockable.

Specified by:
getIcon in interface Dockable
Returns:
The icon of the dockable.

getDockingModes

public int getDockingModes()
Description copied from interface: Dockable

Gets the modes how this dockable can be docked. The integer should be a combination of constants defined by DockingMode.

Combinations of the different modes are made by using the bitwise or-operator.

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 dockPosition)
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:
dockPosition - 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()
Description copied from interface: Dockable
Gets 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:
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()
Description copied from interface: Dockable
Returns whether the dockable will have a header when it is docked alone. With the header the dockable can be dragged. The header can contain also the title, the icon, etc.

Specified by:
isWithHeader in interface Dockable
Returns:
True if the dockable will have a header when it is docked alone, false otherwise.

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.

getActions

public javax.swing.Action[][] getActions()
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.

setWithHeader

public void setWithHeader(boolean withHeader)
Sets whether the dockable will have a header, when it is docked alone.

Parameters:
withHeader - True if the dockable will have a header, when it is docked alone, false otherwise.
See Also:
isWithHeader()

setDockingModes

public void setDockingModes(int dockingModes)
Sets the modes how this dockable can be docked.

Parameters:
dockingModes - The modes how this dockable can be docked.
See Also:
getDockingModes()

setIcon

public void setIcon(javax.swing.Icon icon)
Sets the icon of the dockable.

Parameters:
icon - The icon of the dockable.
See Also:
getIcon()

setTitle

public void setTitle(java.lang.String title)
Sets the title of the dockable.

Parameters:
title - The title of the dockable.
See Also:
getTitle()

setDescription

public void setDescription(java.lang.String description)
Sets the description of the dockable.

Parameters:
description - The description of the dockable.
See Also:
getDescription()

setPossibleStates

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

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

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