Class AbstractDebugCommand
- All Implemented Interfaces:
IDebugCommandHandler
IDebugCommandRequest
and IEnabledStateRequest
updates asynchronously using jobs.
Clients may subclass this class.
- Since:
- 3.6
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
canExecute
(IEnabledStateRequest request) Determines whether this handler can execute on the elements specified in the given request by reporting enabled state to the request.protected abstract void
doExecute
(Object[] targets, IProgressMonitor monitor, IRequest request) Executes this command synchronously on the specified targets, reporting progress.boolean
execute
(IDebugCommandRequest request) Executes this command on the elements specified in the given request reporting status to the given request and returns whether this handler should remain enabled while the command is executing.protected Object
getAdapter
(Object element, Class<?> type) Convenience method to return an adapter of the specified type for the given object ornull
if none.protected Object
Returns the job family for the this command'sIEnabledStateRequest
update job ornull
if none.protected ISchedulingRule
Returns a scheduling rule for this command'sIEnabledStateRequest
update job ornull
if none.protected String
Returns the name to use for a job and progress monitor task names when performing anIEnabledStateRequest
.protected Object
getExecuteJobFamily
(IDebugCommandRequest request) Returns the job family for the this command'sIDebugCommandRequest
execute job ornull
if none.protected ISchedulingRule
Returns a scheduling rule for this command'sIDebugCommandRequest
execute job ornull
if none.protected String
Returns the name to use for jobs and progress monitor task names when executing anIDebugCommandRequest
.protected abstract Object
Returns the appropriate target for this command handler for the given object.protected abstract boolean
isExecutable
(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) Returns whether this command is executable on the specified targets, reporting progress.protected boolean
isRemainEnabled
(IDebugCommandRequest request) Returns whether this command should remain enabled after starting execution of the specified request.
-
Constructor Details
-
AbstractDebugCommand
public AbstractDebugCommand()
-
-
Method Details
-
execute
Description copied from interface:IDebugCommandHandler
Executes this command on the elements specified in the given request reporting status to the given request and returns whether this handler should remain enabled while the command is executing.Implementations must be non-blocking and may respond asynchronously to the given request. Errors can reported by setting an appropriate status on the given request. A request can be canceled by this handler or the caller. A
null
status is equivalent to an OK status. When a request is complete, has encountered an error, or canceled, implementations must calldone()
on the given collector.Handlers are expected to poll the request (using
isCanceled
) periodically and abort at their earliest convenience callingdone()
on the request.- Specified by:
execute
in interfaceIDebugCommandHandler
- Parameters:
request
- specifies elements to operate on and collects execution status- Returns:
- whether this handler remains enabled while command is executing
-
isRemainEnabled
Returns whether this command should remain enabled after starting execution of the specified request.- Parameters:
request
- the request being executed- Returns:
- whether to remain enabled while executing the request
-
canExecute
Description copied from interface:IDebugCommandHandler
Determines whether this handler can execute on the elements specified in the given request by reporting enabled state to the request.Implementations must be non-blocking and may respond asynchronously to the given request. Errors can reported by setting an appropriate status on the given request. A request can be canceled by this handler or caller. A
null
status is equivalent to an OK status. When a request succeeds, fails, or is canceled, implementations must calldone()
on the given request.Clients are expected to poll the request (using
isCanceled
) periodically and abort at their earliest convenience callingdone()
on the request.- Specified by:
canExecute
in interfaceIDebugCommandHandler
- Parameters:
request
- specifies elements to operate on and collects enabled state
-
getEnabledStateTaskName
Returns the name to use for a job and progress monitor task names when performing anIEnabledStateRequest
.- Returns:
- task name
-
getExecuteTaskName
Returns the name to use for jobs and progress monitor task names when executing anIDebugCommandRequest
.- Returns:
- task name
-
doExecute
protected abstract void doExecute(Object[] targets, IProgressMonitor monitor, IRequest request) throws CoreException Executes this command synchronously on the specified targets, reporting progress. This method is called by a job. If an exception is thrown, the calling job will set the associated status on the request object. The calling job also calls #done() on the request object after this method is called, and sets a cancel status on the progress monitor if the request is canceled.Handlers must override this method.
- Parameters:
targets
- objects to perform this command onmonitor
- progress monitorrequest
- can be used to cancel this command- Throws:
CoreException
- if this handler fails to perform the request
-
isExecutable
protected abstract boolean isExecutable(Object[] targets, IProgressMonitor monitor, IEnabledStateRequest request) throws CoreException Returns whether this command is executable on the specified targets, reporting progress. This method is called by a job. If an exception is thrown, the calling job will set the associated status on the request object and report that this command is not enabled. The calling job also calls #done() on the request object after this method is called, and sets a cancel status on the progress monitor if the request is canceled. Enabled state is set tofalse
if the request is canceled.Handlers must override this method.
- Parameters:
targets
- objects to check command enabled state formonitor
- progress monitorrequest
- can be used to cancel this update request- Returns:
- whether this command can be executed for the given targets
- Throws:
CoreException
- if a problem is encountered
-
getTarget
Returns the appropriate target for this command handler for the given object. This method is called to map each element in a command request to the target object that is used indoExecute(Object[], IProgressMonitor, IRequest)
andisExecutable(Object[], IProgressMonitor, IEnabledStateRequest)
. The target may be the element itself, or some other object. Allows for redirection.Clients must override this method.
- Parameters:
element
- element from aIDebugCommandRequest
- Returns:
- associated target object for execution or enabled state update. Cannot return
null
.
-
getAdapter
Convenience method to return an adapter of the specified type for the given object ornull
if none.- Parameters:
element
- element to retrieve adapter fortype
- adapter type- Returns:
- adapter or
null
-
getEnabledStateSchedulingRule
Returns a scheduling rule for this command'sIEnabledStateRequest
update job ornull
if none. By default a rule is created to serialize jobs on the first element in the request.Clients may override this method as required.
- Parameters:
request
- request that a scheduling rule is required for- Returns:
- scheduling rule or
null
-
getExecuteSchedulingRule
Returns a scheduling rule for this command'sIDebugCommandRequest
execute job ornull
if none. By default, execution jobs have no scheduling rule.Clients may override this method as required.
- Parameters:
request
- request that a scheduling rule is required for- Returns:
- scheduling rule or
null
-
getEnabledStateJobFamily
Returns the job family for the this command'sIEnabledStateRequest
update job ornull
if none. The default implementation returnsnull
.Clients may override this method as required.
- Parameters:
request
- request the job family is required for- Returns:
- job family object or
null
if none
-
getExecuteJobFamily
Returns the job family for the this command'sIDebugCommandRequest
execute job ornull
if none. The default implementation returnsnull
.Clients may override this method as required.
- Parameters:
request
- request the job family is required for- Returns:
- job family object or
null
if none
-