public interface IProgressService extends IRunnableContext
All methods on the progress service must be called from the UI thread.
This service can be acquired from your service locator:
IProgressService service = (IProgressService) getSite().getService(IProgressService.class);
NOTE The progress service must be referenced at least once
before it will become the progress provider for the IJobManager
in
the workbench. This connection is done lazily so that RCP applications will
not have to use the IProgressService
as the ProgressProvider
to the jobs framework if they do not wish to reference it.
IWorkbench.getProgressService()
,
IJobManager.setProgressProvider(org.eclipse.core.runtime.jobs.ProgressProvider)
,
IServiceLocator.getService(Class)
Modifier and Type | Method and Description |
---|---|
void |
busyCursorWhile(IRunnableWithProgress runnable)
Set the cursor to busy and run the runnable in a non-UI Thread.
|
Image |
getIconFor(Job job)
Get the icon that has been registered for a Job by
checking if the job belongs to any of the registered
families.
|
int |
getLongOperationTime()
The time at which an operation becomes considered a long
operation.
|
void |
registerIconForFamily(ImageDescriptor icon,
Object family)
Register the ImageDescriptor to be the icon used for
all jobs that belong to family within the workbench.
|
void |
run(boolean fork,
boolean cancelable,
IRunnableWithProgress runnable)
This specialization of IRunnableContext#run(boolean, boolean,
IRunnableWithProgress) might run the runnable asynchronously
if
fork is true . |
void |
runInUI(IRunnableContext context,
IRunnableWithProgress runnable,
ISchedulingRule rule)
Runs the given operation in the UI thread using the given runnable context.
|
void |
showInDialog(Shell shell,
Job job)
Open a dialog on job when it starts to run and close it
when the job is finished.
|
int getLongOperationTime()
busyCursorWhile(IRunnableWithProgress)
void registerIconForFamily(ImageDescriptor icon, Object family)
icon
- ImageDescriptor that will be used when the job is being displayedfamily
- The family to associate withJob.belongsTo(Object)
void runInUI(IRunnableContext context, IRunnableWithProgress runnable, ISchedulingRule rule) throws InvocationTargetException, InterruptedException
This method can act as a wrapper for uses of IRunnableContext where the fork parameter was false.
Note: Running long operations in the UI thread is generally not recommended. This can result in the UI becoming unresponsive for the duration of the operation. Where possible, busyCursorWhile should be used instead.
Modal dialogs should also be avoided in the runnable as there will already be a modal progress dialog open when this operation runs.
context
- The runnable context to run the operation inrunnable
- The operation to runrule
- A scheduling rule, or null
InvocationTargetException
- wraps any exception or error which occurs
while running the runnableInterruptedException
- propagated by the context if the runnable
acknowledges cancelation by throwing this exception.Dialog
,
SWT.APPLICATION_MODAL
Image getIconFor(Job job)
job
- null
if there isn't one.registerIconForFamily(ImageDescriptor,Object)
void busyCursorWhile(IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
getLongOperationTime()
replace it with
a ProgressMonitorDialog so that the user may cancel.
Do not open the ProgressMonitorDialog if there is already a modal
dialog open.runnable
- The runnable to execute and show the progress for.InvocationTargetException
InterruptedException
getLongOperationTime()
void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
fork
is true
.run
in interface IRunnableContext
fork
- true
if the runnable should be run in a separate thread,
and false
to run in the same threadcancelable
- true
to enable the cancelation, and
false
to make the operation uncancellablerunnable
- the runnable to runInvocationTargetException
- wraps any exception or error which occurs
while running the runnableInterruptedException
- propagated by the context if the runnable
acknowledges cancelation by throwing this exception. This should not be thrown
if cancelable is false
.void showInDialog(Shell shell, Job job)
shell
- The Shell to parent the dialog from or
null
if the active shell is to be used.job
- The Job that will be reported in the dialog. job
must not be null
.
Copyright (c) 2000, 2014 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.