de.esprit.common.gui

## Class ZAction<C extends ApplicationContext>

- java.lang.Object
- - javax.swing.AbstractAction
  - - de.esprit.common.gui.ZAction<C>

- All Implemented Interfaces:
    ApplicationObject<C>, ErrorHandlerSupport, SimpleLogSupport, java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
  Direct Known Subclasses:
    AbstractTextEditAction, ActionLookAndFeelMetal, ActionLookAndFeelMotif, ActionLookAndFeelWindows, AddPermissionAction, AgentCancelAction, AllFieldsPanel.MyCheckValuesAction, ApplicationToolAction, ApplyAndCloseAction, CancelAction, CleanupMemoryAction, ClearAction, ClientAction, ConsoleAction, ListDataAction, RemovePermissionAction, ScreenShotAction, SetRootNodeAction, StepAction, TableDataAction, TaskAction, TaskCancelAction, TestLoggingAction, ToolAction, TreeSelectionAction

      public abstract class ZAction<C extends ApplicationContext>
      extends javax.swing.AbstractAction
      implements ApplicationObject<C>, SimpleLogSupport, ErrorHandlerSupport

  This is the base class for all GUI actions. It extends the Java `Action` concept for localized actions. This class supports three translated presentation strings for an action which are: BUTTON_TEXT, MENU_TEXT and TIP_TEXT, all of which can be set with the according methods.
  If the action is fired it automatically sets and resets the Wait-cursor on the current Frame or Dialog.
  Note that a ZAction has got a unique name which does not appear in the GUI but is used for action tracing only. Also note that subclasses must override ``actionFired(ActionEvent)`` for implementing an action (instead of `actionPerformed(ActionEvent)`).
  Author:
    Rainer Buesch
  See Also:
    Serialized Form

