Search in sources :

Example 76 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class PostprocessReformattingAspect method decrementPostponedCounter.

private void decrementPostponedCounter() {
    Application application = ApplicationManager.getApplication();
    application.assertIsDispatchThread();
    if (--getContext().myPostponedCounter == 0) {
        if (application.isWriteAccessAllowed()) {
            doPostponedFormatting();
        } else {
            application.runWriteAction(() -> doPostponedFormatting());
        }
    }
}
Also used : Application(com.intellij.openapi.application.Application)

Example 77 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class InstalledPackagesPanel method refreshLatestVersions.

private void refreshLatestVersions(@NotNull final PackageManagementService packageManagementService) {
    final Application application = ApplicationManager.getApplication();
    application.executeOnPooledThread(() -> {
        if (packageManagementService == myPackageManagementService) {
            try {
                List<RepoPackage> packages = packageManagementService.reloadAllPackages();
                final Map<String, RepoPackage> packageMap = buildNameToPackageMap(packages);
                application.invokeLater(() -> {
                    for (int i = 0; i != myPackagesTableModel.getRowCount(); ++i) {
                        final InstalledPackage pyPackage = (InstalledPackage) myPackagesTableModel.getValueAt(i, 0);
                        final RepoPackage repoPackage = packageMap.get(pyPackage.getName());
                        myPackagesTableModel.setValueAt(repoPackage == null ? null : repoPackage.getLatestVersion(), i, 2);
                    }
                    myPackagesTable.setPaintBusy(false);
                }, ModalityState.stateForComponent(myPackagesTable));
            } catch (IOException ignored) {
                myPackagesTable.setPaintBusy(false);
            }
        }
    });
}
Also used : IOException(java.io.IOException) Application(com.intellij.openapi.application.Application)

Example 78 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class CoreCommandProcessor method executeCommand.

private void executeCommand(@Nullable Project project, @NotNull Runnable command, @Nullable String name, @Nullable Object groupId, @NotNull UndoConfirmationPolicy confirmationPolicy, boolean shouldRecordCommandForActiveDocument, @Nullable Document document) {
    Application application = ApplicationManager.getApplication();
    application.assertIsDispatchThread();
    if (project != null && project.isDisposed()) {
        CommandLog.LOG.error("Project " + project + " already disposed");
        return;
    }
    if (CommandLog.LOG.isDebugEnabled()) {
        CommandLog.LOG.debug("executeCommand: " + command + ", name = " + name + ", groupId = " + groupId);
    }
    if (myCurrentCommand != null) {
        command.run();
        return;
    }
    Throwable throwable = null;
    try {
        myCurrentCommand = new CommandDescriptor(command, project, name, groupId, confirmationPolicy, shouldRecordCommandForActiveDocument, document);
        fireCommandStarted();
        command.run();
    } catch (Throwable th) {
        throwable = th;
    } finally {
        finishCommand(project, myCurrentCommand, throwable);
    }
}
Also used : Application(com.intellij.openapi.application.Application)

Example 79 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class DocumentImpl method beforeChangedUpdate.

private void beforeChangedUpdate(DocumentEvent event) {
    Application app = ApplicationManager.getApplication();
    if (app != null) {
        FileDocumentManager manager = FileDocumentManager.getInstance();
        VirtualFile file = manager.getFile(this);
        if (file != null && !file.isValid()) {
            LOG.error("File of this document has been deleted.");
        }
    }
    assertInsideCommand();
    // initialize line set to track changed lines
    getLineSet();
    if (!ShutDownTracker.isShutdownHookRunning()) {
        DocumentListener[] listeners = getListeners();
        for (int i = listeners.length - 1; i >= 0; i--) {
            try {
                listeners[i].beforeDocumentChange(event);
            } catch (Throwable e) {
                LOG.error(e);
            }
        }
    }
    myEventsHandling = true;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DocumentListener(com.intellij.openapi.editor.event.DocumentListener) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) Application(com.intellij.openapi.application.Application)

Example 80 with Application

use of com.intellij.openapi.application.Application in project intellij-community by JetBrains.

the class DocumentImpl method assertWriteAccess.

private void assertWriteAccess() {
    if (myAssertThreading) {
        final Application application = ApplicationManager.getApplication();
        if (application != null) {
            application.assertWriteAccessAllowed();
            VirtualFile file = FileDocumentManager.getInstance().getFile(this);
            if (file != null && file.isInLocalFileSystem()) {
                ((TransactionGuardImpl) TransactionGuard.getInstance()).assertWriteActionAllowed();
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TransactionGuardImpl(com.intellij.openapi.application.TransactionGuardImpl) Application(com.intellij.openapi.application.Application)

Aggregations

Application (com.intellij.openapi.application.Application)188 NotNull (org.jetbrains.annotations.NotNull)23 VirtualFile (com.intellij.openapi.vfs.VirtualFile)21 IOException (java.io.IOException)14 Project (com.intellij.openapi.project.Project)13 Nullable (org.jetbrains.annotations.Nullable)12 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)9 ModalityState (com.intellij.openapi.application.ModalityState)8 Ref (com.intellij.openapi.util.Ref)7 ArrayList (java.util.ArrayList)7 List (java.util.List)6 ApplicationImpl (com.intellij.openapi.application.impl.ApplicationImpl)5 ApplicationManager (com.intellij.openapi.application.ApplicationManager)4 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)4 Document (com.intellij.openapi.editor.Document)4 Module (com.intellij.openapi.module.Module)4 Computable (com.intellij.openapi.util.Computable)4 PsiFile (com.intellij.psi.PsiFile)4 File (java.io.File)4 Editor (com.intellij.openapi.editor.Editor)3