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

java.lang.Object
  extended by bibliothek.gui.dock.themes.basic.action.BasicButtonModel
      extended by bibliothek.gui.dock.themes.basic.action.BasicDropDownButtonModel

public abstract class BasicDropDownButtonModel
extends BasicButtonModel

An expanded BasicButtonModel that can handle the properties needed to represent a DropDownAction.

Author:
Benjamin Sigg

Constructor Summary
BasicDropDownButtonModel(JComponent owner, BasicDropDownButtonTrigger trigger, BasicResourceInitializer initializer)
          Creates a new model.
BasicDropDownButtonModel(JComponent owner, BasicDropDownButtonTrigger trigger, BasicResourceInitializer initializer, boolean createListener)
          Creates a new model.
 
Method Summary
 Icon getPaintIcon()
          Gets the icon which should be painted on the view.
protected abstract  boolean inDropDownArea(int x, int y)
          Tells whether the location x/y is over the dropdown area of the view or not.
 boolean isMouseOverDropDown()
          Tells whether the mouse is currently over the dropdown area of the view or not.
 boolean isSelectionEnabled()
          Tells whether the selected child-action of the represented DropDownAction is currently enabled or not.
protected  List<Triple<KeyStroke,String,Action>> listActions()
          Gets a list of KeyStrokes, String keys and Actions which are to be applied to the owner of this model.
protected  void popupTriggered()
          Triggers the drop down menu to open.
protected  void setMouseInside(boolean mouseInside)
          Changes the mouseInside property.
protected  void setMouseOverDropDown(boolean overDropDown)
          Sets whether the mouse is currently over the dropdown area of the view or not.
 void setSelectionEnabled(boolean selectionEnabled)
          Sets whether the selected child-action of the represented DropDownAction is currently enabled or not.
 
Methods inherited from class bibliothek.gui.dock.themes.basic.action.BasicButtonModel
addListener, changed, clearIcons, getAction, getBackground, getBackgroundComponent, getBorder, getDockable, getIconContexts, getMaxIconSize, getOrientation, getOwner, getPaintIcon, getText, isEnabled, isMouseInside, isMousePressed, isSelected, listeners, removeListener, setBackground, setBorder, setController, setDockableRepresentative, setEnabled, setIcon, setMousePressed, setOrientation, setSelected, setText, setToolTipText, trigger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicDropDownButtonModel

public BasicDropDownButtonModel(JComponent owner,
                                BasicDropDownButtonTrigger trigger,
                                BasicResourceInitializer initializer)
Creates a new model.

Parameters:
owner - the view of this model
initializer - a strategy to lazily initialize resources
trigger - the callback used when the user clicks on the view

BasicDropDownButtonModel

public BasicDropDownButtonModel(JComponent owner,
                                BasicDropDownButtonTrigger trigger,
                                BasicResourceInitializer initializer,
                                boolean createListener)
Creates a new model.

Parameters:
owner - the view of this model
trigger - the callback used when the user clicks on the view
initializer - a strategy to lazily initialize resources
createListener - whether the model should add a MouseListener and a MouseMotionListener to the view or not.
Method Detail

listActions

protected List<Triple<KeyStroke,String,Action>> listActions()
Description copied from class: BasicButtonModel
Gets a list of KeyStrokes, String keys and Actions which are to be applied to the owner of this model.

Overrides:
listActions in class BasicButtonModel
Returns:
the list of actions

setMouseInside

protected void setMouseInside(boolean mouseInside)
Description copied from class: BasicButtonModel
Changes the mouseInside property. The property tells whether the mouse is currently inside the border of the owner or not. Clients should not call this method unless they handle all mouse events.

Overrides:
setMouseInside in class BasicButtonModel
Parameters:
mouseInside - whether the mouse is inside

setMouseOverDropDown

protected void setMouseOverDropDown(boolean overDropDown)
Sets whether the mouse is currently over the dropdown area of the view or not. Clients should not call this method unless the handle all mouse events.

Parameters:
overDropDown - whether the mouse is over the dropdown area

isMouseOverDropDown

public boolean isMouseOverDropDown()
Tells whether the mouse is currently over the dropdown area of the view or not.

Returns:
whether the mouse is over the dropdown area

setSelectionEnabled

public void setSelectionEnabled(boolean selectionEnabled)
Sets whether the selected child-action of the represented DropDownAction is currently enabled or not.

Parameters:
selectionEnabled - whether the action is enabled

isSelectionEnabled

public boolean isSelectionEnabled()
Tells whether the selected child-action of the represented DropDownAction is currently enabled or not.

Returns:
whether the action is enabled

getPaintIcon

public Icon getPaintIcon()
Description copied from class: BasicButtonModel
Gets the icon which should be painted on the view.

Overrides:
getPaintIcon in class BasicButtonModel
Returns:
the icon to paint, can be null

inDropDownArea

protected abstract boolean inDropDownArea(int x,
                                          int y)
Tells whether the location x/y is over the dropdown area of the view or not. The coordinates are in system of the owner's coordinate-system.

Parameters:
x - the x-coordinate
y - the y-coordinate
Returns:
true if a click with the mouse should open the selection-menu of the DropDownAction

popupTriggered

protected void popupTriggered()
Triggers the drop down menu to open.