Search in sources :

Example 1 with TransactionGuard

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)));
    }
}
Also used : Disposable(com.intellij.openapi.Disposable) BooleanOptionDescription(com.intellij.ide.ui.search.BooleanOptionDescription) OptionDescription(com.intellij.ide.ui.search.OptionDescription) TransactionGuard(com.intellij.openapi.application.TransactionGuard)

Example 2 with TransactionGuard

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();
        }
    }));
}
Also used : TransactionGuard(com.intellij.openapi.application.TransactionGuard) TransactionId(com.intellij.openapi.application.TransactionId) PsiDocumentManager(com.intellij.psi.PsiDocumentManager)

Example 3 with TransactionGuard

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);
        }
    }));
}
Also used : TransactionGuard(com.intellij.openapi.application.TransactionGuard) TransactionId(com.intellij.openapi.application.TransactionId)

Aggregations

TransactionGuard (com.intellij.openapi.application.TransactionGuard)3 TransactionId (com.intellij.openapi.application.TransactionId)2 BooleanOptionDescription (com.intellij.ide.ui.search.BooleanOptionDescription)1 OptionDescription (com.intellij.ide.ui.search.OptionDescription)1 Disposable (com.intellij.openapi.Disposable)1 PsiDocumentManager (com.intellij.psi.PsiDocumentManager)1