de.esprit.netsuite.client.gui.action

## Class AgentAction<C extends ClientContext,A extends AsyncAgent>

- java.lang.Object
- - javax.swing.AbstractAction
  - - de.esprit.common.gui.ZAction<C>
    - - de.esprit.netsuite.client.gui.action.ClientAction<C>
      - - de.esprit.netsuite.client.gui.action.AgentAction<C,A>

- All Implemented Interfaces:
    ApplicationObject<C>, CancellableTask, ErrorHandlerSupport, SimpleLogSupport, java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action
  Direct Known Subclasses:
    AsyncAgentClientTimeoutAction, AsyncAgentServerTimeoutAction, CancelAllClientCommandsAction, CancelCurrentClientCommandsAction, DeleteLogMessagesAction, EverSleepingAsyncAgentAction, EverWorkingAsyncAgentAction, FetchUserListAction, FileSetDownloadAction, FileSetUploadAction, FillLogMessagesAction, ListDataAgentAction, NoReturnAsyncAgentAction, ProbeDataSourceAction, RoundTripAction, RoundTripDataAction, SequencedAsyncAgentAction, ServerShutdownAction, StreamDownloadAction, TimeCompareAction, ViewClientInfoAction, ViewRemoteTasksAction, ViewServerParamsAction, ViewServerStartupAction, ViewServerStatisticAction, ViewThreadPoolStatusAction

      public abstract class AgentAction<C extends ClientContext,A extends AsyncAgent>
      extends ClientAction<C>
      implements CancellableTask

  This Notify sends an agent to the server for execution. If the agent is async then the action blocks until the agent is received in a message.

  Blocking of the action depends on the async-timeout which is set in the agent. Shortly before the async-timeout expires on the server, the user is asked whether he wants to cancel the agent manually.

  Author:
    Rainer Buesch
  See Also:
    `AgentCancelAction`, 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
    `AgentAction(C clientCtx, NlsActionKey nls)`
    `AgentAction(C clientCtx, NlsActionKey nls, IconKey iconKey)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `actionFired(java.awt.event.ActionEvent e)` Is called when the action is fired.
    `protected void` | `agentFailed(A agent, java.lang.Exception error)` Is called finally when the agent response contains an Exception.
    `protected void` | `agentSucceeded(A agent)` Is called finally when the agent has succeeded.
    `void` | `cancel()`
    `protected abstract A` | `createInputAgent()` Creates the input agent to be sent to the server for execution.
    `protected void` | `handleBlockingTimeout()` Prompts for canceling the agent.
    `void` | `setBlockingTimeout(int seconds)` Defines the max blocking time for this action.
    `boolean` | `wasCancelled()` Tells whether ever an attempt has been made to cancel this task.

    - ### Methods inherited from class de.esprit.netsuite.client.gui.action.ClientAction

      `actionFailed, checkEnableCondition, getClientContext, getSessionId, isConnectionSensitive, isLoggedIn, isOffline, isOnline, setConnectionSensitive`

    - ### Methods inherited from class de.esprit.common.gui.ZAction

      `actionConfirmed, actionDenied, actionPerformed, actionPrepare, actionSucceeded, fire, getApplicationContext, getButtonText, getIcon, getLogChannel, getMenuText, getName, getPressedIcon, getTipText, isForced, isHandleError, isLogDebug, isLogVerbose, isPermitted, logDebug, logDump, logError, logError, logFatal, logInfo, logVerbose, logWarning, performAvailabilityCheck, setBusyAnimationEnabled, setHandleError, setIcon, setIcon, setLogChannel, setName, setPressedIcon, setPressedIcon, setText, setTipText, setValidator, showError, showError, showError, showInfo, showInfo, showWarning, showWarning, toString`

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

    - #### AgentAction

          public AgentAction(C clientCtx,
                     NlsActionKey nls)

    - #### AgentAction

          public AgentAction(C clientCtx,
                     NlsActionKey nls,
                     IconKey iconKey)

  - ### Method Detail

    - #### setBlockingTimeout

          public final void setBlockingTimeout(int seconds)

      Defines the max blocking time for this action. Only applicable if the agent runs async. Note that if the blocking timeout is not set, then the agents.getAsyncTimout() * TIMEOUT_SHORT_FACTOR is taken as default. If the agents async timeout is not set, then the action will block forever until the agent has finished or was cancelled.

      When the blocking timeout occurs, then the method `handleBlockingTimeout()` is called. You may override this method to implement your special reaction.

    - #### actionFired

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

      Description copied from class: `ZAction`
      Is called when the action is fired. It contains the code being executed by this action.
      Specified by:
        `actionFired` in class `ZAction<C extends ClientContext>`
      Throws:
        `java.lang.Exception`

    - #### agentFailed

          protected void agentFailed(A agent,
                         java.lang.Exception error)

      Is called finally when the agent response contains an Exception.
      Note: This method is only called if the response error of the agent has not been automatically handled yet by the `AgentErrorAdapter`.

    - #### agentSucceeded

          protected void agentSucceeded(A agent)

      Is called finally when the agent has succeeded. Default implementation is empty.

    - #### createInputAgent

          protected abstract A createInputAgent()

      Creates the input agent to be sent to the server for execution. This agent may be sync or async. An async agent will cause the action to disable until the result agent is received in a message, or the agent is cancelled.

    - #### handleBlockingTimeout

          protected void handleBlockingTimeout()

      Prompts for canceling the agent. If the agent is not cancelled then the blocking timer is restarted.

    - #### cancel

          public final void cancel()

    - #### wasCancelled

          public final boolean wasCancelled()

      Description copied from interface: `CancellableTask`
      Tells whether ever an attempt has been made to cancel this task.
      Specified by:
        `wasCancelled` in interface `CancellableTask`

Copyright © 2014 EsprIT-Systems. All Rights Reserved.