use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class SvnConfigureProxiesDialog method execute.
public void execute(final String url) {
Messages.showInfoMessage(myProject, SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.settings.will.be.stored.text"), SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.settings.will.be.stored.title"));
if (!applyImpl()) {
return;
}
final Ref<Exception> excRef = new Ref<>();
final ProgressManager pm = ProgressManager.getInstance();
pm.runProcessWithProgressSynchronously(() -> {
final ProgressIndicator pi = pm.getProgressIndicator();
if (pi != null) {
pi.setText("Connecting to " + url);
}
try {
SvnVcs.getInstance(myProject).getInfo(SvnUtil.createUrl(url), SVNRevision.HEAD);
} catch (SvnBindException e) {
excRef.set(e);
}
}, "Test connection", true, myProject);
if (!excRef.isNull()) {
Messages.showErrorDialog(myProject, excRef.get().getMessage(), SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.error.title"));
} else {
Messages.showInfoMessage(myProject, SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.succes.text"), SvnBundle.message("dialog.edit.http.proxies.settings.test.connection.succes.title"));
}
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class ElementWithBranchComparer method run.
public void run() {
new Task.Modal(myProject, getTitle(), true) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
try {
beforeCompare();
myElementUrl = resolveElementUrl();
if (myElementUrl == null) {
reportNotFound();
} else {
compare();
}
} catch (SVNCancelException ex) {
ElementWithBranchComparer.this.onCancel();
} catch (SVNException ex) {
reportException(new SvnBindException(ex));
} catch (SvnBindException ex) {
reportException(ex);
} catch (VcsException ex) {
reportGeneralException(ex);
}
}
}.queue();
showResult();
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class CompileDriver method executeCompileTasks.
private boolean executeCompileTasks(final CompileContext context, final boolean beforeTasks) {
if (myProject.isDisposed()) {
return false;
}
final CompilerManager manager = CompilerManager.getInstance(myProject);
final ProgressIndicator progressIndicator = context.getProgressIndicator();
progressIndicator.pushState();
try {
CompileTask[] tasks = beforeTasks ? manager.getBeforeTasks() : manager.getAfterTasks();
if (tasks.length > 0) {
progressIndicator.setText(CompilerBundle.message(beforeTasks ? "progress.executing.precompile.tasks" : "progress.executing.postcompile.tasks"));
for (CompileTask task : tasks) {
if (!task.execute(context)) {
return false;
}
}
}
} finally {
progressIndicator.popState();
StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
if (statusBar != null) {
statusBar.setInfo("");
}
if (progressIndicator instanceof CompilerTask) {
ApplicationManager.getApplication().invokeLater(((CompilerTask) progressIndicator)::showCompilerContent);
}
}
return true;
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class CompileDriver method isUpToDate.
public boolean isUpToDate(CompileScope scope) {
if (LOG.isDebugEnabled()) {
LOG.debug("isUpToDate operation started");
}
final CompilerTask task = new CompilerTask(myProject, "Classes up-to-date check", true, false, false, isCompilationStartedAutomatically(scope));
final CompileContextImpl compileContext = new CompileContextImpl(myProject, task, scope, true, false);
final Ref<ExitStatus> result = new Ref<>();
task.start(() -> {
final ProgressIndicator indicator = compileContext.getProgressIndicator();
if (indicator.isCanceled() || myProject.isDisposed()) {
return;
}
try {
final TaskFuture future = compileInExternalProcess(compileContext, true);
if (future != null) {
while (!future.waitFor(200L, TimeUnit.MILLISECONDS)) {
if (indicator.isCanceled()) {
future.cancel(false);
}
}
}
} catch (Throwable e) {
LOG.error(e);
} finally {
result.set(COMPILE_SERVER_BUILD_STATUS.get(compileContext));
if (!myProject.isDisposed()) {
CompilerCacheManager.getInstance(myProject).flushCaches();
}
}
}, null);
if (LOG.isDebugEnabled()) {
LOG.debug("isUpToDate operation finished");
}
return ExitStatus.UP_TO_DATE.equals(result.get());
}
use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.
the class CompileDriver method startup.
private void startup(final CompileScope scope, final boolean isRebuild, final boolean forceCompile, final CompileStatusNotification callback, final CompilerMessage message) {
ApplicationManager.getApplication().assertIsDispatchThread();
final String contentName = CompilerBundle.message(forceCompile ? "compiler.content.name.compile" : "compiler.content.name.make");
final boolean isUnitTestMode = ApplicationManager.getApplication().isUnitTestMode();
final CompilerTask compileTask = new CompilerTask(myProject, contentName, isUnitTestMode, true, true, isCompilationStartedAutomatically(scope));
StatusBar.Info.set("", myProject, "Compiler");
// ensure the project model seen by build process is up-to-date
myProject.save();
if (!isUnitTestMode) {
ApplicationManager.getApplication().saveSettings();
}
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
FileDocumentManager.getInstance().saveAllDocuments();
final CompileContextImpl compileContext = new CompileContextImpl(myProject, compileTask, scope, !isRebuild && !forceCompile, isRebuild);
final Runnable compileWork = () -> {
final ProgressIndicator indicator = compileContext.getProgressIndicator();
if (indicator.isCanceled() || myProject.isDisposed()) {
if (callback != null) {
callback.finished(true, 0, 0, compileContext);
}
return;
}
CompilerCacheManager compilerCacheManager = CompilerCacheManager.getInstance(myProject);
try {
LOG.info("COMPILATION STARTED (BUILD PROCESS)");
if (message != null) {
compileContext.addMessage(message);
}
if (isRebuild) {
CompilerUtil.runInContext(compileContext, "Clearing build system data...", (ThrowableRunnable<Throwable>) () -> compilerCacheManager.clearCaches(compileContext));
}
final boolean beforeTasksOk = executeCompileTasks(compileContext, true);
final int errorCount = compileContext.getMessageCount(CompilerMessageCategory.ERROR);
if (!beforeTasksOk || errorCount > 0) {
COMPILE_SERVER_BUILD_STATUS.set(compileContext, errorCount > 0 ? ExitStatus.ERRORS : ExitStatus.CANCELLED);
return;
}
final TaskFuture future = compileInExternalProcess(compileContext, false);
if (future != null) {
while (!future.waitFor(200L, TimeUnit.MILLISECONDS)) {
if (indicator.isCanceled()) {
future.cancel(false);
}
}
if (!executeCompileTasks(compileContext, false)) {
COMPILE_SERVER_BUILD_STATUS.set(compileContext, ExitStatus.CANCELLED);
}
if (compileContext.getMessageCount(CompilerMessageCategory.ERROR) > 0) {
COMPILE_SERVER_BUILD_STATUS.set(compileContext, ExitStatus.ERRORS);
}
}
} catch (ProcessCanceledException ignored) {
compileContext.putUserDataIfAbsent(COMPILE_SERVER_BUILD_STATUS, ExitStatus.CANCELLED);
} catch (Throwable e) {
// todo
LOG.error(e);
} finally {
compilerCacheManager.flushCaches();
final long duration = notifyCompilationCompleted(compileContext, callback, COMPILE_SERVER_BUILD_STATUS.get(compileContext));
CompilerUtil.logDuration("\tCOMPILATION FINISHED (BUILD PROCESS); Errors: " + compileContext.getMessageCount(CompilerMessageCategory.ERROR) + "; warnings: " + compileContext.getMessageCount(CompilerMessageCategory.WARNING), duration);
}
};
compileTask.start(compileWork, () -> {
if (isRebuild) {
final int rv = Messages.showOkCancelDialog(myProject, "You are about to rebuild the whole project.\nRun 'Build Project' instead?", "Confirm Project Rebuild", "Build", "Rebuild", Messages.getQuestionIcon());
if (rv == Messages.OK) /*yes, please, do run make*/
{
startup(scope, false, false, callback, null);
return;
}
}
startup(scope, isRebuild, forceCompile, callback, message);
});
}
Aggregations