Search in sources :

Example 1 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project buck by facebook.

the class BuckBuildManager method runBuckCommand.

/**
   * Execute simple process asynchronously with progress.
   *
   * @param handler        a handler
   * @param operationTitle an operation title shown in progress dialog
   */
public synchronized void runBuckCommand(final BuckCommandHandler handler, final String operationTitle) {
    if (!(handler instanceof BuckKillCommandHandler)) {
        currentRunningBuckCommandHandler = handler;
        // Save files for anything besides buck kill
        ApplicationManager.getApplication().invokeAndWait(new Runnable() {

            @Override
            public void run() {
                FileDocumentManager.getInstance().saveAllDocuments();
            }
        }, ModalityState.NON_MODAL);
    }
    Project project = handler.project();
    String exec = BuckSettingsProvider.getInstance().getState().buckExecutable;
    if (exec == null) {
        BuckToolWindowFactory.outputConsoleMessage(project, "Please specify the buck executable path!\n", ConsoleViewContentType.ERROR_OUTPUT);
        BuckToolWindowFactory.outputConsoleMessage(project, "Preference -> Tools -> Buck -> Path to Buck executable\n", ConsoleViewContentType.NORMAL_OUTPUT);
        return;
    }
    final ProgressManager manager = ProgressManager.getInstance();
    ApplicationManager.getApplication().invokeLater(new Runnable() {

        @Override
        public void run() {
            manager.run(new Task.Backgroundable(handler.project(), operationTitle, true) {

                public void run(final ProgressIndicator indicator) {
                    runInCurrentThread(handler, indicator, true, operationTitle);
                }
            });
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) ProgressManager(com.intellij.openapi.progress.ProgressManager) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator)

Example 2 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project buck by facebook.

the class TestExecutionState method showProgress.

private void showProgress(final OSProcessHandler result, final String title) {
    final ProgressManager manager = ProgressManager.getInstance();
    ApplicationManager.getApplication().invokeLater(() -> {
        manager.run(new Task.Backgroundable(mProject, title, true) {

            public void run(@NotNull final ProgressIndicator indicator) {
                try {
                    result.waitFor();
                } finally {
                    indicator.cancel();
                }
            }
        });
    });
}
Also used : Task(com.intellij.openapi.progress.Task) ProgressManager(com.intellij.openapi.progress.ProgressManager) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator)

Example 3 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project intellij-plugins by StepicOrg.

the class StepikSendAction method check.

private void check(@NotNull Project project) {
    logger.info("Start checking step");
    StudyNode<?, ?> selected = StepikProjectManager.getSelected(project);
    if (!(selected instanceof StepNode)) {
        logger.info("Stop checking step: step is null or is not StepNode ");
        return;
    }
    StepNode stepNode = (StepNode) selected;
    String title = "Checking Step: " + stepNode.getName();
    ProgressManager.getInstance().run(new Task.Backgroundable(project, title) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            indicator.setIndeterminate(true);
            StepikApiClient stepikApiClient = authAndGetStepikApiClient(true);
            if (!isAuthenticated()) {
                return;
            }
            Long submissionId = sendStep(stepikApiClient, project, stepNode);
            if (submissionId == null) {
                return;
            }
            Metrics.sendAction(project, stepNode, SUCCESSFUL);
            SendAction.checkStepStatus(project, stepikApiClient, stepNode, submissionId, indicator);
            logger.info(String.format("Finish checking step: id=%s", stepNode.getId()));
        }
    });
}
Also used : StepikAuthManager.authAndGetStepikApiClient(org.stepik.core.stepik.StepikAuthManager.authAndGetStepikApiClient) StepikApiClient(org.stepik.api.client.StepikApiClient) Task(com.intellij.openapi.progress.Task) StepNode(org.stepik.core.courseFormat.StepNode) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator)

Example 4 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.

the class SvnAuthenticationNotifier method clearAuthenticationDirectory.

