Search in sources :

Example 1 with BackgroundableProcessIndicator

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

the class TreeConflictRefreshablePanel method refresh.

@CalledInAwt
public void refresh() {
    ApplicationManager.getApplication().assertIsDispatchThread();
    myDetailsPanel.startLoading();
    Loader task = new Loader(myVcs.getProject(), myLoadingTitle);
    myIndicator = new BackgroundableProcessIndicator(task);
    myQueue.run(task, defaultModalityState(), myIndicator);
}
Also used : BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator) CalledInAwt(org.jetbrains.annotations.CalledInAwt)

Example 2 with BackgroundableProcessIndicator

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

the class ShowImplementationsAction method updateInBackground.

private void updateInBackground(Editor editor, @Nullable PsiElement element, @NotNull ImplementationViewComponent component, String title, @NotNull AbstractPopup popup, @NotNull Ref<UsageView> usageView) {
    final ImplementationsUpdaterTask updaterTask = SoftReference.dereference(myTaskRef);
    if (updaterTask != null) {
        updaterTask.cancelTask();
    }
    //already found
    if (element == null)
        return;
    final ImplementationsUpdaterTask task = new ImplementationsUpdaterTask(element, editor, title, isIncludeAlwaysSelf());
    task.init(popup, component, usageView);
    myTaskRef = new WeakReference<>(task);
    ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, new BackgroundableProcessIndicator(task));
}
Also used : BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator)

Example 3 with BackgroundableProcessIndicator

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

the class SMTestRunnerResultsForm method addToHistory.

private void addToHistory(final SMTestProxy.SMRootTestProxy root, TestConsoleProperties consoleProperties, Disposable parentDisposable) {
    final RunProfile configuration = consoleProperties.getConfiguration();
    if (configuration instanceof RunConfiguration && !(consoleProperties instanceof ImportedTestConsoleProperties) && !ApplicationManager.getApplication().isUnitTestMode() && !myDisposed) {
        final MySaveHistoryTask backgroundable = new MySaveHistoryTask(consoleProperties, root, (RunConfiguration) configuration);
        final BackgroundableProcessIndicator processIndicator = new BackgroundableProcessIndicator(backgroundable);
        Disposer.register(parentDisposable, new Disposable() {

            @Override
            public void dispose() {
                processIndicator.cancel();
                backgroundable.dispose();
            }
        });
        Disposer.register(parentDisposable, processIndicator);
        ProgressManager.getInstance().runProcessWithProgressAsynchronously(backgroundable, processIndicator);
    }
}
Also used : Disposable(com.intellij.openapi.Disposable) ImportedTestConsoleProperties(com.intellij.execution.testframework.sm.runner.history.ImportedTestConsoleProperties) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator) RunProfile(com.intellij.execution.configurations.RunProfile)

Example 4 with BackgroundableProcessIndicator

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

the class AbstractVcsHelperImpl method loadAndShowCommittedChangesDetails.

