use of com.intellij.openapi.application.ModalityState in project azure-tools-for-java by Microsoft.
the class IntellijAzureTaskManager method doRunLater.
@Override
protected void doRunLater(final Runnable runnable, final AzureTask<?> task) {
final ModalityState state = toIntellijModality(task);
ApplicationManager.getApplication().invokeLater(runnable, state);
}
use of com.intellij.openapi.application.ModalityState in project azure-tools-for-java by Microsoft.
the class IntellijAzureTaskManager method doRunAndWait.
@Override
protected void doRunAndWait(final Runnable runnable, final AzureTask<?> task) {
final ModalityState state = toIntellijModality(task);
ApplicationManager.getApplication().invokeAndWait(runnable, state);
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class MergingUpdateQueue method isModalityStateCorrect.
protected boolean isModalityStateCorrect() {
if (!myExecuteInDispatchThread)
return true;
if (myModalityStateComponent == ANY_COMPONENT)
return true;
ModalityState current = ApplicationManager.getApplication().getCurrentModalityState();
final ModalityState modalityState = getModalityState();
return !current.dominates(modalityState);
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class BackgroundTaskUtil method executeAndTryWait.
@NotNull
@CalledInAwt
public static ProgressIndicator executeAndTryWait(@NotNull Function<ProgressIndicator, /*@NotNull*/
Runnable> backgroundTask, @Nullable Runnable onSlowAction, long waitMillis, boolean forceEDT) {
ModalityState modality = ModalityState.current();
if (forceEDT) {
ProgressIndicator indicator = new EmptyProgressIndicator(modality);
try {
Runnable callback = backgroundTask.fun(indicator);
finish(callback, indicator);
} catch (ProcessCanceledException ignore) {
} catch (Throwable t) {
LOG.error(t);
}
return indicator;
} else {
Pair<Runnable, ProgressIndicator> pair = computeInBackgroundAndTryWait(backgroundTask, (callback, indicator) -> {
ApplicationManager.getApplication().invokeLater(() -> {
finish(callback, indicator);
}, modality);
}, modality, waitMillis);
Runnable callback = pair.first;
ProgressIndicator indicator = pair.second;
if (callback != null) {
finish(callback, indicator);
} else {
if (onSlowAction != null)
onSlowAction.run();
}
return indicator;
}
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class BackgroundTaskQueue method runTaskInCurrentThread.
private void runTaskInCurrentThread(@NotNull BackgroundableTaskData data) {
Task.Backgroundable task = data.myTask;
ProgressIndicator indicator = data.myIndicator;
if (indicator == null)
indicator = new EmptyProgressIndicator();
ModalityState modalityState = data.myModalityState;
if (modalityState == null)
modalityState = ModalityState.NON_MODAL;
ProgressManagerImpl pm = (ProgressManagerImpl) ProgressManager.getInstance();
// prohibit simultaneous execution from different threads
synchronized (TEST_TASK_LOCK) {
pm.runProcessWithProgressInCurrentThread(task, indicator, modalityState);
}
}
Aggregations