bibliothek.gui.dock.action.actions
Class SimpleDockAction

java.lang.Object
  extended by bibliothek.gui.dock.action.actions.AbstractStandardDockAction
      extended by bibliothek.gui.dock.action.actions.SimpleDockAction
All Implemented Interfaces:
SharingStandardDockAction, DockAction, StandardDockAction
Direct Known Subclasses:
AbstractSimpleDropDownAction, SimpleDropDownItemAction, SimpleMenuAction

public abstract class SimpleDockAction
extends AbstractStandardDockAction
implements SharingStandardDockAction

A simple implementation of DockAction. This action uses for all associated Dockables the same settings.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from class bibliothek.gui.dock.action.actions.AbstractStandardDockAction
listeners
 
Fields inherited from interface bibliothek.gui.dock.action.DockAction
BUTTON_CONTENT_FILTER
 
Constructor Summary
SimpleDockAction(boolean monitorDisabling)
          Creates a new action
 
Method Summary
protected  void bound(Dockable dockable)
          Invoked by this AbstractStandardDockAction when a Dockable was bound to this action the first time.
 KeyStroke getAccelerator()
          Gets the type of KeyEvent that must happen to trigger this action.
 Icon getDisabledIcon()
          Gets the icon that is shown when this action is not enabled.
 Dockable getDockableRepresentation()
          Gets the Dockable which is represented by this DockAction.
 Dockable getDockableRepresentation(Dockable dockable)
          Tells whether this DockAction represents a Dockable.
 Icon getIcon()
          Gets the default-icon that is shown for this action.
 Icon getIcon(ActionContentModifier modifier)
          Gets the icon which is shown if the conditions of modifier are met.
 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.
 String getText()
          Gets the text that is shown for this action.
 String getText(Dockable dockable)
          Gets the text of this DockActon, when this DockAction is shown together with dockable.
 String getTooltip()
          Gets the first part of the toopltip-text that is shown for this action.
 String getTooltipText()
          Gets the text that should be shown as tooltip of this action.
 String getTooltipText(Dockable dockable)
          Gets a tooltip for this DockActon, when this DockAction is shown together with dockable.
 boolean isEnabled()
          Gets the enabled-state for this action.
 boolean isEnabled(Dockable dockable)
          This method chooses the result according to the current DisablingStrategy.
 void setAccelerator(KeyStroke accelerator)
          Sets the type of event that will trigger this action.
 void setDisabledIcon(Icon icon)
          Sets an icon that will be shown when this action is not enabled.
 void setDockableRepresentation(Dockable dockable)
          Sets the Dockable which is represented by this DockAction.
 void setEnabled(boolean enabled)
          Sets the enabled-state of this action.
 void setIcon(ActionContentModifier modifier, Icon icon)
          Sets the icon that is to be used when the conditions of modifier are met.
 void setIcon(Icon icon)
          Sets the default-icon for this action.
 void setText(String text)
          Sets the text which is shown for this action.
 void setTooltip(String tooltip)
          Sets the first part of the tooltip-text which is shown for this action.
protected  boolean trigger(KeyEvent event, Dockable dockable)
          Called when the user hit the accelerator.
protected  void unbound(Dockable dockable)
          Called by this AbstractStandardDockAction when the Dockable dockable will not be used in any means by this action.
 
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.StandardDockAction
addDockActionListener, removeDockActionListener
 
Methods inherited from interface bibliothek.gui.dock.action.DockAction
bind, createView, trigger, unbind
 

Constructor Detail

SimpleDockAction

public SimpleDockAction(boolean monitorDisabling)
Creates a new action

Parameters:
monitorDisabling - whether the current DisablingStrategy should be monitored
Method Detail

bound

protected void bound(Dockable dockable)
Description copied from class: AbstractStandardDockAction
Invoked by this AbstractStandardDockAction when a Dockable was bound to this action the first time.

Overrides:
bound in class AbstractStandardDockAction
Parameters:
dockable - The Dockable that was not known to this action before the method was invoked

unbound

protected void unbound(Dockable dockable)
Description copied from class: AbstractStandardDockAction
Called by this AbstractStandardDockAction when the Dockable dockable will not be used in any means by this action. Note that the AbstractStandardDockAction.bound(Dockable)-method can be invoked again with the dockable.

Overrides:
unbound in class AbstractStandardDockAction
Parameters:
dockable - The Dockable which will not by used in any way.

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
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.

getText

public String getText(Dockable dockable)
Description copied from interface: StandardDockAction
Gets the text of this DockActon, when this DockAction is shown together with dockable.

Specified by:
getText in interface StandardDockAction
Parameters:
dockable - The Dockable for which the action-text should be chosen.
Returns:
The text to show for this action when the action is associated with dockable, or null.

getText

public String getText()
Description copied from interface: SharingStandardDockAction
Gets the text that is shown for this action.

Specified by:
getText in interface SharingStandardDockAction
Returns:
The text of this action, may be null
See Also:
SharingStandardDockAction.setText(String)

setText

public void setText(String text)
Description copied from interface: SharingStandardDockAction
Sets the text which is shown for this action.

Specified by:
setText in interface SharingStandardDockAction
Parameters:
text - The text to show, or null

getTooltipText

public String getTooltipText(Dockable dockable)
Description copied from interface: StandardDockAction
Gets a tooltip for this DockActon, when this DockAction is shown together with dockable.

Specified by:
getTooltipText in interface StandardDockAction
Parameters:
dockable - The Dockable for which the action-tooltip should be chosen.
Returns:
The tooltip to show for this action when the action is associated with dockable, or null.

getTooltipText

public String getTooltipText()
Description copied from interface: SharingStandardDockAction
Gets the text that should be shown as tooltip of this action. This text contains the value of SharingStandardDockAction.getTooltip(), but also additional information like the accelerator

