bibliothek.gui.dock.action.actions
Class SimpleSelectableAction

java.lang.Object
  extended by bibliothek.gui.dock.action.actions.AbstractStandardDockAction
      extended by bibliothek.gui.dock.action.actions.SimpleDockAction
          extended by bibliothek.gui.dock.action.actions.SimpleDropDownItemAction
              extended by bibliothek.gui.dock.action.actions.SimpleSelectableAction
All Implemented Interfaces:
SharingDropDownItemAction, SharingSelectableDockAction, SharingStandardDockAction, DockAction, DropDownItemAction, SelectableDockAction, StandardDockAction, StandardDropDownItemAction
Direct Known Subclasses:
SimpleSelectableAction.Check, SimpleSelectableAction.Radio

public abstract class SimpleSelectableAction
extends SimpleDropDownItemAction
implements SharingSelectableDockAction, SelectableDockAction

A DockAction that has a state selected. That state has always the same value for every Dockable using this action.

Author:
Benjamin Sigg

Nested Class Summary
static class SimpleSelectableAction.Check
          A SimpleSelectableAction that is visualized as a ActionType.CHECK.
static class SimpleSelectableAction.Radio
          A SimpleSelectableAction that is visualized as a ActionType.RADIO.
 
Constructor Summary
SimpleSelectableAction(ActionType<SelectableDockAction> type, boolean monitorDisabling)
          Creates a new action.
 
Method Summary
 void addSelectableListener(SelectableDockActionListener listener)
          Adds a listener to this action.
<V> V
createView(ViewTarget<V> target, ActionViewConverter converter, Dockable dockable)
          Creates a view for this action, for the platform target and with help of converter.
protected  void fireSelectedChanged()
          Fires an event to all observers of type SelectableDockActionListener.
protected  Icon firstNonNull(Icon... icons)
          Gets the first element of icons that is not null.
 Icon getDisabledSelectedIcon()
          Gets the icon which is shown if this action is selected but disabled
 Icon getIcon(Dockable dockable, ActionContentModifier modifier)
          Gets the Icon of this DockAction, when this DockAction is shown together with dockable.
 ActionContentModifier[] getIconContexts(Dockable dockable)
          Gets all the ActionContentModifiers for which StandardDockAction.getIcon(Dockable, ActionContentModifier) would return a value other than null.
 Icon getSelectedIcon()
          Gets the icon which is shown if this action is selected
 Icon getSelectedIcon(ActionContentModifier modifier)
          Gets the icon that is shown when this action is selected.
 boolean isSelected()
          Gets the selected-state of this action.
 boolean isSelected(Dockable dockable)
          Tells whether this DockAction is selected or not (in respect to the given dockable).
 void removeSelectableListener(SelectableDockActionListener listener)
          Removes a listener from this action.
 void setDisabledSelectedIcon(Icon icon)
          Sets the icon which is shown if this action is selected but disabled
 void setSelected(boolean selected)
          Sets the state of this action.
 void setSelected(Dockable dockable, boolean selected)
          Sets the selected state for dockable.
 void setSelectedIcon(ActionContentModifier modifier, Icon selectedIcon)
          Sets the icon that will be shown, when this action is selected.
 void setSelectedIcon(Icon icon)
          Sets the icon which is shown if this action is selected
 
Methods inherited from class bibliothek.gui.dock.action.actions.SimpleDropDownItemAction
isDropDownSelectable, isDropDownSelectable, isDropDownTriggerable, isDropDownTriggerableNotSelected, isDropDownTriggerableSelected, setDropDownSelectable, setDropDownTriggerableNotSelected, setDropDownTriggerableSelected
 
Methods inherited from class bibliothek.gui.dock.action.actions.SimpleDockAction
bound, getAccelerator, getDisabledIcon, getDockableRepresentation, getDockableRepresentation, getIcon, getIcon, getText, getText, getTooltip, getTooltipText, getTooltipText, isEnabled, isEnabled, setAccelerator, setDisabledIcon, setDockableRepresentation, setEnabled, setIcon, setIcon, setText, setTooltip, trigger, unbound
 
Methods inherited from class bibliothek.gui.dock.action.actions.AbstractStandardDockAction
addDockActionListener, bind, fireActionEnabledChanged, fireActionIconChanged, fireActionRepresentativeChanged, fireActionTextChanged, fireActionTooltipTextChanged, getBoundDockables, isBound, removeDockActionListener, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.action.actions.SharingDropDownItemAction
isDropDownSelectable, isDropDownTriggerableNotSelected, isDropDownTriggerableSelected, setDropDownSelectable, setDropDownTriggerableNotSelected, setDropDownTriggerableSelected
 
Methods inherited from interface bibliothek.gui.dock.action.actions.SharingStandardDockAction
getAccelerator, getDisabledIcon, getDockableRepresentation, getIcon, getIcon, getText, getTooltip, getTooltipText, isEnabled, setAccelerator, setDisabledIcon, setDockableRepresentation, setEnabled, setIcon, setIcon, setText, setTooltip
 

Constructor Detail

SimpleSelectableAction

public SimpleSelectableAction(ActionType<SelectableDockAction> type,
                              boolean monitorDisabling)
Creates a new action.

Parameters:
type - how this action is to be visualized
monitorDisabling - whether the current DisablingStrategy should be monitored
Method Detail

