com.javadocking.dockable
Class ActionDockable

java.lang.Object
  extended by com.javadocking.dockable.ActionDockable
All Implemented Interfaces:
Dockable
Direct Known Subclasses:
StateActionDockable

public class ActionDockable
extends java.lang.Object
implements Dockable

A decorator for a delegate Dockable. This decorator adds actions to the delegate.

Information on using dockables with actions is in How to Use Dockables in The Sanaware Developer Guide.

When the method getActions() is called, the actions of this decorator are added at the end of the matrix of actions retrieved by executing this method on the delegate.

Author:
Heidi Rakels.

Constructor Summary
ActionDockable(Dockable delegate)
          Constructs a decorator for the given dockable.
ActionDockable(Dockable delegate, javax.swing.Action[][] actionsToAdd)
          Constructs a decorator for the given dockable.
 
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()
           Creates a matrix of actions with the actions retrieved from the delegate and the actions of this decorator.
 javax.swing.Action[][] getActionsToAdd()
          Gets the actions that will be added by this wrapper to the matrix of actions of the delegate.
 java.awt.Component getContent()
          Gets the content of the dockable.
 Dockable getDelegate()
          Gets the wrapped 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 setActionsToAdd(javax.swing.Action[][] actions)
          Sets the actions that will be added by this wrapper to the matrix of actions of the delegate.
 void setDock(LeafDock dock)
          Sets the dock in which the dockable is docked.
 void setLastDockingMode(int dockingMode)
          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 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

ActionDockable

public ActionDockable(Dockable delegate)
Constructs a decorator for the given dockable. The action matrix for this decorator is a matrix with 0 rows.

Parameters:
delegate - The delegate dockable.

ActionDockable

public ActionDockable(Dockable delegate,
                      javax.swing.Action[][] actionsToAdd)
Constructs a decorator for the given dockable.

Parameters:
delegate - The delegate dockable.
actionsToAdd - The actions that will be added to the matrix of actions of the delegate.
See Also:
getActions()
Method Detail

getActions

public javax.swing.Action[][] getActions()

Creates a matrix of actions with the actions retrieved from the delegate and the actions of this decorator.

The rows of actions of this decorator will be the rows at the end of the action matrix.

If the delegate returns null, then the matrix of actions of this decorator is returned.

Specified by:
getActions in interface Dockable
Returns:
The matrix of actions created with the actions retrieved from the delegate and the actions of this decorator.

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.

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.

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.

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.

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.

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.

getPossibleStates

public int getPossibleStates()
Description copied from interface: Dockable
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.

Specified by:
getPossibleStates in interface Dockable
Returns:
The possible states 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.

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.

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.

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.

setLastDockingMode

public void setLastDockingMode(int dockingMode)
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:
dockingMode - 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.

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.

setState

public void setState(int state,
                     java.lang.Object visualizer)
Description copied from interface: Dockable
Tries to set the new state of the dockable. No checking is done, if the state is allowed by Dockable.getPossibleStates().

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.

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.

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

setActionsToAdd

public void setActionsToAdd(javax.swing.Action[][] actions)
Sets the actions that will be added by this wrapper to the matrix of actions of the delegate.

Parameters:
actions - The actions that will be added to the matrix of actions of the delegate.
See Also:
getActions()

getActionsToAdd

public javax.swing.Action[][] getActionsToAdd()
Gets the actions that will be added by this wrapper to the matrix of actions of the delegate.

Returns:
actions The actions that will be added to the matrix of actions of the delegate.
See Also:
getActions()

getDelegate

public Dockable getDelegate()
Gets the wrapped dockable.

Returns:
The wrapped dockable.