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;
}
}
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;
}
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);
}
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));
}
}
}
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);
}
}
Aggregations