@Override
public void loadAndShowCommittedChangesDetails(@NotNull final Project project, @NotNull final VcsRevisionNumber revision, @NotNull final VirtualFile virtualFile, @NotNull VcsKey vcsKey, @Nullable final RepositoryLocation location, final boolean isNonLocal) {
    final AbstractVcs vcs = ProjectLevelVcsManager.getInstance(project).findVcsByName(vcsKey.getName());
    if (vcs == null)
        return;
    final CommittedChangesProvider provider = vcs.getCommittedChangesProvider();
    if (provider == null)
        return;
    if (isNonLocal && provider.getForNonLocal(virtualFile) == null)
        return;
    final String title = VcsBundle.message("paths.affected.in.revision", revision instanceof ShortVcsRevisionNumber ? ((ShortVcsRevisionNumber) revision).toShortString() : revision.asString());
    final CommittedChangeList[] list = new CommittedChangeList[1];
    final FilePath[] targetPath = new FilePath[1];
    final VcsException[] exc = new VcsException[1];
    final BackgroundableActionLock lock = BackgroundableActionLock.getLock(project, VcsBackgroundableActions.COMMITTED_CHANGES_DETAILS, revision, virtualFile.getPath());
    if (lock.isLocked())
        return;
    lock.lock();
    Task.Backgroundable task = new Task.Backgroundable(project, title, true) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            try {
                if (!isNonLocal) {
                    final Pair<CommittedChangeList, FilePath> pair = provider.getOneList(virtualFile, revision);
                    if (pair != null) {
                        list[0] = pair.getFirst();
                        targetPath[0] = pair.getSecond();
                    }
                } else {
                    if (location != null) {
                        final ChangeBrowserSettings settings = provider.createDefaultSettings();
                        settings.USE_CHANGE_BEFORE_FILTER = true;
                        settings.CHANGE_BEFORE = revision.asString();
                        final List<CommittedChangeList> changes = provider.getCommittedChanges(settings, location, 1);
                        if (changes != null && changes.size() == 1) {
                            list[0] = changes.get(0);
                        }
                    } else {
                        list[0] = getRemoteList(vcs, revision, virtualFile);
                    }
                }
            } catch (VcsException e) {
                exc[0] = e;
            }
        }

        @Override
        public void onCancel() {
            lock.unlock();
        }

        @Override
        public void onSuccess() {
            lock.unlock();
            if (exc[0] != null) {
                showError(exc[0], failedText(virtualFile, revision));
            } else if (list[0] == null) {
                Messages.showErrorDialog(project, failedText(virtualFile, revision), getTitle());
            } else {
                VirtualFile navigateToFile = targetPath[0] != null ? new VcsVirtualFile(targetPath[0].getPath(), null, VcsFileSystem.getInstance()) : virtualFile;
                showChangesListBrowser(list[0], navigateToFile, title);
            }
        }
    };
    // we can's use runProcessWithProgressAsynchronously(task) because then ModalityState.NON_MODAL would be used
    CoreProgressManager progressManager = (CoreProgressManager) ProgressManager.getInstance();
    progressManager.runProcessWithProgressAsynchronously(task, new BackgroundableProcessIndicator(task), null, ModalityState.current());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) Task(com.intellij.openapi.progress.Task) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) CommittedChangeList(com.intellij.openapi.vcs.versionBrowser.CommittedChangeList) NotNull(org.jetbrains.annotations.NotNull) ChangeBrowserSettings(com.intellij.openapi.vcs.versionBrowser.ChangeBrowserSettings) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator)

Example 5 with BackgroundableProcessIndicator

use of com.intellij.openapi.progress.impl.BackgroundableProcessIndicator in project android by JetBrains.

the class SmwOldApiDirectInstall method startSdkInstallUsingNonSwtOldApi.

