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:
DockAction, StandardDockAction
Direct Known Subclasses:
AbstractSimpleDropDownAction, CPanelPopup.PanelPopup, SimpleDropDownItemAction, SimpleMenuAction

public abstract class SimpleDockAction
extends AbstractStandardDockAction

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
 
Constructor Summary
SimpleDockAction()
           
 
Method Summary
protected  void bound(Dockable dockable)
          Invoked by this AbstractStandardDockAction when a Dockable was bound to this action the first time.
 javax.swing.KeyStroke getAccelerator()
          Gets the type of KeyEvent that must happen to trigger this action.
 javax.swing.Icon getDisabledIcon()
          Gets the icon that is shown when this action is not enabled.
 javax.swing.Icon getDisabledIcon(Dockable dockable)
          Gets the Icon of this DockAction, when this DockAction is shown together with dockable and 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.
 javax.swing.Icon getIcon()
          Gets the default-icon that is shown for this action.
 javax.swing.Icon getIcon(Dockable dockable)
          Gets the Icon of this DockAction, when this DockAction is shown together with dockable.
 java.lang.String getText()
          Gets the text that is shown for this action.
 java.lang.String getText(Dockable dockable)
          Gets the text of this DockActon, when this DockAction is shown together with dockable.
 java.lang.String getTooltip()
          Gets the first part of the toopltip-text that is shown for this action.
 java.lang.String getTooltipText()
          Gets the text that should be shown as tooltip of this action.
 java.lang.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)
          Tells whether this DockAction can be triggered together with the dockable.
 void setAccelerator(javax.swing.KeyStroke accelerator)
          Sets the type of event that will trigger this action.
 void setDisabledIcon(javax.swing.Icon disabledIcon)
          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(javax.swing.Icon icon)
          Sets the default-icon for this action.
 void setText(java.lang.String text)
          Sets the text which is shown for this action.
 void setTooltip(java.lang.String tooltip)
          Sets the first part of the tooltip-text which is shown for this action.
protected  boolean trigger(java.awt.event.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, 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.DockAction
createView, trigger
 

Constructor Detail

SimpleDockAction

public SimpleDockAction()
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 javax.swing.Icon getIcon(Dockable dockable)
Description copied from interface: StandardDockAction
Gets the Icon of this DockAction, when this DockAction is shown together with dockable.

Parameters:
dockable - The Dockable for which the action-icon should be chosen.
Returns:
The icon to show for this action when the action is associated with dockable, or null.

getText

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

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 java.lang.String getText()
Gets the text that is shown for this action.

Returns:
The text of this action, may be null
See Also:
setText(String)

setText

public void setText(java.lang.String text)
Sets the text which is shown for this action.

Parameters:
text - The text to show, or null

getTooltipText

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

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 java.lang.String getTooltipText()
Gets the text that should be shown as tooltip of this action. This text contains the value of getTooltip(), but also additional information like the accelerator

Returns:
the full tooltip text

getTooltip

public java.lang.String getTooltip()
Gets the first part of the toopltip-text that is shown for this action.

Returns:
The client defined part of the tooltip
See Also:
setTooltip(String)

setTooltip

public void setTooltip(java.lang.String tooltip)
Sets the first part of the tooltip-text which is shown for this action.

Parameters:
tooltip - The client defined part of the tooltip for this action

isEnabled

public boolean isEnabled(Dockable dockable)
Description copied from interface: StandardDockAction
Tells whether this DockAction can be triggered together with the dockable.

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()
Gets the enabled-state for this action. Only an action that is enabled can be triggered.

Returns:
true if this action can be triggered, false otherwise
See Also:
setEnabled(boolean)

setEnabled

public void setEnabled(boolean enabled)
Sets the enabled-state of this action. This action can be triggered only if it is enabled.

Parameters:
enabled - The state

getIcon

public javax.swing.Icon getIcon()
Gets the default-icon that is shown for this action.

Returns:
The icon, may be null
See Also:
setIcon(Icon)

setIcon

public void setIcon(javax.swing.Icon icon)
Sets the default-icon for this action. This icon will be shown when no other icon fits the current states of the action.

Parameters:
icon - The icon, can be null

getDisabledIcon

public javax.swing.Icon getDisabledIcon()
Gets the icon that is shown when this action is not enabled.

Returns:
The disabled-icon, may be null
See Also:
setDisabledIcon(Icon), isEnabled()

getDisabledIcon

public javax.swing.Icon getDisabledIcon(Dockable dockable)
Description copied from interface: StandardDockAction
Gets the Icon of this DockAction, when this DockAction is shown together with dockable and is not enabled.

Parameters:
dockable - The Dockable for which the action-icon should be chosen.
Returns:
The icon to show for this action when the action is associated with dockable, or null.

setDockableRepresentation

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

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.

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()
Gets the Dockable which is represented by this DockAction.

Returns:
the element, can be null
See Also:
getDockableRepresentation(Dockable)

setDisabledIcon

public void setDisabledIcon(javax.swing.Icon disabledIcon)
Sets an icon that will be shown when this action is not enabled.

Parameters:
disabledIcon - The disabled-icon, can be null
See Also:
setEnabled(boolean)

getAccelerator

public javax.swing.KeyStroke getAccelerator()
Gets the type of KeyEvent that must happen to trigger this action.

Returns:
the type of event or null

setAccelerator

public void setAccelerator(javax.swing.KeyStroke accelerator)
Sets the type of event that will trigger this action.

Parameters:
accelerator - the type of event or null.

trigger

protected boolean trigger(java.awt.event.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.