bibliothek.gui.dock.action.actions
Class GroupedSelectableDockAction<K>

java.lang.Object
  extended by bibliothek.gui.dock.action.actions.AbstractStandardDockAction
      extended by bibliothek.gui.dock.action.actions.GroupedDockAction<K,D>
          extended by bibliothek.gui.dock.action.actions.GroupedDropDownItemAction<K,SimpleSelectableAction>
              extended by bibliothek.gui.dock.action.actions.GroupedSelectableDockAction<K>
Type Parameters:
K - the type of key to distinguish between groups of Dockables
All Implemented Interfaces:
DockAction, DropDownItemAction, SelectableDockAction, StandardDockAction, StandardDropDownItemAction
Direct Known Subclasses:
GroupedSelectableDockAction.Check, GroupedSelectableDockAction.Radio

public abstract class GroupedSelectableDockAction<K>
extends GroupedDropDownItemAction<K,SimpleSelectableAction>
implements SelectableDockAction

An action that can change between selected and not selected.

Author:
Benjamin Sigg

Nested Class Summary
static class GroupedSelectableDockAction.Check<K>
          An action intended to use as type ActionType.CHECK
static class GroupedSelectableDockAction.Radio<K>
          An action intended to use as type ActionType.RADIO
 
Constructor Summary
GroupedSelectableDockAction(GroupKeyGenerator<? extends K> generator, ActionType<SelectableDockAction> type)
          Creates a new action.
 
Method Summary
 void addSelectableListener(SelectableDockActionListener listener)
          Adds a listener to this action.
protected  SimpleSelectableAction createGroup(K key)
          Creates a new group.
protected abstract  SimpleSelectableAction createGroup(SelectableDockActionListener listener)
          Creates a new group and adds a listener to the group.
<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(Dockable dockable)
          Fires a change-event on all known listeners.
protected  void fireSelectedChanged(java.util.Set<Dockable> dockables)
          Fires a change-event on all known listeners.
 javax.swing.Icon getDisabledSelectedIcon(java.lang.Object key)
          Gets the icon that is shown when the group key is selected and disabled.
 javax.swing.Icon getSelectedIcon(java.lang.Object key)
          Gets the icon that is shown when the group named key is in the selected-state.
 boolean isSelected(Dockable dockable)
          Tells whether this DockAction is selected or not (in respect to the given dockable).
 boolean isSelected(java.lang.Object key)
          Gets the selected-state property of the group key.
 void removeSelectableListener(SelectableDockActionListener listener)
          Removes a listener from this action.
 void setDisabledSelectedIcon(K key, javax.swing.Icon icon)
          Sets the icon that will be shown when the group key is disabled and selected.
 void setGroup(K key, Dockable dockable)
          Assigns the dockable/code> to the group with the given key.
 void setSelected(Dockable dockable, boolean selected)
          Sets the selected state for dockable.
 void setSelected(K key, boolean selected)
          Sets the selected-state of the group key.
 void setSelectedIcon(K key, javax.swing.Icon icon)
          Sets the icon that will be shown when the group named key is selected.
 
Methods inherited from class bibliothek.gui.dock.action.actions.GroupedDropDownItemAction
isDropDownSelectable, isDropDownSelectable, isDropDownTriggerable, isDropDownTriggerable, setDropDownSelectable, setDropDownTriggerableNotSelected, setDropDownTriggerableSelected
 
Methods inherited from class bibliothek.gui.dock.action.actions.GroupedDockAction
bound, createGroupKey, ensureGroup, getAccelerator, getDisabledIcon, getDisabledIcon, getDockableRepresentation, getDockableRepresentation, getGenerator, getGroup, getGroup, getIcon, getIcon, getText, getText, getTooltip, getTooltipText, getTooltipText, groupExists, isEnabled, isEnabled, isKnown, isRemoveEmptyGroups, removeGroup, setAccelerator, setDisabledIcon, setDockableRepresentation, setEnabled, setGenerator, setIcon, setRemoveEmptyGroups, setText, setTooltip, trigger, unbound
 
Methods inherited from class bibliothek.gui.dock.action.actions.AbstractStandardDockAction
addDockActionListener, bind, fireActionDisabledIconChanged, 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.dropdown.DropDownItemAction
isDropDownSelectable, isDropDownTriggerable
 

Constructor Detail

GroupedSelectableDockAction

public GroupedSelectableDockAction(GroupKeyGenerator<? extends K> generator,
                                   ActionType<SelectableDockAction> type)
Creates a new action.

Parameters:
generator - a generator to create keys for Dockables which are not yet in a group.
type - the type of this action
Method Detail

setGroup

public void setGroup(K key,
                     Dockable dockable)
Description copied from class: GroupedDockAction
Assigns the dockable/code> to the group with the given key.

Overrides:
setGroup in class GroupedDockAction<K,SimpleSelectableAction>
Parameters:
key - The name of the new group
dockable - The Dockable whose membership will be changed. The dockable must already be in a group of this action.
See Also:
GroupedDockAction.createGroupKey(Dockable)

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

createGroup

protected SimpleSelectableAction createGroup(K key)
Description copied from class: GroupedDockAction
Creates a new group.

Specified by:
createGroup in class GroupedDockAction<K,SimpleSelectableAction>
Parameters:
key - the key of the new group
Returns:
the new group

createGroup

protected abstract SimpleSelectableAction createGroup(SelectableDockActionListener listener)
Creates a new group and adds a listener to the group.

Parameters:
listener - the listener to add
Returns:
the new group

fireSelectedChanged

protected void fireSelectedChanged(Dockable dockable)
Fires a change-event on all known listeners.

Parameters:
dockable - the Dockable whose state has changed

fireSelectedChanged

protected void fireSelectedChanged(java.util.Set<Dockable> dockables)
Fires a change-event on all known listeners.

Parameters:
dockables - the Dockables whose state has been changed

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

setSelected

public void setSelected(K key,
                        boolean selected)
Sets the selected-state of the group key. If the group does not exist, it will be created.

Parameters:
key - The name of the group
selected - The new state of the group

isSelected

public boolean isSelected(java.lang.Object key)
Gets the selected-state property of the group key.

Parameters:
key - The name of the group
Returns:
The state
Throws:
java.lang.IllegalArgumentException - If the group does not exist
See Also:
setSelected(Object, boolean)

setSelectedIcon

public void setSelectedIcon(K key,
                            javax.swing.Icon icon)
Sets the icon that will be shown when the group named key is selected. If the group does not exist, it will be created.

Parameters:
key - The name of the group
icon - The selected-icon, may be null

getSelectedIcon

public javax.swing.Icon getSelectedIcon(java.lang.Object key)
Gets the icon that is shown when the group named key is in the selected-state.

Parameters:
key - The name of the group
Returns:
The selected-icon, may be null
Throws:
java.lang.IllegalArgumentException - if the group does not exist
See Also:
GroupedDockAction.setDisabledIcon(Object, Icon)

setDisabledSelectedIcon

public void setDisabledSelectedIcon(K key,
                                    javax.swing.Icon icon)
Sets the icon that will be shown when the group key is disabled and selected. If the group does not exist, it will be created.

Parameters:
key - The name of the group
icon - The icon to display, when the group is selected and disabled, may be null

getDisabledSelectedIcon

public javax.swing.Icon getDisabledSelectedIcon(java.lang.Object key)
Gets the icon that is shown when the group key is selected and disabled.

Parameters:
key - The name of the group
Returns:
The disabled-selected-icon, may be null
Throws:
java.lang.IllegalArgumentException - if the group does not exist
See Also:
setDisabledSelectedIcon(Object, Icon)