createView

public <V> V createView(ViewTarget<V> target,
                        ActionViewConverter converter,
                        Dockable dockable)
Description copied from interface: DockAction
Creates a view for this action, for the platform target and with help of converter. Clients might use their own code to create a new view, but the preferred way is to call ActionViewConverter.createView(ActionType, DockAction, ViewTarget, Dockable) with an ActionType that fits to this DockAction.

Specified by:
createView in interface DockAction
Type Parameters:
V - the type of view requested
Parameters:
target - The platform on which the view will be used
converter - A set of methods that can be used to create a view
dockable - The Dockable for which the view will be shown. Note that this action may not yet be bound to this action.
Returns:
a new view

addSelectableListener

public void addSelectableListener(SelectableDockActionListener listener)
Description copied from interface: SelectableDockAction
Adds a listener to this action. The listener will be invoked whenever the selected state of a Dockable changes.

Specified by:
addSelectableListener in interface SelectableDockAction
Parameters:
listener - the new listener

removeSelectableListener

public void removeSelectableListener(SelectableDockActionListener listener)
Description copied from interface: SelectableDockAction
Removes a listener from this action.

Specified by:
removeSelectableListener in interface SelectableDockAction
Parameters:
listener - the listener to remove

fireSelectedChanged

protected void fireSelectedChanged()
Fires an event to all observers of type SelectableDockActionListener.


isSelected

public boolean isSelected(Dockable dockable)
Description copied from interface: SelectableDockAction
Tells whether this DockAction is selected or not (in respect to the given dockable).

Specified by:
isSelected in interface SelectableDockAction
Parameters:
dockable - The Dockable for which this action may be selected or not selected
Returns:
true if this DockAction is selcted, false otherwise

setSelected

public void setSelected(Dockable dockable,
                        boolean selected)
Description copied from interface: SelectableDockAction
Sets the selected state for dockable.

Specified by:
setSelected in interface SelectableDockAction
Parameters:
dockable - the affected dockable
selected - the new state

isSelected

public boolean isSelected()
Description copied from interface: SharingSelectableDockAction
Gets the selected-state of this action.

Specified by:
isSelected in interface SharingSelectableDockAction
Returns:
The current state
See Also:
SharingSelectableDockAction.setSelected(boolean)

setSelected

public void setSelected(boolean selected)
Description copied from interface: SharingSelectableDockAction
Sets the state of this action. The action will notify all listeners about the new state.

Specified by:
setSelected in interface SharingSelectableDockAction
Parameters:
selected - the new state

getIcon

public Icon getIcon(Dockable dockable,
                    ActionContentModifier modifier)
Description copied from interface: StandardDockAction
Gets the Icon of this DockAction, when this DockAction is shown together with dockable. This method must ignore the backup property of modifier.

Specified by:
getIcon in interface StandardDockAction
Overrides:
getIcon in class SimpleDockAction
Parameters:
dockable - The Dockable for which the action-icon should be chosen.
modifier - how the icon will be used
Returns:
The icon to show for this action when the action is associated with dockable, or null.

firstNonNull

protected Icon firstNonNull(Icon... icons)
Gets the first element of icons that is not null.

Parameters:
icons - a list of icons
Returns:
the first non-null icon

getIconContexts

public ActionContentModifier[] getIconContexts(Dockable dockable)
Description copied from interface: StandardDockAction
Gets all the ActionContentModifiers for which StandardDockAction.getIcon(Dockable, ActionContentModifier) would return a value other than null.

Specified by:
getIconContexts in interface StandardDockAction
Overrides:
getIconContexts in class SimpleDockAction
Parameters:
dockable - the Dockable for which the action-icons may be chosen.
Returns:
the contexts in which an icon is present

setSelectedIcon

public void setSelectedIcon(Icon icon)
Sets the icon which is shown if this action is selected

Parameters:
icon - the icon to show, or null

getSelectedIcon

public Icon getSelectedIcon()
Gets the icon which is shown if this action is selected

Returns:
the icon or null

setDisabledSelectedIcon

public void setDisabledSelectedIcon(Icon icon)
Sets the icon which is shown if this action is selected but disabled

Parameters:
icon - the icon to show, or null

getDisabledSelectedIcon

public Icon getDisabledSelectedIcon()
Gets the icon which is shown if this action is selected but disabled

Returns:
the icon or null

getSelectedIcon

public Icon getSelectedIcon(ActionContentModifier modifier)
Description copied from interface: SharingSelectableDockAction
Gets the icon that is shown when this action is selected.

Specified by:
getSelectedIcon in interface SharingSelectableDockAction
Parameters:
modifier - tells in which context the icon is used
Returns:
The selected-icon, may be null
See Also:
SharingSelectableDockAction.setSelectedIcon(ActionContentModifier, Icon), SharingSelectableDockAction.isSelected()

setSelectedIcon

public void setSelectedIcon(ActionContentModifier modifier,
                            Icon selectedIcon)
Description copied from interface: SharingSelectableDockAction
Sets the icon that will be shown, when this action is selected.

Specified by:
setSelectedIcon in interface SharingSelectableDockAction
Parameters:
modifier - tells in which context icon will be used
selectedIcon - The icon, can be null
See Also:
SharingSelectableDockAction.setSelected(boolean)