public class ActionExecutor
extends java.lang.Object
ActionDescriptors.
Executing an Action will create an IExecutionContext, which uniquely
saves every available Property in its context (which will be an
IResource most of the times). This context can be filled with
additional Properties programmatically. Furthermore the IExecutionContext
stores every single output parameter from any executed tool during the action
execution.
The ActionExecutor also creates an element list, if the following conditions are met:
Get Children or
Get Root Containers action, or:
Has Elementlist reference
to an element list structure.
The ActionExecutor also checks for the tool's return codes, processes
exceptions, return codes and ResourceOperations returned by tools.
Not intended to be sub-classed by clients.
IToolExecutor2,
ToolDescriptor| Modifier and Type | Class and Description |
|---|---|
class |
ActionExecutor.ActionExecutorJob
Implementation of
Job to execute an ActionDescriptor in
the background. |
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
TOOL_EXECUTOR_EXT_POINT_ID |
| Constructor and Description |
|---|
ActionExecutor(ActionDescriptor pActDescr,
IExecutionContext pContext)
Basic constructor.
|
ActionExecutor(ActionDescriptor pActDescr,
ISystemImage pImg,
IResource pRes)
Creates an ActionExecutor instance with a single
IResource as
context. |
ActionExecutor(ActionDescriptor pActDescr,
ISystemImage pImg,
java.util.List<IResource> pResources)
Creates an ActionExecutor instance with multiple
IResources as
context. |
ActionExecutor(ITaurusJob pJob,
IExecutionContext pContext)
Constructor for creating an action descriptor for a "run as job after
action".
|
| Modifier and Type | Method and Description |
|---|---|
static void |
addActionListener(TaurusActionListener pListener)
Adds a
TaurusActionListener to the executor. |
static java.lang.String |
createActionExecutionExceptionMessage(ActionDescriptor pActDescr)
Creates a general error message when the execution of an action
descriptor fails with an exception.
|
static java.lang.String |
createActionExecutionExceptionMessage(ActionDescriptor pActDescr,
java.lang.Throwable pE)
Creates a general error message when the execution of an action
descriptor fails with an exception.
|
static java.util.Map<java.lang.String,ToolTypeExtension> |
createToolTypeMap()
Creates and returns a map of all available tool types and their
corresponding tool executors.
|
ActionExecutorResult |
execute(org.eclipse.core.runtime.IProgressMonitor pMon)
Executes the action.
|
static IAction |
executeAction(IExecutionContext pActionContext,
ActionDescriptor pActDesc,
org.eclipse.core.runtime.IProgressMonitor pMon)
Deprecated.
Not thread safe and doesn't throw exceptions. Use any of the
create(...) methods to create an action executor instance and
then
execute(IProgressMonitor) instead. |
static IAction |
executeAction(ISystemImage pImg,
IResource pRes,
ActionDescriptor pTauAction,
org.eclipse.core.runtime.IProgressMonitor pMon)
Deprecated.
Not thread safe and doesn't throw exceptions. Use any of the
create(...) methods to create an action executor instance and
then
execute(IProgressMonitor) instead. |
static IAction |
executeAction(ISystemImage pImg,
java.util.List<IResource> pResources,
ActionDescriptor pActDescr,
org.eclipse.core.runtime.IProgressMonitor pMon)
Deprecated.
Not thread safe and doesn't throw exceptions. Use any of the
create(...) methods to create an action executor instance and
then
execute(IProgressMonitor) instead. |
IAction |
executeWithWait(org.eclipse.core.runtime.IProgressMonitor pMon)
Executes the action and waits for it to finish if its execution mode was
EActionExecutionMode.MODELESS. |
ActionDescriptor |
getActionDescriptor()
Gets the the
ActionDescriptor of the action executor instance. |
static java.util.List<TaurusActionListener> |
getActionListeners()
Returns the list of registered action listeners.
|
static java.util.List<IValidationMessage> |
getAllValidationMessages(IAction pValActionResult)
Gets all validation messages returned by all tools of an executed action.
|
IExecutionContext |
getContext()
Gets the the
IExecutionContext of the action executor instance. |
static int |
getModelessRunningCount()
Gets the the number of ActionExecutorJobs currently running.
|
static java.lang.String |
getParameterValue(RToolInParameter pInparm,
IExecutionContext pContext)
|
static void |
handleActionExcecutionException(TaurusException pExpception,
ActionDescriptor pActDescr,
IExecutionContext pContext)
Handles how the given exception occurred during execution of the given
action descriptor should be processed.
|
static void |
handleFileOutput(IToolContext pToolContext,
IExecutionContext pExecutionContext,
FileDescriptor targetIDFile,
java.lang.Object pOutparmValue)
Handles a returned file output parameter by "describing" the referenced
file descriptor and adding it to the parameter memory.
|
static boolean |
isMassProcessing(IExecutionContext pContext,
ToolDescriptor pTool)
Returns whether the action descriptor of the given context was modelled
with
"Mass Processing = true. |
boolean |
isParallelExecutionAllowed()
Returns whether executed MODELESS actions of this instance can run
simunltaniously with other actions.
|
static ResourceOperation |
parseResourceOperation(ToolDescriptor pTool,
java.lang.String pLine,
IExecutionContext pContext)
Deprecated.
this method uses deprecated tool descriptor attributes. Use
AbstractCommandBasedToolExecutor.parseResourceOperation(ToolDescriptor, String, String, List, IExecutionContext)
instead. |
static ValidateMessage |
parseValidateMessage(java.lang.String pLine)
Tries to parse a validate message from the given line.
|
static boolean |
removeActionListener(TaurusActionListener pListener)
Removes a
TaurusActionEvent from the list of listeners. |
void |
setParallelExecutionAllowed(boolean pParallelExecution)
Sets whether executed MODELESS actions of this instance can run
simunltaniously to other actions.
|
static void |
setParmFilePath(java.lang.String pParmFilePath)
|
void |
setSkipModelUpdateCheck(boolean pSkipModelUpdateCheck)
Set whether the model update check should be skipped.
|
static void |
setTool(ToolDescriptor pTool)
|
public static final java.lang.String TOOL_EXECUTOR_EXT_POINT_ID
public ActionExecutor(ActionDescriptor pActDescr, IExecutionContext pContext)
pActDescr - the action descriptor.pContext - the context.public ActionExecutor(ActionDescriptor pActDescr, ISystemImage pImg, IResource pRes)
IResource as
context.pActDescr - the action descriptor.pImg - the system image.pRes - the resource to create the context from.ActionExecutor(ActionDescriptor, IExecutionContext)public ActionExecutor(ActionDescriptor pActDescr, ISystemImage pImg, java.util.List<IResource> pResources)
IResources as
context.pActDescr - the action descriptor.pImg - the system image.pResources - the list of resources (can be empty or null).IExecutionContext.initContext(List)public ActionExecutor(ITaurusJob pJob, IExecutionContext pContext)
pJob - an ITaurusJob.pContext - the context.ToolDescriptor.getRunAsJob(),
ToolDescriptor.getAfterJobAction()@Deprecated public static IAction executeAction(ISystemImage pImg, IResource pRes, ActionDescriptor pTauAction, org.eclipse.core.runtime.IProgressMonitor pMon)
execute(IProgressMonitor) instead.ActionDescriptor which was defined in the TAURUS
configuration file.pImg - the ISystemImage of the remote (or local) system.pRes - the corresponding IResourcepTauAction - the ActionDescriptorpMon - an IProgressMonitorIAction which contains information about the executed
action (even if the action was interrupted by an exception)@Deprecated public static IAction executeAction(IExecutionContext pActionContext, ActionDescriptor pActDesc, org.eclipse.core.runtime.IProgressMonitor pMon)
execute(IProgressMonitor) instead.ActionDescriptor which was defined in the TAURUS
configuration file.pActionContext - the execution context to be used in this action.pActDesc - the ActionDescriptorpMon - an IProgressMonitorIAction which contains information about the executed
action (even if the action was interrupted by an exception)public ActionExecutorResult execute(org.eclipse.core.runtime.IProgressMonitor pMon) throws TaurusException
IAction or an
ActionExecutor.ActionExecutorJob, depending on whether the action execution mode
was EActionExecutionMode.MODAL or
EActionExecutionMode.MODELESS. If the action was modeless and a
job is returned, the caller can wait for the job to finish and obtain the
IAction from it afterwards.pMon - a progress monitor.TaurusException - if an exception occurs during executing the action or one of
its tools.executeWithWait(IProgressMonitor),
ActionExecutor.ActionExecutorJob.getAction()public IAction executeWithWait(org.eclipse.core.runtime.IProgressMonitor pMon) throws TaurusException
EActionExecutionMode.MODELESS.
This method should not be called in a separate thread to not block the main thread and preserve the idea behind modeless actions.
pMon - a progress monitor. Must not be null.IAction.TaurusException - if an exception occurs during executing the action or one of
its tools.execute(IProgressMonitor)public static int getModelessRunningCount()
@Deprecated public static IAction executeAction(ISystemImage pImg, java.util.List<IResource> pResources, ActionDescriptor pActDescr, org.eclipse.core.runtime.IProgressMonitor pMon)
execute(IProgressMonitor) instead.ActionDescriptor which was defined in the TAURUS
configuration file. Supports mass processing execution.pImg - the ISystemImage of the remote (or local) system.pResources - a list of selected IResources. Can be empty or
null.pActDescr - the ActionDescriptorpMon - an IProgressMonitorIAction which contains information about the executed
action (even if the action was interrupted by an exception)ActionDescriptor.isMassProcessing()public static void handleFileOutput(IToolContext pToolContext, IExecutionContext pExecutionContext, FileDescriptor targetIDFile, java.lang.Object pOutparmValue) throws TaurusToolException
pToolContext - the tool contextpExecutionContext - execution contexttargetIDFile - referenced target file descriptorpOutparmValue - returned parameter valueTaurusToolException - if the returned value type is not compatible with the
referenced file descriptorpublic boolean isParallelExecutionAllowed()
setParallelExecutionAllowed(boolean)public void setParallelExecutionAllowed(boolean pParallelExecution)
pParallelExecution - whether actions executed by this instance should be able to
run simultaneously.public static java.util.Map<java.lang.String,ToolTypeExtension> createToolTypeMap()
@Deprecated public static void setParmFilePath(java.lang.String pParmFilePath)
executeAction(IExecutionContext, ActionDescriptor, IProgressMonitor)
,
executeAction(ISystemImage, IResource, ActionDescriptor, IProgressMonitor)
and
executeAction(ISystemImage, List, ActionDescriptor, IProgressMonitor)pParmFilePath - the parameter file path to set@Deprecated public static void setTool(ToolDescriptor pTool)
executeAction(IExecutionContext, ActionDescriptor, IProgressMonitor)
,
executeAction(ISystemImage, IResource, ActionDescriptor, IProgressMonitor)
and
executeAction(ISystemImage, List, ActionDescriptor, IProgressMonitor)pTool - the tool descriptor to set.public static java.lang.String getParameterValue(RToolInParameter pInparm, IExecutionContext pContext) throws TaurusToolException
pInparm - the input parameter to be resolved.pContext - the execution context which should contain the value.null if the value was neither
static, found in the context and no default value exists.TaurusToolException - if the property value could not be found in the execution
context and neither a static- nor a default value is set.TaurusModelUtilities.getParameterValue(RToolInParameter,
IExecutionContext)public static ValidateMessage parseValidateMessage(java.lang.String pLine) throws TaurusToolException
null) if the line does not start with
VALMSG.pLine - the lineValidateMessage or nullTaurusToolException - if the validate message line is invalid@Deprecated public static ResourceOperation parseResourceOperation(ToolDescriptor pTool, java.lang.String pLine, IExecutionContext pContext) throws TaurusToolException
AbstractCommandBasedToolExecutor.parseResourceOperation(ToolDescriptor, String, String, List, IExecutionContext)
instead.EResourceProcessingTypes).
Returns null if the line is not a valid resource operation
or does not contain a resource operation at all.pTool - the tool which returned the line as outout.pLine - the line which might contain a resource operation.pContext - the context.null.TaurusToolException - if an error occurs during parsing of resource operation
parameters.public static void addActionListener(TaurusActionListener pListener)
TaurusActionListener to the executor.pListener - an implementation of the TaurusActionListener.getActionListeners(),
removeActionListener(TaurusActionListener)public static boolean removeActionListener(TaurusActionListener pListener)
TaurusActionEvent from the list of listeners. Does
nothing if the handed listener was not found. #see
addActionListener(TaurusActionListener)pListener - an implementation of the TaurusActionListener.true if the listener has been removed.
false if it wasn't contained in the list of active
listeners.public static java.util.List<TaurusActionListener> getActionListeners()
addActionListener(TaurusActionListener)public static boolean isMassProcessing(IExecutionContext pContext, ToolDescriptor pTool)
"Mass Processing = true. This method can be used by
tool executors which do not want to check whether the given context
contains an action descriptor.
false if the action
descriptor of the given context is null.pContext - an IExecutionContext.pTool - the tool descriptor being executed.true if the context has an action descriptor with
mass processing set to true. Otherwise returns
false.ActionDescriptor.isMassProcessing()public static java.lang.String createActionExecutionExceptionMessage(ActionDescriptor pActDescr)
Example result:
"An error occurred while executing the action 'My Action'."
pActDescr - the action descriptor which failed executing.createActionExecutionExceptionMessage(ActionDescriptor, Throwable)public static void handleActionExcecutionException(TaurusException pExpception, ActionDescriptor pActDescr, IExecutionContext pContext)
pExpception - the exceptionpActDescr - the action descriptorpContext - the execution contextpublic static java.lang.String createActionExecutionExceptionMessage(ActionDescriptor pActDescr, java.lang.Throwable pE)
If the optional Throwable parameter is not null, the method
will return the first occurred detail message. This is not recommended
for error dialogs which already show the reason right away, since the
same massage will be visible several times. A good example for using this
method with the Throwable parameter is creating an IStatus with
an error message.
Example (no detail message found):
"An error occurred while executing the action 'My Action'."
Example (detail message found in Throwable):
"The parameter 'xyz' was invalid."
pActDescr - the action descriptor which failed executing.pE - (optional) the exception to get a more accurate message from.
Can be nullcreateActionExecutionExceptionMessage(ActionDescriptor)public ActionDescriptor getActionDescriptor()
ActionDescriptor of the action executor instance.public IExecutionContext getContext()
IExecutionContext of the action executor instance.public void setSkipModelUpdateCheck(boolean pSkipModelUpdateCheck)
This is useful for actions being executed as "OnLoad" actions.
pSkipModelUpdateCheck - whether to skip the model update checkRApplicationAction.getExecutionType(),
EApplicationActionExecutionType.ON_LOADpublic static java.util.List<IValidationMessage> getAllValidationMessages(IAction pValActionResult)
pValActionResult - the action resultCopyright © 2015 Micro Focus GmbH. All rights reserved.