use of com.intellij.openapi.application.TransactionGuard in project intellij-community by JetBrains.
the class GotoActionAction method openOptionOrPerformAction.
public static void openOptionOrPerformAction(@NotNull Object element, final String enteredText, @Nullable final Project project, Component component, @Nullable AnActionEvent e) {
if (element instanceof OptionDescription) {
OptionDescription optionDescription = (OptionDescription) element;
final String configurableId = optionDescription.getConfigurableId();
Disposable disposable = project != null ? project : ApplicationManager.getApplication();
TransactionGuard guard = TransactionGuard.getInstance();
if (optionDescription.hasExternalEditor()) {
guard.submitTransactionLater(disposable, () -> optionDescription.invokeInternalEditor());
} else {
guard.submitTransactionLater(disposable, () -> ShowSettingsUtilImpl.showSettingsDialog(project, configurableId, enteredText));
}
} else {
ApplicationManager.getApplication().invokeLater(() -> IdeFocusManager.getInstance(project).doWhenFocusSettlesDown(() -> performAction(element, component, e)));
}
}
use of com.intellij.openapi.application.TransactionGuard in project intellij-community by JetBrains.
the class AutoPopupController method runTransactionWithEverythingCommitted.
public static void runTransactionWithEverythingCommitted(@NotNull final Project project, @NotNull final Runnable runnable) {
TransactionGuard guard = TransactionGuard.getInstance();
TransactionId id = guard.getContextTransaction();
final PsiDocumentManager pdm = PsiDocumentManager.getInstance(project);
pdm.performLaterWhenAllCommitted(() -> guard.submitTransaction(project, id, () -> {
if (pdm.hasUncommitedDocuments()) {
// no luck, will try later
runTransactionWithEverythingCommitted(project, runnable);
} else {
runnable.run();
}
}));
}
use of com.intellij.openapi.application.TransactionGuard in project intellij-community by JetBrains.
the class InferNullityAnnotationsAction method restartAnalysis.
protected void restartAnalysis(final Project project, final AnalysisScope scope) {
TransactionGuard guard = TransactionGuard.getInstance();
TransactionId id = guard.getContextTransaction();
DumbService.getInstance(project).smartInvokeLater(() -> TransactionGuard.getInstance().submitTransaction(project, id, () -> {
if (DumbService.isDumb(project)) {
restartAnalysis(project, scope);
} else {
analyze(project, scope);
}
}));
}
Aggregations