- - ### Field Summary

    - ### Fields inherited from class javax.swing.AbstractAction

      `changeSupport, enabled`

    - ### Fields inherited from interface javax.swing.Action

      `ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ZAction(C ctx, NlsActionKey nlsKey)`
    `ZAction(C ctx, NlsActionKey nlsKey, ActionValidator validator)`
    `ZAction(C ctx, NlsActionKey nlsKey, IconKey iconKey)`
    `ZAction(C ctx, NlsActionKey nlsKey, IconKey iconKey, ActionValidator validator)`
    `ZAction(C ctx, java.lang.String untranslatedName)`
    `ZAction(NlsActionKey nlsKey)`
    `ZAction(NlsActionKey nlsKey, ActionValidator validator)`
    `ZAction(NlsActionKey nlsKey, IconKey iconKey)`
    `ZAction(NlsActionKey nlsKey, IconKey iconKey, ActionValidator validator)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected boolean` | `actionConfirmed()` Can be overridden to pop up a ConfirmDialog.
    `protected void` | `actionDenied(java.lang.Exception e)` Is called when the action was tried to execute without having permission.
    `protected void` | `actionFailed(java.lang.Exception e)` Is called when the action has thrown an Exception.
    `protected abstract void` | `actionFired(java.awt.event.ActionEvent e)` Is called when the action is fired.
    `void` | `actionPerformed(java.awt.event.ActionEvent e)` Cannot be overridden, subclasses must implement `actionFired(ActionEvent)` instead.
    `protected void` | `actionPrepare()` Runs sync BEFORE the `actionFired(ActionEvent)` method is called.
    `protected void` | `actionSucceeded()` Is called when the action has been executed successfully
    `protected boolean` | `checkEnableCondition()` This condition is evaluated automatically after construction.
    `void` | `fire()` Convenience method for firing this action
    `C` | `getApplicationContext()`
    `java.lang.String` | `getButtonText()` Returns the translated button text.
    `javax.swing.Icon` | `getIcon()` Returns icon for this action.
    `LogChannel` | `getLogChannel()`
    `java.lang.String` | `getMenuText()` Returns the translated menu text.
    `java.lang.String` | `getName()` Returns the unique name (untranslated) of this action.
    `javax.swing.Icon` | `getPressedIcon()` Returns icon for the pressed button state.
    `java.lang.String` | `getTipText()` Returns the translated tooltip text.
    `boolean` | `isForced()` Tells whether the action Confirmation should be suppressed.
    `boolean` | `isHandleError()`
    `boolean` | `isLogDebug()`
    `boolean` | `isLogVerbose()`
    `boolean` | `isPermitted()` Returns true if the current validator allows this action
    `void` | `logDebug(java.lang.String message)`
    `void` | `logDump(java.lang.String message)`
    `void` | `logError(java.lang.String message)`
    `void` | `logError(java.lang.String message, java.lang.Exception e)`
    `void` | `logFatal(java.lang.String message, java.lang.Exception e)`
    `void` | `logInfo(java.lang.String message)`
    `void` | `logVerbose(java.lang.String message)`
    `void` | `logWarning(java.lang.String message)`
    `void` | `performAvailabilityCheck()` Enables/disables the action according to its enable condition.
    `void` | `setBusyAnimationEnabled(boolean useBusyAnim)` If set to true then the action shows up with a `BusyAnimationWindow` during execution.
    `void` | `setHandleError(boolean isHandleError)`
    `void` | `setIcon(javax.swing.Icon icon)` Sets an icon for this action.
    `void` | `setIcon(IconKey iconKey)` Sets an icon for this action
    `void` | `setLogChannel(LogChannel logCh)`
    `void` | `setName(java.lang.String actionName)` Sets the unique name for this action, mainly for debugging purpose.
    `void` | `setPressedIcon(javax.swing.Icon icon)` Sets an pressed icon for this action which is shown when a button is pressed.
    `void` | `setPressedIcon(IconKey iconKey)`
    `void` | `setText(NlsKey nls)` Sets the text that is used to present this action in a button.
    `void` | `setTipText(java.lang.String tipText)` Allows for setting the tip text independent of any NlsKey
    `ZAction` | `setValidator(ActionValidator newValidator)` Sets the validator for this action.
    `void` | `showError(java.lang.Exception e)`
    `void` | `showError(java.lang.String message, java.lang.Exception e)`
    `void` | `showError(java.lang.String message, java.lang.String details, java.lang.Exception e)`
    `void` | `showInfo(java.lang.String message)`
    `void` | `showInfo(java.lang.String message, java.lang.String details)`
    `void` | `showWarning(java.lang.String message)`
    `void` | `showWarning(java.lang.String message, java.lang.String details)`
    `java.lang.String` | `toString()` Returns a string representation of this action - same as getName().

    - ### Methods inherited from class javax.swing.AbstractAction

      `addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ZAction

          public ZAction(NlsActionKey nlsKey,
                 IconKey iconKey)

    - #### ZAction

          public ZAction(NlsActionKey nlsKey)

    - #### ZAction

          public ZAction(NlsActionKey nlsKey,
                 ActionValidator validator)

    - #### ZAction

          public ZAction(NlsActionKey nlsKey,
                 IconKey iconKey,
                 ActionValidator validator)

    - #### ZAction

          public ZAction(C ctx,
                 java.lang.String untranslatedName)

    - #### ZAction

          public ZAction(C ctx,
                 NlsActionKey nlsKey)

    - #### ZAction

          public ZAction(C ctx,
                 NlsActionKey nlsKey,
                 ActionValidator validator)

    - #### ZAction

          public ZAction(C ctx,
                 NlsActionKey nlsKey,
                 IconKey iconKey)

    - #### ZAction

          public ZAction(C ctx,
                 NlsActionKey nlsKey,
                 IconKey iconKey,
                 ActionValidator validator)

  - ### Method Detail

    - #### getApplicationContext

          public final C getApplicationContext()

      Specified by:
        `getApplicationContext` in interface `ApplicationObject<C extends ApplicationContext>`

    - #### performAvailabilityCheck

          public final void performAvailabilityCheck()

      Enables/disables the action according to its enable condition.
      See Also:
        `checkEnableCondition()`

    - #### isHandleError

          public final boolean isHandleError()

    - #### setHandleError

          public final void setHandleError(boolean isHandleError)

    - #### setBusyAnimationEnabled

          public final void setBusyAnimationEnabled(boolean useBusyAnim)

      If set to true then the action shows up with a `BusyAnimationWindow` during execution.

    - #### setIcon

          public final void setIcon(IconKey iconKey)

      Sets an icon for this action

    - #### setIcon

          public final void setIcon(javax.swing.Icon icon)

      Sets an icon for this action.

    - #### setPressedIcon

          public final void setPressedIcon(javax.swing.Icon icon)

      Sets an pressed icon for this action which is shown when a button is pressed.

    - #### setPressedIcon

          public final void setPressedIcon(IconKey iconKey)

    - #### getIcon

          public final javax.swing.Icon getIcon()

      Returns icon for this action.

    - #### getPressedIcon

          public final javax.swing.Icon getPressedIcon()

      Returns icon for the pressed button state.

    - #### setName

          public final void setName(java.lang.String actionName)

      Sets the unique name for this action, mainly for debugging purpose.

    - #### setText

          public final void setText(NlsKey nls)

      Sets the text that is used to present this action in a button. Note that the argument must be a translation key.

    - #### setTipText

          public final void setTipText(java.lang.String tipText)

      Allows for setting the tip text independent of any NlsKey

    - #### getName

          public java.lang.String getName()

      Returns the unique name (untranslated) of this action.

    - #### getTipText

          public final java.lang.String getTipText()

      Returns the translated tooltip text.

    - #### getButtonText

          public final java.lang.String getButtonText()

      Returns the translated button text.

    - #### getMenuText

          public final java.lang.String getMenuText()

      Returns the translated menu text.

    - #### toString

          public java.lang.String toString()

      Returns a string representation of this action - same as getName().
      Overrides:
        `toString` in class `java.lang.Object`

    - #### actionPerformed

          public final void actionPerformed(java.awt.event.ActionEvent e)

      Cannot be overridden, subclasses must implement `actionFired(ActionEvent)` instead.
      Specified by:
        `actionPerformed` in interface `java.awt.event.ActionListener`

    - #### fire

          public final void fire()

      Convenience method for firing this action

    - #### actionPrepare

          protected void actionPrepare()
                                throws java.lang.Exception

      Runs sync BEFORE the `actionFired(ActionEvent)` method is called. Any preconditional checks or settings may be implemented here.
      Throws:
        `java.lang.Exception`

    - #### actionConfirmed

          protected boolean actionConfirmed()

      Can be overridden to pop up a ConfirmDialog. If false is returned the action is not fired.

    - #### actionFired

          protected abstract void actionFired(java.awt.event.ActionEvent e)
                                       throws java.lang.Exception

      Is called when the action is fired. It contains the code being executed by this action.
      Throws:
        `java.lang.Exception`

    - #### actionFailed

          protected void actionFailed(java.lang.Exception e)

      Is called when the action has thrown an Exception. By default pops up an error dialog. May be overridden to handle the Exception in a different way.

    - #### actionDenied

          protected void actionDenied(java.lang.Exception e)

      Is called when the action was tried to execute without having permission. Pops up an according error message by default.

    - #### actionSucceeded

          protected void actionSucceeded()

      Is called when the action has been executed successfully

    - #### checkEnableCondition

          protected boolean checkEnableCondition()

      This condition is evaluated automatically after construction. The action enables/disables accordingly. Does not change the current enable state by default.

    - #### isPermitted

          public final boolean isPermitted()

      Returns true if the current validator allows this action

    - #### isForced

          public final boolean isForced()

      Tells whether the action Confirmation should be suppressed. By default returns true if the the SHIFT or CNTRL key is pressed.

    - #### setValidator

          public final ZAction setValidator(ActionValidator newValidator)

      Sets the validator for this action. Setting this to null actually resets to the defaultValidator.

    - #### setLogChannel

          public final void setLogChannel(LogChannel logCh)

      Specified by:
        `setLogChannel` in interface `SimpleLogSupport`

    - #### getLogChannel

          public final LogChannel getLogChannel()

      Specified by:
        `getLogChannel` in interface `SimpleLogSupport`

    - #### isLogDebug

          public final boolean isLogDebug()

      Specified by:
        `isLogDebug` in interface `SimpleLogSupport`

    - #### isLogVerbose

          public final boolean isLogVerbose()

      Specified by:
        `isLogVerbose` in interface `SimpleLogSupport`

    - #### logFatal

          public final void logFatal(java.lang.String message,
                      java.lang.Exception e)

      Specified by:
        `logFatal` in interface `SimpleLogSupport`

    - #### logError

          public final void logError(java.lang.String message,
                      java.lang.Exception e)

      Specified by:
        `logError` in interface `SimpleLogSupport`

    - #### logError

          public final void logError(java.lang.String message)

      Specified by:
        `logError` in interface `SimpleLogSupport`

    - #### logWarning

          public final void logWarning(java.lang.String message)

      Specified by:
        `logWarning` in interface `SimpleLogSupport`

    - #### logInfo

          public final void logInfo(java.lang.String message)

      Specified by:
        `logInfo` in interface `SimpleLogSupport`

    - #### logVerbose

          public final void logVerbose(java.lang.String message)

      Specified by:
        `logVerbose` in interface `SimpleLogSupport`

    - #### logDebug

          public final void logDebug(java.lang.String message)

      Specified by:
        `logDebug` in interface `SimpleLogSupport`

    - #### logDump

          public final void logDump(java.lang.String message)

      Specified by:
        `logDump` in interface `SimpleLogSupport`

    - #### showError

          public final void showError(java.lang.Exception e)

      Specified by:
        `showError` in interface `ErrorHandlerSupport`

    - #### showError

          public final void showError(java.lang.String message,
                       java.lang.Exception e)

      Specified by:
        `showError` in interface `ErrorHandlerSupport`

    - #### showError

          public final void showError(java.lang.String message,
                       java.lang.String details,
                       java.lang.Exception e)

      Specified by:
        `showError` in interface `ErrorHandlerSupport`

    - #### showInfo

          public final void showInfo(java.lang.String message,
                      java.lang.String details)

      Specified by:
        `showInfo` in interface `ErrorHandlerSupport`

    - #### showInfo

          public final void showInfo(java.lang.String message)

      Specified by:
        `showInfo` in interface `ErrorHandlerSupport`

    - #### showWarning

          public final void showWarning(java.lang.String message,
                         java.lang.String details)

      Specified by:
        `showWarning` in interface `ErrorHandlerSupport`

    - #### showWarning

          public final void showWarning(java.lang.String message)

      Specified by:
        `showWarning` in interface `ErrorHandlerSupport`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.