private void startSdkInstallUsingNonSwtOldApi() {
    // Get the SDK instance.
    final AndroidSdkHandler sdkHandler = AndroidSdks.getInstance().tryToChooseSdkHandler();
    if (sdkHandler.getLocation() == null) {
        myErrorLabel.setText("Error: can't get SDK instance.");
        myErrorLabel.setIcon(AllIcons.General.BalloonError);
        return;
    }
    File androidSdkPath = IdeSdks.getInstance().getAndroidSdkPath();
    if (androidSdkPath != null && androidSdkPath.exists() && !androidSdkPath.canWrite()) {
        myErrorLabel.setText(String.format("SDK folder is read-only: '%1$s'", androidSdkPath.getPath()));
        myErrorLabel.setIcon(AllIcons.General.BalloonError);
        return;
    }
    myLabelSdkPath.setText(sdkHandler.getLocation().getPath());
    final CustomLogger logger = new CustomLogger();
    final com.android.repository.api.ProgressIndicator repoProgress = new StudioLoggerProgressIndicator(getClass());
    RepoManager.RepoLoadedCallback onComplete = packages -> UIUtil.invokeLaterIfNeeded(() -> {
        List<String> requestedChanges = myState.get(INSTALL_REQUESTS_KEY);
        if (requestedChanges == null) {
            assert false : "Shouldn't be in installer with no requests";
            myInstallFinished = true;
            invokeUpdate(null);
            return;
        }
        Map<String, RemotePackage> remotes = packages.getRemotePackages();
        List<RemotePackage> requestedPackages = Lists.newArrayList();
        boolean notFound = false;
        for (String path : requestedChanges) {
            RemotePackage remotePackage = remotes.get(path);
            if (remotePackage != null) {
                requestedPackages.add(remotePackage);
            } else {
                notFound = true;
            }
        }
        if (requestedPackages.isEmpty()) {
            myInstallFinished = true;
            invokeUpdate(null);
        } else {
            requestedPackages = InstallerUtil.computeRequiredPackages(requestedPackages, packages, repoProgress);
            if (requestedPackages == null) {
                notFound = true;
            } else {
                InstallTask task = new InstallTask(sdkHandler, requestedPackages, logger);
                BackgroundableProcessIndicator indicator = new BackgroundableProcessIndicator(task);
                logger.setIndicator(indicator);
                ProgressManager.getInstance().runProcessWithProgressAsynchronously(task, indicator);
            }
        }
        if (notFound) {
            myErrorLabel.setText("Problem: Some required packages could not be installed. Check internet connection.");
            myErrorLabel.setIcon(AllIcons.General.BalloonError);
        }
    });
    StudioProgressRunner runner = new StudioProgressRunner(false, false, "Updating SDK", false, null);
    sdkHandler.getSdkManager(repoProgress).load(RepoManager.DEFAULT_EXPIRATION_PERIOD_MS, null, ImmutableList.of(onComplete), null, runner, new StudioDownloader(), StudioSettingsController.getInstance(), false);
}
Also used : ILogger(com.android.utils.ILogger) UIUtil(com.intellij.util.ui.UIUtil) AllIcons(com.intellij.icons.AllIcons) VirtualFile(com.intellij.openapi.vfs.VirtualFile) StudioSdkInstallerUtil(com.android.tools.idea.sdk.install.StudioSdkInstallerUtil) NEWLY_INSTALLED_API_KEY(com.android.tools.idea.wizard.WizardConstants.NEWLY_INSTALLED_API_KEY) FileOp(com.android.repository.io.FileOp) INSTALL_REQUESTS_KEY(com.android.tools.idea.wizard.WizardConstants.INSTALL_REQUESTS_KEY) JBLabel(com.intellij.ui.components.JBLabel) RemotePackage(com.android.repository.api.RemotePackage) IPkgDesc(com.android.sdklib.repository.legacy.descriptors.IPkgDesc) Lists(com.google.common.collect.Lists) Task(com.intellij.openapi.progress.Task) ImmutableList(com.google.common.collect.ImmutableList) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) Map(java.util.Map) InstallerFactory(com.android.repository.api.InstallerFactory) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator) ProgressManager(com.intellij.openapi.progress.ProgressManager) Installer(com.android.repository.api.Installer) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) AndroidVersion(com.android.sdklib.AndroidVersion) PkgType(com.android.sdklib.repository.legacy.descriptors.PkgType) LoggerProgressIndicatorWrapper(com.android.sdklib.repository.LoggerProgressIndicatorWrapper) InstallerUtil(com.android.repository.util.InstallerUtil) Disposable(com.intellij.openapi.Disposable) LocalFileSystem(com.intellij.openapi.vfs.LocalFileSystem) File(java.io.File) com.android.tools.idea.sdk(com.android.tools.idea.sdk) DynamicWizardStepWithDescription(com.android.tools.idea.wizard.dynamic.DynamicWizardStepWithDescription) InstallSelectedPackagesStep(com.android.tools.idea.sdk.wizard.InstallSelectedPackagesStep) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) List(java.util.List) FileOpUtils(com.android.repository.io.FileOpUtils) RepoManager(com.android.repository.api.RepoManager) NotNull(org.jetbrains.annotations.NotNull) PerformInBackgroundOption(com.intellij.openapi.progress.PerformInBackgroundOption) javax.swing(javax.swing) StudioProgressRunner(com.android.tools.idea.sdk.progress.StudioProgressRunner) AndroidSdkHandler(com.android.sdklib.repository.AndroidSdkHandler) StudioLoggerProgressIndicator(com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator) RepoManager(com.android.repository.api.RepoManager) BackgroundableProcessIndicator(com.intellij.openapi.progress.impl.BackgroundableProcessIndicator) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) RemotePackage(com.android.repository.api.RemotePackage)

Aggregations

BackgroundableProcessIndicator (com.intellij.openapi.progress.impl.BackgroundableProcessIndicator)10 NotNull (org.jetbrains.annotations.NotNull)5 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)4 Task (com.intellij.openapi.progress.Task)3 AndroidSdkHandler (com.android.sdklib.repository.AndroidSdkHandler)2 StudioSdkInstallerUtil (com.android.tools.idea.sdk.install.StudioSdkInstallerUtil)2 StudioLoggerProgressIndicator (com.android.tools.idea.sdk.progress.StudioLoggerProgressIndicator)2 Disposable (com.intellij.openapi.Disposable)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 IDevice (com.android.ddmlib.IDevice)1 AndroidLocation (com.android.prefs.AndroidLocation)1 com.android.repository.api (com.android.repository.api)1 Installer (com.android.repository.api.Installer)1 InstallerFactory (com.android.repository.api.InstallerFactory)1 RemotePackage (com.android.repository.api.RemotePackage)1 RepoManager (com.android.repository.api.RepoManager)1 TypeDetails (com.android.repository.impl.meta.TypeDetails)1 FileOp (com.android.repository.io.FileOp)1 FileOpUtils (com.android.repository.io.FileOpUtils)1