Interface IProgressService
-
- All Superinterfaces:
IRunnableContext
- All Known Subinterfaces:
IWorkbenchSiteProgressService
public interface IProgressService extends IRunnableContext
The progress service is the primary interface to the workbench progress support. It can be obtained from the workbench and then used to show progress for both background operations and operations that run in the UI thread.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);
- This service is available globally.
NOTE The progress service must be referenced at least once before it will become the progress provider for the
IJobManagerin the workbench. This connection is done lazily so that RCP applications will not have to use theIProgressServiceas theProgressProviderto the jobs framework if they do not wish to reference it.- Since:
- 3.0
- See Also:
IWorkbench.getProgressService(),IJobManager.setProgressProvider(org.eclipse.core.runtime.jobs.ProgressProvider),IServiceLocator.getService(Class)- Restriction:
- This interface is not intended to be implemented by clients.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidbusyCursorWhile(IRunnableWithProgress runnable)Set the cursor to busy and run the runnable in a non-UI Thread.ImagegetIconFor(Job job)Get the icon that has been registered for a Job by checking if the job belongs to any of the registered families.intgetLongOperationTime()The time at which an operation becomes considered a long operation.voidregisterIconForFamily(ImageDescriptor icon, Object family)Register the ImageDescriptor to be the icon used for all jobs that belong to family within the workbench.voidrun(boolean fork, boolean cancelable, IRunnableWithProgress runnable)This specialization of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) might run the runnable asynchronously ifforkistrue.voidrunInUI(IRunnableContext context, IRunnableWithProgress runnable, ISchedulingRule rule)Runs the given operation in the UI thread using the given runnable context.voidshowInDialog(Shell shell, Job job)Open a dialog on job when it starts to run and close it when the job is finished.
-
-
-
Method Detail
-
getLongOperationTime
int getLongOperationTime()
The time at which an operation becomes considered a long operation. Used to determine when the busy cursor will be replaced with a progress monitor.- Returns:
- int
- See Also:
busyCursorWhile(IRunnableWithProgress)
-
registerIconForFamily
void registerIconForFamily(ImageDescriptor icon, Object family)
Register the ImageDescriptor to be the icon used for all jobs that belong to family within the workbench.- Parameters:
icon- ImageDescriptor that will be used when the job is being displayedfamily- The family to associate with- See Also:
Job.belongsTo(Object)
-
runInUI
void runInUI(IRunnableContext context, IRunnableWithProgress runnable, ISchedulingRule rule) throws InvocationTargetException, InterruptedException
Runs the given operation in the UI thread using the given runnable context. The given scheduling rule, if any, will be acquired for the duration of the operation. If the rule is not available when this method is called, a progress dialog will be displayed that gives users control over the background processes that may be blocking the runnable from proceeding.This method can act as a wrapper for uses of
IRunnableContextwhere theforkparameter wasfalse.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,
busyCursorWhileshould 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.
- Parameters:
context- The runnable context to run the operation inrunnable- The operation to runrule- A scheduling rule, ornull- Throws:
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.- See Also:
Dialog,SWT.APPLICATION_MODAL
-
getIconFor
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.- Parameters:
job-- Returns:
- Icon or
nullif there isn't one. - See Also:
registerIconForFamily(ImageDescriptor,Object)
-
busyCursorWhile
void busyCursorWhile(IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException
Set the cursor to busy and run the runnable in a non-UI Thread. The calling thread will be blocked for the duration of the execution of the supplied runnable. After the cursor has been running forgetLongOperationTime()replace it with a ProgressMonitorDialog so that the user may cancel. Do not open the ProgressMonitorDialog if there is already a modal dialog open.- Parameters:
runnable- The runnable to execute and show the progress for.- Throws:
InvocationTargetExceptionInterruptedException- See Also:
getLongOperationTime()
-
run
void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedExceptionThis specialization of IRunnableContext#run(boolean, boolean, IRunnableWithProgress) might run the runnable asynchronously ifforkistrue.- Specified by:
runin interfaceIRunnableContext- Parameters:
fork-trueif the runnable should be run in a separate thread, andfalseto run in the same threadcancelable-trueto enable the cancelation, andfalseto make the operation uncancellablerunnable- the runnable to run- Throws:
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. This should not be thrown if cancelable isfalse.- Since:
- 3.2
-
showInDialog
void showInDialog(Shell shell, Job job)
Open a dialog on job when it starts to run and close it when the job is finished. Wait for ProgressManagerUtil#SHORT_OPERATION_TIME before opening the dialog. Do not open if it is already done or if the user has set a preference to always run in the background. Parent the dialog from the shell.- Parameters:
shell- The Shell to parent the dialog from ornullif the active shell is to be used.job- The Job that will be reported in the dialog. job must not benull.
-
-