Specified by:
getTooltipText in interface SharingStandardDockAction
Returns:
the full tooltip text

getTooltip

public String getTooltip()
Description copied from interface: SharingStandardDockAction
Gets the first part of the toopltip-text that is shown for this action.

Specified by:
getTooltip in interface SharingStandardDockAction
Returns:
The client defined part of the tooltip
See Also:
SharingStandardDockAction.setTooltip(String)

setTooltip

public void setTooltip(String tooltip)
Description copied from interface: SharingStandardDockAction
Sets the first part of the tooltip-text which is shown for this action.

Specified by:
setTooltip in interface SharingStandardDockAction
Parameters:
tooltip - The client defined part of the tooltip for this action

isEnabled

public boolean isEnabled(Dockable dockable)
Description copied from class: AbstractStandardDockAction
This method chooses the result according to the current DisablingStrategy.

Specified by:
isEnabled in interface StandardDockAction
Overrides:
isEnabled in class AbstractStandardDockAction
Parameters:
dockable - The Dockable for which this action maybe triggered.
Returns:
true if the user should be able to trigger this action, false otherwise

isEnabled

public boolean isEnabled()
Description copied from interface: SharingStandardDockAction
Gets the enabled-state for this action. Only an action that is enabled can be triggered.

Specified by:
isEnabled in interface SharingStandardDockAction
Returns:
true if this action can be triggered, false otherwise
See Also:
SharingStandardDockAction.setEnabled(boolean)

setEnabled

public void setEnabled(boolean enabled)
Description copied from interface: SharingStandardDockAction
Sets the enabled-state of this action. This action can be triggered only if it is enabled.

Specified by:
setEnabled in interface SharingStandardDockAction
Parameters:
enabled - The state

getIcon

public Icon getIcon()
Description copied from interface: SharingStandardDockAction
Gets the default-icon that is shown for this action.

Specified by:
getIcon in interface SharingStandardDockAction
Returns:
The icon, may be null
See Also:
SharingStandardDockAction.setIcon(Icon)

setIcon

public void setIcon(Icon icon)
Description copied from interface: SharingStandardDockAction
Sets the default-icon for this action. This icon will be shown when no other icon fits the current states of the action.

Specified by:
setIcon in interface SharingStandardDockAction
Parameters:
icon - The icon, can be null

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
Parameters:
dockable - the Dockable for which the action-icons may be chosen.
Returns:
the contexts in which an icon is present

getDisabledIcon

public Icon getDisabledIcon()
Description copied from interface: SharingStandardDockAction
Gets the icon that is shown when this action is not enabled.

Specified by:
getDisabledIcon in interface SharingStandardDockAction
Returns:
The disabled-icon, may be null
See Also:
SharingStandardDockAction.setDisabledIcon(Icon), SharingStandardDockAction.isEnabled()

setDisabledIcon

public void setDisabledIcon(Icon icon)
Description copied from interface: SharingStandardDockAction
Sets an icon that will be shown when this action is not enabled.

Specified by:
setDisabledIcon in interface SharingStandardDockAction
Parameters:
icon - The disabled-icon, can be null
See Also:
SharingStandardDockAction.setEnabled(boolean)

getIcon

public Icon getIcon(ActionContentModifier modifier)
Gets the icon which is shown if the conditions of modifier are met.

Specified by:
getIcon in interface SharingStandardDockAction
Parameters:
modifier - the conditions to met
Returns:
the icon to show or null if not set

setIcon

public void setIcon(ActionContentModifier modifier,
                    Icon icon)
Sets the icon that is to be used when the conditions of modifier are met.

Specified by:
setIcon in interface SharingStandardDockAction
Parameters:
modifier - the conditions to met
icon - the icon to use or null

setDockableRepresentation

public void setDockableRepresentation(Dockable dockable)
Description copied from interface: SharingStandardDockAction
Sets the Dockable which is represented by this DockAction. Some views of this DockAction will register themselves as DockElementRepresentative representing dockable.

Specified by:
setDockableRepresentation in interface SharingStandardDockAction
Parameters:
dockable - the new representation, can be null

getDockableRepresentation

public Dockable getDockableRepresentation(Dockable dockable)
Description copied from interface: StandardDockAction
Tells whether this DockAction represents a Dockable. If so, the framework may register views for this action as DockElementRepresentative.

Specified by:
getDockableRepresentation in interface StandardDockAction
Parameters:
dockable - The Dockable for which this action may be triggered
Returns:
the Dockable which is represented by this action, can be null. Normally dockable should not be the result.

getDockableRepresentation

public Dockable getDockableRepresentation()
Description copied from interface: SharingStandardDockAction
Gets the Dockable which is represented by this DockAction.

Specified by:
getDockableRepresentation in interface SharingStandardDockAction
Returns:
the element, can be null
See Also:
StandardDockAction.getDockableRepresentation(Dockable)

getAccelerator

public KeyStroke getAccelerator()
Description copied from interface: SharingStandardDockAction
Gets the type of KeyEvent that must happen to trigger this action.

Specified by:
getAccelerator in interface SharingStandardDockAction
Returns:
the type of event or null

setAccelerator

public void setAccelerator(KeyStroke accelerator)
Description copied from interface: SharingStandardDockAction
Sets the type of event that will trigger this action.

Specified by:
setAccelerator in interface SharingStandardDockAction
Parameters:
accelerator - the type of event or null.

trigger

protected boolean trigger(KeyEvent event,
                          Dockable dockable)
Called when the user hit the accelerator. This method directly calls trigger( dockable ), subclasses might override this method to further analyze event.

Parameters:
event - the triggering event
dockable - the source of the event
Returns:
true if this action could do anything, false if this action was not able to react in any way to the event.