public static void clearAuthenticationDirectory(@NotNull SvnConfiguration configuration) {
    final File authDir = new File(configuration.getConfigurationDirectory(), "auth");
    if (authDir.exists()) {
        final Runnable process = () -> {
            final ProgressIndicator ind = ProgressManager.getInstance().getProgressIndicator();
            if (ind != null) {
                ind.setIndeterminate(true);
                ind.setText("Clearing stored credentials in " + authDir.getAbsolutePath());
            }
            final File[] files = authDir.listFiles((dir, name) -> ourAuthKinds.contains(name));
            for (File dir : files) {
                if (ind != null) {
                    ind.setText("Deleting " + dir.getAbsolutePath());
                }
                FileUtil.delete(dir);
            }
        };
        final Application application = ApplicationManager.getApplication();
        if (application.isUnitTestMode() || !application.isDispatchThread()) {
            process.run();
        } else {
            ProgressManager.getInstance().runProcessWithProgressSynchronously(process, "button.text.clear.authentication.cache", false, configuration.getProject());
        }
    }
}
Also used : IdeFrame(com.intellij.openapi.wm.IdeFrame) Application(com.intellij.openapi.application.Application) MessageType(com.intellij.openapi.ui.MessageType) ScheduledFuture(java.util.concurrent.ScheduledFuture) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ModalityState(com.intellij.openapi.application.ModalityState) Balloon(com.intellij.openapi.ui.popup.Balloon) CommonProxy(com.intellij.util.proxy.CommonProxy) java.net(java.net) Messages(com.intellij.openapi.ui.Messages) FileUtil(com.intellij.openapi.util.io.FileUtil) Logger(com.intellij.openapi.diagnostic.Logger) SVNAuthentication(org.tmatesoft.svn.core.auth.SVNAuthentication) ProgressManager(com.intellij.openapi.progress.ProgressManager) ThreeState(com.intellij.util.ThreeState) org.jetbrains.idea.svn(org.jetbrains.idea.svn) NotificationType(com.intellij.notification.NotificationType) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) ApplicationManager(com.intellij.openapi.application.ApplicationManager) WindowManagerEx(com.intellij.openapi.wm.ex.WindowManagerEx) NotNull(org.jetbrains.annotations.NotNull) Ref(com.intellij.openapi.util.Ref) RelativePoint(com.intellij.ui.awt.RelativePoint) SvnBindException(org.jetbrains.idea.svn.commandLine.SvnBindException) java.util(java.util) VcsBalloonProblemNotifier(com.intellij.openapi.vcs.ui.VcsBalloonProblemNotifier) Project(com.intellij.openapi.project.Project) NamedRunnable(com.intellij.openapi.util.NamedRunnable) InfoClient(org.jetbrains.idea.svn.info.InfoClient) JobScheduler(com.intellij.concurrency.JobScheduler) HttpConfigurable(com.intellij.util.net.HttpConfigurable) ClientFactory(org.jetbrains.idea.svn.api.ClientFactory) SVNCancelException(org.tmatesoft.svn.core.SVNCancelException) SVNURLUtil(org.tmatesoft.svn.core.internal.util.SVNURLUtil) SVNException(org.tmatesoft.svn.core.SVNException) StringUtil(com.intellij.openapi.util.text.StringUtil) Info(org.jetbrains.idea.svn.info.Info) SVNAuthenticationException(org.tmatesoft.svn.core.SVNAuthenticationException) File(java.io.File) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) ISVNAuthenticationManager(org.tmatesoft.svn.core.auth.ISVNAuthenticationManager) SVNRevision(org.tmatesoft.svn.core.wc.SVNRevision) SVNURL(org.tmatesoft.svn.core.SVNURL) JBPopupFactory(com.intellij.openapi.ui.popup.JBPopupFactory) GenericNotifierImpl(com.intellij.openapi.vcs.impl.GenericNotifierImpl) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) javax.swing(javax.swing) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) NamedRunnable(com.intellij.openapi.util.NamedRunnable) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Application(com.intellij.openapi.application.Application)

Example 5 with ProgressIndicator

use of com.intellij.openapi.progress.ProgressIndicator in project intellij-community by JetBrains.

the class SvnCheckoutProvider method doExport.

public static void doExport(final Project project, final File target, final SVNURL url, final Depth depth, final boolean ignoreExternals, final boolean force, final String eolStyle) {
    try {
        final VcsException[] exception = new VcsException[1];
        final SvnVcs vcs = SvnVcs.getInstance(project);
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            ProgressIndicator progressIndicator = ProgressManager.getInstance().getProgressIndicator();
            ProgressTracker handler = new CheckoutEventHandler(vcs, true, progressIndicator);
            try {
                progressIndicator.setText(message("progress.text.export", target.getAbsolutePath()));
                SvnTarget from = SvnTarget.fromURL(url);
                ExportClient client = vcs.getFactoryFromSettings().createExportClient();
                client.export(from, target, SVNRevision.HEAD, depth, eolStyle, force, ignoreExternals, handler);
            } catch (VcsException e) {
                exception[0] = e;
            }
        }, message("message.title.export"), true, project);
        if (exception[0] != null) {
            throw exception[0];
        }
    } catch (VcsException e1) {
        showErrorDialog(message("message.text.cannot.export", e1.getMessage()), message("message.title.export"));
    }
}
Also used : ProgressTracker(org.jetbrains.idea.svn.api.ProgressTracker) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) VcsException(com.intellij.openapi.vcs.VcsException) SvnTarget(org.tmatesoft.svn.core.wc2.SvnTarget) SvnVcs(org.jetbrains.idea.svn.SvnVcs)

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