Search in sources :

Example 31 with ProgressIndicator

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"));
    }
}
Also used : Ref(com.intellij.openapi.util.Ref) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ProgressManager(com.intellij.openapi.progress.ProgressManager) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ConfigurationException(com.intellij.openapi.options.ConfigurationException)

Example 32 with ProgressIndicator

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();
}
Also used : Task(com.intellij.openapi.progress.Task) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) VcsException(com.intellij.openapi.vcs.VcsException) SVNException(org.tmatesoft.svn.core.SVNException)

Example 33 with ProgressIndicator

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;
}
Also used : CompilerTask(com.intellij.compiler.progress.CompilerTask) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator)

Example 34 with ProgressIndicator

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());
}
Also used : Ref(com.intellij.openapi.util.Ref) CompilerTask(com.intellij.compiler.progress.CompilerTask) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) TaskFuture(org.jetbrains.jps.api.TaskFuture)

Example 35 with ProgressIndicator

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);
    });
}
Also used : CompilerTask(com.intellij.compiler.progress.CompilerTask) ThrowableRunnable(com.intellij.util.ThrowableRunnable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ThrowableRunnable(com.intellij.util.ThrowableRunnable) TaskFuture(org.jetbrains.jps.api.TaskFuture) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Aggregations

ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)400 Task (com.intellij.openapi.progress.Task)151 VirtualFile (com.intellij.openapi.vfs.VirtualFile)106 NotNull (org.jetbrains.annotations.NotNull)101 Project (com.intellij.openapi.project.Project)88 File (java.io.File)59 IOException (java.io.IOException)58 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)47 Nullable (org.jetbrains.annotations.Nullable)46 ProgressManager (com.intellij.openapi.progress.ProgressManager)39 List (java.util.List)36 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)31 Ref (com.intellij.openapi.util.Ref)27 Module (com.intellij.openapi.module.Module)26 VcsException (com.intellij.openapi.vcs.VcsException)26 ArrayList (java.util.ArrayList)26 ApplicationManager (com.intellij.openapi.application.ApplicationManager)25 Logger (com.intellij.openapi.diagnostic.Logger)23 AzureString (com.microsoft.azure.toolkit.lib.common.bundle.AzureString)22 AzureTask (com.microsoft.azure.toolkit.lib.common.task.AzureTask)22