public abstract class ProgressManager extends ProgressIndicatorProvider
Constructor and Description |
---|
ProgressManager() |
Modifier and Type | Method and Description |
---|---|
static void |
assertNotCircular(ProgressIndicator original) |
static void |
canceled(ProgressIndicator indicator) |
static void |
checkCanceled() |
abstract <T,E extends java.lang.Exception> |
computeInNonCancelableSection(ThrowableComputable<T,E> computable)
Runs the specified operation and return its result in non-cancellable manner synchronously on the same thread were it was called.
|
abstract <T,E extends java.lang.Throwable> |
computePrioritized(ThrowableComputable<T,E> computable)
Performs the given computation while giving more priority to the current thread
(by forcing all other non-prioritized threads to sleep a bit whenever they call
checkCanceled() . |
abstract void |
executeNonCancelableSection(java.lang.Runnable runnable)
Runs the specified operation in non-cancellable manner synchronously on the same thread were it was called.
|
abstract void |
executeProcessUnderProgress(java.lang.Runnable process,
ProgressIndicator progress) |
static ProgressManager |
getInstance() |
abstract ProgressIndicator |
getProgressIndicator() |
abstract boolean |
hasModalProgressIndicator() |
abstract boolean |
hasProgressIndicator() |
abstract boolean |
hasUnsafeProgressIndicator() |
protected void |
indicatorCanceled(ProgressIndicator indicator) |
abstract boolean |
isInNonCancelableSection() |
static void |
progress(java.lang.String text) |
static void |
progress(java.lang.String text,
java.lang.String text2) |
static void |
progress2(java.lang.String text) |
<T,E extends java.lang.Exception> |
run(Task.WithResult<T,E> task)
Runs a specified computation with a modal progress dialog.
|
abstract void |
run(Task task)
Runs a specified
task in either background/foreground thread and shows a progress dialog. |
abstract boolean |
runInReadActionWithWriteActionPriority(java.lang.Runnable action,
ProgressIndicator indicator)
This method attempts to run provided action synchronously in a read action, so that, if possible, it wouldn't impact any pending,
executing or future write actions (for this to work effectively the action should invoke
checkCanceled() or
ProgressIndicator.checkCanceled() often enough). |
<T> T |
runProcess(Computable<T> process,
ProgressIndicator progress)
Performs the given computation synchronously in calling thread and returns its result, associating this thread with the specified progress indicator.
|
abstract void |
runProcess(java.lang.Runnable process,
ProgressIndicator progress)
Runs the given process synchronously in calling thread, associating this thread with the specified progress indicator.
|
abstract void |
runProcessWithProgressAsynchronously(Project project,
java.lang.String progressTitle,
java.lang.Runnable process,
java.lang.Runnable successRunnable,
java.lang.Runnable canceledRunnable)
Deprecated.
use
run(Task) |
abstract void |
runProcessWithProgressAsynchronously(Project project,
java.lang.String progressTitle,
java.lang.Runnable process,
java.lang.Runnable successRunnable,
java.lang.Runnable canceledRunnable,
PerformInBackgroundOption option)
Deprecated.
use
run(Task) |
abstract void |
runProcessWithProgressAsynchronously(Task.Backgroundable task,
ProgressIndicator progressIndicator) |
abstract boolean |
runProcessWithProgressSynchronously(java.lang.Runnable process,
java.lang.String progressTitle,
boolean canBeCanceled,
Project project)
Runs the specified operation in a background thread and shows a modal progress dialog in the
main thread while the operation is executing.
|
abstract boolean |
runProcessWithProgressSynchronously(java.lang.Runnable process,
java.lang.String progressTitle,
boolean canBeCanceled,
Project project,
javax.swing.JComponent parentComponent)
Runs the specified operation in a background thread and shows a modal progress dialog in the
main thread while the operation is executing.
|
abstract <T,E extends java.lang.Exception> |
runProcessWithProgressSynchronously(ThrowableComputable<T,E> process,
java.lang.String progressTitle,
boolean canBeCanceled,
Project project)
Runs the specified operation in a background thread and shows a modal progress dialog in the
main thread while the operation is executing.
|
doCheckCanceled, getGlobalProgressIndicator, startNonCancelableSectionIfSupported
public static ProgressManager getInstance()
public abstract boolean hasProgressIndicator()
public abstract boolean hasModalProgressIndicator()
public abstract boolean hasUnsafeProgressIndicator()
public abstract void runProcess(java.lang.Runnable process, ProgressIndicator progress) throws ProcessCanceledException
getProgressIndicator()
inside the process
,
and checkCanceled()
will throw a ProcessCanceledException
if the progress indicator is canceled.progress
- an indicator to use, null
means reuse current progressProcessCanceledException
public final <T> T runProcess(Computable<T> process, ProgressIndicator progress) throws ProcessCanceledException
getProgressIndicator()
inside the process
,
and checkCanceled()
will throw a ProcessCanceledException
if the progress indicator is canceled.progress
- an indicator to use, null
means reuse current progressProcessCanceledException
public abstract ProgressIndicator getProgressIndicator()
getProgressIndicator
in class ProgressIndicatorProvider
public static void progress(java.lang.String text) throws ProcessCanceledException
ProcessCanceledException
public static void progress2(java.lang.String text) throws ProcessCanceledException
ProcessCanceledException
public static void progress(java.lang.String text, java.lang.String text2) throws ProcessCanceledException
ProcessCanceledException
public abstract void executeNonCancelableSection(java.lang.Runnable runnable)
runnable
- the operation to executecomputeInNonCancelableSection(ThrowableComputable)
public abstract <T,E extends java.lang.Exception> T computeInNonCancelableSection(ThrowableComputable<T,E> computable) throws E extends java.lang.Exception
computable
- the operation to executeE extends java.lang.Exception
executeNonCancelableSection(Runnable)
public abstract boolean runProcessWithProgressSynchronously(java.lang.Runnable process, java.lang.String progressTitle, boolean canBeCanceled, Project project)
process
- the operation to execute.progressTitle
- the title of the progress window.canBeCanceled
- whether "Cancel" button is shown on the progress window.project
- the project in the context of which the operation is executed.public abstract <T,E extends java.lang.Exception> T runProcessWithProgressSynchronously(ThrowableComputable<T,E> process, java.lang.String progressTitle, boolean canBeCanceled, Project project) throws E extends java.lang.Exception
process
- the operation to execute.progressTitle
- the title of the progress window.canBeCanceled
- whether "Cancel" button is shown on the progress window.project
- the project in the context of which the operation is executed.E
- exception thrown by processE extends java.lang.Exception
public abstract boolean runProcessWithProgressSynchronously(java.lang.Runnable process, java.lang.String progressTitle, boolean canBeCanceled, Project project, javax.swing.JComponent parentComponent)
process
- the operation to execute.progressTitle
- the title of the progress window.canBeCanceled
- whether "Cancel" button is shown on the progress window.project
- the project in the context of which the operation is executed.parentComponent
- the component which will be used to calculate the progress window ancestor@Deprecated public abstract void runProcessWithProgressAsynchronously(Project project, java.lang.String progressTitle, java.lang.Runnable process, java.lang.Runnable successRunnable, java.lang.Runnable canceledRunnable)
run(Task)
process
in a background thread and shows a progress dialog, which can be made non-modal by pressing
background button. Upon successful termination of the process a successRunnable
will be called in Swing UI thread and
canceledRunnable
will be called if terminated on behalf of the user by pressing either cancel button, while running in
a modal state or stop button if running in background.project
- the project in the context of which the operation is executed.progressTitle
- the title of the progress window.process
- the operation to execute.successRunnable
- a callback to be called in Swing UI thread upon normal termination of the process.canceledRunnable
- a callback to be called in Swing UI thread if the process have been canceled by the user.@Deprecated public abstract void runProcessWithProgressAsynchronously(Project project, java.lang.String progressTitle, java.lang.Runnable process, java.lang.Runnable successRunnable, java.lang.Runnable canceledRunnable, PerformInBackgroundOption option)
run(Task)
process
in a background thread and shows a progress dialog, which can be made non-modal by pressing
background button. Upon successful termination of the process a successRunnable
will be called in Swing UI thread and
canceledRunnable
will be called if terminated on behalf of the user by pressing either cancel button, while running in
a modal state or stop button if running in background.project
- the project in the context of which the operation is executed.progressTitle
- the title of the progress window.process
- the operation to execute.successRunnable
- a callback to be called in Swing UI thread upon normal termination of the process.canceledRunnable
- a callback to be called in Swing UI thread if the process have been canceled by the user.option
- progress indicator behavior controller.public abstract void run(Task task)
task
in either background/foreground thread and shows a progress dialog.task
- task to run (either Task.Modal
or Task.Backgroundable
).public <T,E extends java.lang.Exception> T run(Task.WithResult<T,E> task) throws E extends java.lang.Exception
E extends java.lang.Exception
public abstract void runProcessWithProgressAsynchronously(Task.Backgroundable task, ProgressIndicator progressIndicator)
protected void indicatorCanceled(ProgressIndicator indicator)
public static void canceled(ProgressIndicator indicator)
public static void checkCanceled() throws ProcessCanceledException
ProcessCanceledException
- if the progress indicator associated with the current thread has been canceled.ProgressIndicator.checkCanceled()
public abstract void executeProcessUnderProgress(java.lang.Runnable process, ProgressIndicator progress) throws ProcessCanceledException
progress
- an indicator to use, null
means reuse current progressProcessCanceledException
public static void assertNotCircular(ProgressIndicator original)
public abstract boolean runInReadActionWithWriteActionPriority(java.lang.Runnable action, ProgressIndicator indicator)
checkCanceled()
or
ProgressIndicator.checkCanceled()
often enough).
It returns true
if action was executed successfully. It returns false
if the action was not
executed successfully, i.e. if:
ProcessCanceledException
when some other thread initiated
write actionaction
- the code to execute under read actionindicator
- progress indicator that should be cancelled if a write action is about to start. Can be null.public abstract boolean isInNonCancelableSection()
public abstract <T,E extends java.lang.Throwable> T computePrioritized(ThrowableComputable<T,E> computable) throws E extends java.lang.Throwable
checkCanceled()
.
This is intended for relatively short (expected to be under 10 seconds) background activities that the user is waiting for
(e.g. code navigation), and which shouldn't be slowed down by CPU-intensive background tasks like highlighting or indexing.E extends java.lang.Throwable