com.microfocus.awm.model.toolexecution

## Interface IToolExecutor2

- All Known Subinterfaces:
    IAsynchronousToolExecutor
  All Known Implementing Classes:
    AbstractCommandBasedToolExecutor, AbstractConvertedToolExecutor, CheckOSFileExistence, ChildrenRefresherToolExecutor, ClearApplicationFileCacheToolExecutor, ClearErrorFeedbackEntriesToolExecutor, CreateStaticElementListToolExecutor, CreateStructuredFileToolExecutor, EditCleanUpToolExecutor, ErrorFeedbackToolExecutor, LinkedPropertySetter, LocalFileCreatorToolExecutor, LocalFileLocatorToolExecutor, LocalTempFileCreatorToolExecutor, MergeStructuredFiles2, OSCommandToolExecutor2, ReturnPropertyValue2, TransferFile, ValidateLineLength, ValidateValue

      public interface IToolExecutor2

  Executes a modeled `ToolDescriptor` within an `ActionDescriptor` tool sequence.

  Tool executors can optionally override `init(IToolContext)` for initialization code.

  Author:
    Micro Focus

- - ### Method Summary

    All Methods Instance Methods Abstract Methods Default Methods
    Modifier and Type | Method and Description
    --- | ---
    `default IToolContext` | `createToolContext(IExecutionContext pExecutionContext, ToolDescriptor pToolDescriptor, boolean pIsMassProcessing)` This method creates a `IToolContext`.
    `IToolResult` | `executeMassProcessing(IMassProcessingToolContext pMassProcessingContext, org.eclipse.core.runtime.IProgressMonitor pMon)` Executes the tool for multiple resource.
    `IToolResult` | `executeSingleProcessing(IToolContext pToolContext, org.eclipse.core.runtime.IProgressMonitor pMon)` Executes the tool for a single resource.
    `default void` | `init(IToolContext pToolContext)` Initializes the tool executor before it is being executed.
    `default boolean` | `supportsMassProcessing()` Whether the tool executor supports mass processing execution.

- - ### Method Detail

    - #### init

          default void init(IToolContext pToolContext)
                     throws TaurusToolException

      Initializes the tool executor before it is being executed. This can be used process or validate tool descriptor attributes and parameters.
      Parameters:
        `pToolContext` - the tool context
      Throws:
        `TaurusToolException` - if the tool executor cannot be initialized for any reason

    - #### executeSingleProcessing

          IToolResult executeSingleProcessing(IToolContext pToolContext,
                                              org.eclipse.core.runtime.IProgressMonitor pMon)
                                       throws TaurusToolException

      Executes the tool for a single resource.

      A tool typically obtains values of modeled attributes and input parameters through the `IToolContext` (or `ToolUtility` helper methods), runs its specific function and returns all results (including possible output parameters) in the `IToolResult`.

      This method gets called if the tool is being executed from an `ActionDescriptor` with the `Mass Processing` attribute set to `false` or if `supportsMassProcessing()` returned `false`.

      The tool context contains all parameters, since their `Mass Processing` flags are ignored during single processing execution.

      Parameters:
        `pToolContext` - the tool context
        `pMon` - a progress monitor. Setting the monitor to `canceled` will cancel the action after the tool has been executed
      Returns:
        an `IToolResult`
      Throws:
        `TaurusToolException` - if the tool cannot be executed for any reason
      See Also:
        `ToolUtility`

    - #### executeMassProcessing

          IToolResult executeMassProcessing(IMassProcessingToolContext pMassProcessingContext,
                                            org.eclipse.core.runtime.IProgressMonitor pMon)
                                     throws TaurusToolException

      Executes the tool for multiple resource. In contrast to `executeSingleProcessing(IToolContext, IProgressMonitor)` the tool executor can process multiple resources with a single call.

      If the tool executor does not support mass processing execution (by returning `false` with `supportsMassProcessing()`), this method will never by called by AWM and can simply return `null`.

      The list of resources to be processed by the mass processing action can be obtained from the mass processing tool context via `IMassProcessingToolContext.getSubContexts()`.

      The `IMassProcessingToolContext` only contains parameters with the `Mass Processing` flag set to `false`. Mass processing parameters are contained by its sub-contexts.

      Parameters:
        `pMassProcessingContext` - the mass processing context
        `pMon` - a progress monitor. Setting the monitor to `canceled` will cancel the action after the tool has been executed
      Returns:
        an `IToolResult`. Can be `null` if `supportsMassProcessing()` returned `false`
      Throws:
        `TaurusToolException` - if the tool cannot be executed for any reason
      See Also:
        `ToolUtility`

    - #### supportsMassProcessing

          default boolean supportsMassProcessing()

      Whether the tool executor supports mass processing execution. Returns `true` by default.

      If `false` is returned, the tool executor cannot effectively process multiple resources (e.g. selected elements). This can be intended for tools not directly processing selected elements. In this case AWM will always call `executeSingleProcessing(IToolContext, IProgressMonitor)` and never `executeMassProcessing(IMassProcessingToolContext, IProgressMonitor)`.

      If applicable, tool executors should always aim for implementing mass processing support, since it can increase their usability in AWM models.

      Returns:
        `true` if the tool supports mass processing, otherwise `false`

    - #### createToolContext

          default IToolContext createToolContext(IExecutionContext pExecutionContext,
                                                 ToolDescriptor pToolDescriptor,
                                                 boolean pIsMassProcessing)
                                          throws TaurusToolException

      This method creates a `IToolContext`. By default an AWM internal `IMassProcessingToolContext` or single processing `IToolContext` is created.

      This method must return an `IMassProcessingToolContext`, if the isMassProcessing parameter is set to `true`. The support of mass processing can be disabled by returning `false` in the method `supportsMassProcessing()`.

      Parameters:
        `pExecutionContext` - the `IExecutionContext` which is used for the execution of the `ToolDescriptor`
        `pToolDescriptor` - the corresponding `ToolDescriptor`
        `pIsMassProcessing` - whether this `IToolExecutor2` should be executed as mass processing or not. If this parameter is set to `true`, this method has to return a `IMassProcessingToolContext`.
      Returns:
        the `IToolContext` which will be used for the execution of the `IToolExecutor2`.
      Throws:
        `TaurusToolException` - if an exception occurs while creating an `IToolContext`.

Copyright © 2015 Micro Focus GmbH. All rights reserved.