Search in sources :

Example 36 with Application

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

the class LightPlatformTestCase method runBare.

@SuppressWarnings("AssignmentToStaticFieldFromInstanceMethod")
@Override
public final void runBare() throws Throwable {
    if (!shouldRunTest()) {
        return;
    }
    TestRunnerUtil.replaceIdeEventQueueSafely();
    EdtTestUtil.runInEdtAndWait(() -> {
        try {
            ourTestThread = Thread.currentThread();
            startRunAndTear();
        } finally {
            ourTestThread = null;
            try {
                Application application = ApplicationManager.getApplication();
                if (application instanceof ApplicationEx) {
                    PlatformTestCase.cleanupApplicationCaches(ourProject);
                }
                resetAllFields();
            } catch (Throwable e) {
                //noinspection CallToPrintStackTrace
                e.printStackTrace();
            }
        }
    });
    // just to make sure all deferred Runnables to finish
    SwingUtilities.invokeAndWait(EmptyRunnable.getInstance());
    if (IdeaLogger.ourErrorsOccurred != null) {
        throw IdeaLogger.ourErrorsOccurred;
    }
}
Also used : ApplicationEx(com.intellij.openapi.application.ex.ApplicationEx) IdeaTestApplication(com.intellij.idea.IdeaTestApplication) Application(com.intellij.openapi.application.Application) MockApplication(com.intellij.mock.MockApplication)

Example 37 with Application

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

the class PatchApplier method createFiles.

@NotNull
private ApplyPatchStatus createFiles() {
    final Application application = ApplicationManager.getApplication();
    Boolean isSuccess = application.runWriteAction(new Computable<Boolean>() {

        @Override
        public Boolean compute() {
            final List<FilePatch> filePatches = myVerifier.execute();
            myFailedPatches.addAll(filePatches);
            myPatches.removeAll(filePatches);
            return myFailedPatches.isEmpty();
        }
    });
    return isSuccess ? ApplyPatchStatus.SUCCESS : ApplyPatchStatus.FAILURE;
}
Also used : Application(com.intellij.openapi.application.Application) NotNull(org.jetbrains.annotations.NotNull)

Example 38 with Application

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

the class PatchApplier method showError.

public static void showError(final Project project, final String message) {
    final Application application = ApplicationManager.getApplication();
    if (application.isUnitTestMode()) {
        return;
    }
    WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> Messages.showErrorDialog(project, message, VcsBundle.message("patch.apply.dialog.title")), null, project);
}
Also used : Application(com.intellij.openapi.application.Application)

Example 39 with Application

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

the class ConversionResultImpl method postStartupActivity.

@Override
public void postStartupActivity(@NotNull Project project) {
    final Application application = ApplicationManager.getApplication();
    if (application.isHeadlessEnvironment() || application.isUnitTestMode()) {
        return;
    }
    List<VirtualFile> changedFiles = findVirtualFiles(myChangedFiles);
    if (!changedFiles.isEmpty()) {
        EditAction.editFilesAndShowErrors(project, changedFiles);
    }
    final List<VirtualFile> createdFiles = findVirtualFiles(myCreatedFiles);
    if (containsFilesUnderVcs(createdFiles, project)) {
        final VcsShowConfirmationOptionImpl option = new VcsShowConfirmationOptionImpl("", "", "", "", "");
        final Collection<VirtualFile> selected = AbstractVcsHelper.getInstance(project).selectFilesToProcess(createdFiles, "Files Created", "Select files to be added to version control", null, null, option);
        if (selected != null && !selected.isEmpty()) {
            final ChangeListManagerImpl changeListManager = ChangeListManagerImpl.getInstanceImpl(project);
            changeListManager.addUnversionedFiles(changeListManager.getDefaultChangeList(), new ArrayList<>(selected));
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ChangeListManagerImpl(com.intellij.openapi.vcs.changes.ChangeListManagerImpl) VcsShowConfirmationOptionImpl(com.intellij.openapi.vcs.VcsShowConfirmationOptionImpl) Application(com.intellij.openapi.application.Application)

Example 40 with Application

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

the class CommitHelper method generalCommit.

private void generalCommit(final GeneralCommitProcessor processor) {
    try {
        final Application appManager = ApplicationManager.getApplication();
        appManager.runReadAction(new Runnable() {

            public void run() {
                markCommittingDocuments();
            }
        });
        try {
            processor.callSelf();
        } finally {
            appManager.runReadAction(new Runnable() {

                public void run() {
                    unmarkCommittingDocuments();
                }
            });
        }
        processor.doBeforeRefresh();
    } catch (ProcessCanceledException pce) {
        throw pce;
    } catch (RuntimeException e) {
        LOG.error(e);
        processor.myVcsExceptions.add(new VcsException(e));
        throw e;
    } catch (Throwable e) {
        LOG.error(e);
        processor.myVcsExceptions.add(new VcsException(e));
        throw new RuntimeException(e);
    } finally {
        commitCompleted(processor.getVcsExceptions(), processor);
        processor.customRefresh();
        WaitForProgressToShow.runOrInvokeLaterAboveProgress(new Runnable() {

            public void run() {
                processor.doPostRefresh();
            }
        }, null, myProject);
    }
}
Also used : Application(com.intellij.openapi.application.Application) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

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