Class AbstractAsynchronousCustomFeature
java.lang.Object
org.eclipse.graphiti.features.impl.AbstractFeature
org.eclipse.graphiti.features.custom.AbstractCustomFeature
org.eclipse.graphiti.features.custom.AbstractAsynchronousCustomFeature
- All Implemented Interfaces:
ICustomFeature
,IFeature
,IFeatureProviderHolder
,IDescription
,IName
This class should be used if for some reason a CustomFeature can be long to
execute. It runs execute(ICustomContext, IProgressMonitor)
in a
Command on top of current TransactionalEditingDomain. This command itself is
run in a Job, and can use the associated IProgressMonitor
This is useful to indicate to users that the job is running, but eclipse has not crashed.
- Since:
- 0.12
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
Callback executed immediately after job execution in the background job execution thread.protected void
Callback executed just before job scheduling; called in the feature execution thread.protected void
configureJob
(org.eclipse.core.runtime.jobs.Job job) Initialize parameters of the given Jobfinal void
Must not be overridden in order to guarantee correct delegation to the background job, seeexecute(ICustomContext)
.final void
execute
(ICustomContext context) The implementation of this method will during the execution of the feature trigger the creation of a background job, configure it and execute it.
Clients should implement their feature functionality inexecute(ICustomContext, IProgressMonitor)
, potentially also in thebeforeJobExecution()
andafterJobExecution()
hooks.protected abstract void
execute
(ICustomContext context, org.eclipse.core.runtime.IProgressMonitor monitor) Concrete code to execute.final boolean
The default implementation returnsfalse
in any case.protected org.eclipse.core.runtime.jobs.Job
initializeJob
(ICustomContext context) Initialize the Job.Methods inherited from class org.eclipse.graphiti.features.custom.AbstractCustomFeature
canExecute, canExecute, getDescription, getImageId, isAvailable
Methods inherited from class org.eclipse.graphiti.features.impl.AbstractFeature
addGraphicalRepresentation, canUndo, getAllBusinessObjectsForPictogramElement, getBusinessObjectForPictogramElement, getDiagram, getDiagramBehavior, getFeatureProvider, getName, getProgressCallback, getUserDecision, layoutPictogramElement, link, link, manageColor, manageColor, manageDefaultFont, manageFont, manageFont, setProgressCallback, toString, updatePictogramElement
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.graphiti.features.IFeatureProviderHolder
getFeatureProvider
-
Constructor Details
-
AbstractAsynchronousCustomFeature
-
-
Method Details
-
execute
protected abstract void execute(ICustomContext context, org.eclipse.core.runtime.IProgressMonitor monitor) Concrete code to execute. Sub-classes should use the given monitor correctly: create tasks (and eventually sub-tasks), notify for worked and done tasks and check if user cancelled the task.- Parameters:
context
- The CustomFeature contextmonitor
- The monitor used to manage progress bar and Job cancellation
-
beforeJobExecution
protected void beforeJobExecution()Callback executed just before job scheduling; called in the feature execution thread. Default implementation is empty. -
afterJobExecution
protected void afterJobExecution()Callback executed immediately after job execution in the background job execution thread. Default implementation is empty. -
initializeJob
Initialize the Job.- Parameters:
context
- The CustomContext that will be given toexecute(ICustomContext, IProgressMonitor)
.- Returns:
- The Job instance
-
configureJob
protected void configureJob(org.eclipse.core.runtime.jobs.Job job) Initialize parameters of the given Job- Parameters:
job
- The Job instance to configure
-
execute
Must not be overridden in order to guarantee correct delegation to the background job, seeexecute(ICustomContext)
.- Specified by:
execute
in interfaceIFeature
- Overrides:
execute
in classAbstractCustomFeature
- Parameters:
context
- this is the general input for this method- See Also:
-
execute
The implementation of this method will during the execution of the feature trigger the creation of a background job, configure it and execute it.
Clients should implement their feature functionality inexecute(ICustomContext, IProgressMonitor)
, potentially also in thebeforeJobExecution()
andafterJobExecution()
hooks. The background job and its behavior can be changed in the methodsinitializeJob(ICustomContext)
andconfigureJob(Job)
.- Parameters:
context
- The CustomFeature context
-
hasDoneChanges
public final boolean hasDoneChanges()The default implementation returnsfalse
in any case. This is usually the desired return value, because this method will be queried already before the asynchronous feature will be executed (execute(ICustomContext, IProgressMonitor)
is called). Returningtrue
here would mean that users could already undo the feature while it is still being executed; this would mean also canceling the a running job. Because of potentially strange effects and complexity this is not possible.- Specified by:
hasDoneChanges
in interfaceIFeature
- Overrides:
hasDoneChanges
in classAbstractFeature
- Returns:
- Always
false
-