bibliothek.gui.dock.themes.basic.action
Class BasicHandler<D extends StandardDockAction>

java.lang.Object
  extended by bibliothek.gui.dock.themes.basic.action.BasicHandler<D>
Type Parameters:
D - The type of action observed by this model
All Implemented Interfaces:
ViewItem<JComponent>, BasicTitleViewItem<JComponent>, BasicTrigger
Direct Known Subclasses:
BasicButtonHandler, BasicMenuHandler, BasicPanelPopupHandler, BasicSelectableHandler

public abstract class BasicHandler<D extends StandardDockAction>
extends Object
implements BasicTrigger, BasicTitleViewItem<JComponent>

A class connecting a DockAction with a BasicButtonModel. The handler observes the action and reports all changed properties to the model.
Clients should call the method setModel(BasicButtonModel) to connect the handler with a model.
This class implements BasicTitleViewItem in order to allow clients to use instances as results of some ViewGenerators.

Author:
Benjamin Sigg

Nested Class Summary
protected  class BasicHandler.Listener
          A listener to the action of the enclosing handler.
 
Constructor Summary
BasicHandler(D action, Dockable dockable)
          Creates a new handler.
 
Method Summary
 void bind()
          Binds this item to its action
protected  BasicHandler.Listener createListener()
          Creates a listener which forwards changes in the action to the model.
 D getAction()
          Gest the action which is monitored by this handler.
 Dockable getDockable()
          Gets the Dockable for which the action is shown.
 JComponent getItem()
          Gets this item as component.
 BasicButtonModel getModel()
          Gets the model of this handler.
 void setBackground(Color background)
          Called by the title that shows this item to tell this item what the background color of the title is.
 void setForeground(Color foreground)
          Called by the title that shows this item to tell this item what the foreground color of the title is.
 void setModel(BasicButtonModel model)
          Sets the model to which all properties of the action are transfered.
 void setOrientation(DockTitle.Orientation orientation)
          Informs the item about the orientation of the title that uses this item.
abstract  void triggered()
          Invoked by a BasicButtonModel when the button, which is monitored by the model, is clicked.
 void unbind()
          Unbinds this item from its action
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicHandler

public BasicHandler(D action,
                    Dockable dockable)
Creates a new handler.

Parameters:
action - the action which will be observed.
dockable - the dockable for which the action is shown
Method Detail

setModel

public void setModel(BasicButtonModel model)
Sets the model to which all properties of the action are transfered.

Parameters:
model - the model

getModel

public BasicButtonModel getModel()
Gets the model of this handler.

Returns:
the model
See Also:
setModel(BasicButtonModel)

getAction

public D getAction()
Gest the action which is monitored by this handler.

Specified by:
getAction in interface ViewItem<JComponent>
Returns:
the observed action

getDockable

public Dockable getDockable()
Gets the Dockable for which the action is shown.

Returns:
the dockable

getItem

public JComponent getItem()
Description copied from interface: ViewItem
Gets this item as component.

Specified by:
getItem in interface ViewItem<JComponent>
Returns:
this item

setBackground

public void setBackground(Color background)
Description copied from interface: BasicTitleViewItem
Called by the title that shows this item to tell this item what the background color of the title is.

Specified by:
setBackground in interface BasicTitleViewItem<JComponent>
Parameters:
background - the background color of the title

setForeground

public void setForeground(Color foreground)
Description copied from interface: BasicTitleViewItem
Called by the title that shows this item to tell this item what the foreground color of the title is.

Specified by:
setForeground in interface BasicTitleViewItem<JComponent>
Parameters:
foreground - the foreground color of the title

setOrientation

public void setOrientation(DockTitle.Orientation orientation)
Description copied from interface: BasicTitleViewItem
Informs the item about the orientation of the title that uses this item.

Specified by:
setOrientation in interface BasicTitleViewItem<JComponent>
Parameters:
orientation - the orientation

triggered

public abstract void triggered()
Description copied from interface: BasicTrigger
Invoked by a BasicButtonModel when the button, which is monitored by the model, is clicked.

Specified by:
triggered in interface BasicTrigger

bind

public void bind()
Description copied from interface: ViewItem
Binds this item to its action

Specified by:
bind in interface ViewItem<JComponent>

unbind

public void unbind()
Description copied from interface: ViewItem
Unbinds this item from its action

Specified by:
unbind in interface ViewItem<JComponent>

createListener

protected BasicHandler.Listener createListener()
Creates a listener which forwards changes in the action to the model.

Returns:
the new listener