bibliothek.gui.dock.themes.basic.action
Class BasicDropDownButtonHandler

java.lang.Object
  extended by bibliothek.gui.dock.themes.basic.action.BasicDropDownButtonHandler
All Implemented Interfaces:
ViewItem<javax.swing.JComponent>, BasicTitleViewItem<javax.swing.JComponent>, BasicTrigger

public class BasicDropDownButtonHandler
extends java.lang.Object
implements BasicTrigger, BasicTitleViewItem<javax.swing.JComponent>

A handler connecting a DropDownAction with a BasicDropDownButtonModel and its view. Clients should call the method setModel(BasicDropDownButtonModel) to connect model and handler.

Author:
Benjamin Sigg

Nested Class Summary
protected  class BasicDropDownButtonHandler.ButtonView
          A view that sends all values directly to the button.
private  class BasicDropDownButtonHandler.Listener
          A listener to the action that is handled by this handler
protected  class BasicDropDownButtonHandler.SelectionView
          A set of properties which can be set by the selected action.
 
Field Summary
private  DropDownAction action
          the action to observe and to trigger
private  java.util.List<DockAction> actions
          the currently known actions
private  BasicDropDownButtonHandler.ButtonView buttonView
          connection between filter and button
private  Dockable dockable
          the element for which the action is shown
private  DropDownFilter filter
          filters the properties of the action and its selection
private  java.util.Map<DockAction,DropDownItemHandle> items
          the views for the items of actions.
private  BasicDropDownButtonHandler.Listener listener
          a listener to the model
private  javax.swing.JPopupMenu menu
          the menu to show when the button is clicked
private  BasicDropDownButtonModel model
          the model that links to the view
private  DropDownItemHandle selection
          the currently selected item, can be null
private  BasicDropDownButtonHandler.SelectionView selectionView
          connection between current selection and filter
private  DockActionSource source
          the current source of child-actions
 
Constructor Summary
BasicDropDownButtonHandler(DropDownAction action, Dockable dockable)
          Creates a new handler.
 
Method Summary
private  void add(int index, DockAction action)
          Adds an action into the list of all known actions.
 void bind()
          Binds this item to its action
 DropDownAction getAction()
          Gets the action that is represented by this target.
protected  BasicDropDownButtonHandler.ButtonView getButtonView()
          Gets the view which contains information about the currently selected action.
 Dockable getDockable()
           
 javax.swing.JComponent getItem()
          Gets this item as component.
 void popupTriggered()
          Shows the popup menu
private  void remove(int index)
          Removes an action from the list of all known actions.
protected  void reset()
          Sets all values of the filter to null.
 void setModel(BasicDropDownButtonModel model)
          Sets the model to which this handler sends all properties of the action.
 void setOrientation(DockTitle.Orientation orientation)
          Informs the item about the orientation of the title that uses this item.
 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
protected  void update()
          Updates the filter.
 void updateUI()
          Update the look and feel of the menu
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

private DropDownAction action
the action to observe and to trigger


source

private DockActionSource source
the current source of child-actions


dockable

private Dockable dockable
the element for which the action is shown


model

private BasicDropDownButtonModel model
the model that links to the view


listener

private BasicDropDownButtonHandler.Listener listener
a listener to the model


selection

private DropDownItemHandle selection
the currently selected item, can be null


actions

private java.util.List<DockAction> actions
the currently known actions


items

private java.util.Map<DockAction,DropDownItemHandle> items
the views for the items of actions. Not all actions have a view.


menu

private javax.swing.JPopupMenu menu
the menu to show when the button is clicked


selectionView

private BasicDropDownButtonHandler.SelectionView selectionView
connection between current selection and filter


buttonView

private BasicDropDownButtonHandler.ButtonView buttonView
connection between filter and button


filter

private DropDownFilter filter
filters the properties of the action and its selection

Constructor Detail

BasicDropDownButtonHandler

public BasicDropDownButtonHandler(DropDownAction action,
                                  Dockable dockable)
Creates a new handler.

Parameters:
action - the action to observe
dockable - the element for which the action is shown
Method Detail

setModel

public void setModel(BasicDropDownButtonModel model)
Sets the model to which this handler sends all properties of the action.

Parameters:
model - the model to inform about changes

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<javax.swing.JComponent>
Parameters:
orientation - the orientation

bind

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

Specified by:
bind in interface ViewItem<javax.swing.JComponent>

unbind

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

Specified by:
unbind in interface ViewItem<javax.swing.JComponent>

add

private void add(int index,
                 DockAction action)
Adds an action into the list of all known actions.

Parameters:
index - the location of the action
action - the new action

remove

private void remove(int index)
Removes an action from the list of all known actions.

Parameters:
index - the location of the action

getAction

public DropDownAction getAction()
Description copied from interface: ViewItem
Gets the action that is represented by this target.

Specified by:
getAction in interface ViewItem<javax.swing.JComponent>
Returns:
the action, might be null

getDockable

public Dockable getDockable()

getItem

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

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

triggered

public 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

popupTriggered

public void popupTriggered()
Shows the popup menu


updateUI

public void updateUI()
Update the look and feel of the menu


getButtonView

protected BasicDropDownButtonHandler.ButtonView getButtonView()
Gets the view which contains information about the currently selected action.

Returns:
the information

reset

protected void reset()
Sets all values of the filter to null.


update

protected void update()
Updates the filter. This might change some contents of the button.