com.intellij.openapi.progress.PerformInBackgroundOption Java Examples

The following examples show how to use com.intellij.openapi.progress.PerformInBackgroundOption. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BlamePopup.java    From GitToolBox with Apache License 2.0 6 votes vote down vote up
private void revealRevisionInLog(@NotNull AbstractVcsLogUi logUi) {
  String revisionNumber = revisionInfo.getRevisionNumber().asString();
  Future<Boolean> future = logUi.getVcsLog().jumpToReference(revisionNumber);
  if (!future.isDone()) {
    ProgressManager.getInstance().run(new Task.Backgroundable(project,
        "Searching for revision " + revisionNumber, false,
        PerformInBackgroundOption.ALWAYS_BACKGROUND) {
      @Override
      public void run(@NotNull ProgressIndicator indicator) {
        try {
          future.get();
        } catch (CancellationException | InterruptedException ignored) {
          Thread.currentThread().interrupt();
        } catch (ExecutionException e) {
          LOG.error(e);
        }
      }
    });
  }
}
 
Example #2
Source File: Communicator.java    From CppTools with Apache License 2.0 6 votes vote down vote up
private void doServerStartup(final Runnable startServerAction) {
  if (ApplicationManager.getApplication().isUnitTestMode()) return;
  serverState = ServerState.STARTING;

  ApplicationManager.getApplication().invokeAndWait(new Runnable() {
    public void run() {
      ProgressManager.getInstance().runProcessWithProgressAsynchronously(
        myProject,
        "analyzing c / c++ sources",
        startServerAction,
        null,
        null,
        new PerformInBackgroundOption() {
          public boolean shouldStartInBackground() {
            return true;
          }

          public void processSentToBackground() {
          }
        }
      );
    }
  }, ModalityState.NON_MODAL);
}
 
Example #3
Source File: DefaultSdksModel.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
private void setupSdk(Sdk newSdk, Consumer<Sdk> callback) {
  UIAccess uiAccess = UIAccess.current();

  new Task.ConditionalModal(null, "Setuping SDK...", false, PerformInBackgroundOption.DEAF) {
    @Override
    public void run(@Nonnull ProgressIndicator indicator) {
      SdkType sdkType = (SdkType)newSdk.getSdkType();
      sdkType.setupSdkPaths(newSdk);

      uiAccess.give(() -> {
        if (newSdk.getVersionString() == null) {
          String home = newSdk.getHomePath();
          Messages.showMessageDialog(ProjectBundle.message("sdk.java.corrupt.error", home), ProjectBundle.message("sdk.java.corrupt.title"), Messages.getErrorIcon());
        }

        doAdd(newSdk, callback);
      });
    }
  }.queue();
}
 
Example #4
Source File: DWCleanAction.java    From intellij-demandware with MIT License 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
    Project project = e.getProject();

    if (project != null) {
        for (Module module : ModuleManager.getInstance(project).getModules()) {
            if (ModuleType.get(module) instanceof DWModuleType) {
                ModuleServiceManager.getService(module, DWServerConnection.class);
                ProgressManager.getInstance().run(
                        new DWCleanTask(project, module, "Cleaning cartridges...", true, PerformInBackgroundOption.ALWAYS_BACKGROUND)
                );

            }
        }
    }

}
 
Example #5
Source File: DWUpdateFileTask.java    From intellij-demandware with MIT License 6 votes vote down vote up
public DWUpdateFileTask(Project project,
                        Module module,
                        final String title,
                        final boolean canBeCancelled,
                        final PerformInBackgroundOption backgroundOption,
                        String sourceRootPath,
                        String localFilePath) {
    super(project, title, canBeCancelled, backgroundOption);
    DWServerConnection serverConnection = ModuleServiceManager.getService(module, DWServerConnection.class);
    this.project = project;
    this.localFilePath = localFilePath;
    this.httpClient = serverConnection.getClient();
    this.context = serverConnection.getContext();
    this.remoteDirPaths = serverConnection.getRemoteDirPaths(sourceRootPath, localFilePath);
    this.remoteFilePath = serverConnection.getRemoteFilePath(sourceRootPath, localFilePath);
}
 
Example #6
Source File: FormatUtils.java    From intellij with Apache License 2.0 6 votes vote down vote up
/** Runs a format future under a progress dialog. */
public static void formatWithProgressDialog(
    Project project, String title, ListenableFuture<?> future) {
  ProgressWindow progressWindow =
      new BackgroundableProcessIndicator(
          project, title, PerformInBackgroundOption.DEAF, "Cancel", "Cancel", true);
  progressWindow.setIndeterminate(true);
  progressWindow.start();
  progressWindow.addStateDelegate(
      new AbstractProgressIndicatorExBase() {
        @Override
        public void cancel() {
          super.cancel();
          future.cancel(true);
        }
      });
  future.addListener(
      () -> {
        if (progressWindow.isRunning()) {
          progressWindow.stop();
          progressWindow.processFinish();
        }
      },
      MoreExecutors.directExecutor());
}
 
Example #7
Source File: WorkspaceModel.java    From azure-devops-intellij with MIT License 6 votes vote down vote up
public void saveWorkspace(final Project project, final String workspaceRootPath, final boolean syncFiles, final Runnable onSuccess) {
    final ServerContext serverContext = currentServerContext;
    final Workspace oldWorkspace = this.oldWorkspace;
    final Workspace newWorkspace = new Workspace(server, name, computer, owner, comment, mappings);

    // Using IntelliJ's background framework here so the user can choose to wait or continue working
    final Task.Backgroundable backgroundTask = new Task.Backgroundable(project,
            TfPluginBundle.message(TfPluginBundle.KEY_WORKSPACE_DIALOG_PROGRESS_TITLE),
            true, PerformInBackgroundOption.DEAF) {
        @Override
        public void run(@NotNull final ProgressIndicator indicator) {
            saveWorkspaceInternal(serverContext, oldWorkspace, newWorkspace, indicator, project,
                    workspaceRootPath, syncFiles, onSuccess);
        }
    };

    backgroundTask.queue();
}
 
Example #8
Source File: BackgroundableProcessIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
public BackgroundableProcessIndicator(Project project,
                                      @Nls final String progressTitle,
                                      @Nonnull PerformInBackgroundOption option,
                                      @Nls final String cancelButtonText,
                                      @Nls final String backgroundStopTooltip, final boolean cancellable) {
  this(project, new TaskInfo() {

    @Override
    @Nonnull
    public String getTitle() {
      return progressTitle;
    }

    @Override
    public String getCancelText() {
      return cancelButtonText;
    }

    @Override
    public String getCancelTooltipText() {
      return backgroundStopTooltip;
    }

    @Override
    public boolean isCancellable() {
      return cancellable;
    }
  }, option);
}
 
Example #9
Source File: PendingAsyncTestContext.java    From intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Waits for the run configuration to be configured, displaying a progress dialog if necessary.
 *
 * @throws com.intellij.execution.ExecutionException if the run configuration is not successfully
 *     configured
 */
private void waitForFutureUnderProgressDialog(Project project)
    throws com.intellij.execution.ExecutionException {
  if (future.isDone()) {
    getFutureHandlingErrors();
  }
  // The progress indicator must be created on the UI thread.
  ProgressWindow indicator =
      UIUtil.invokeAndWaitIfNeeded(
          () ->
              new BackgroundableProcessIndicator(
                  project,
                  progressMessage,
                  PerformInBackgroundOption.ALWAYS_BACKGROUND,
                  "Cancel",
                  "Cancel",
                  /* cancellable= */ true));

  indicator.setIndeterminate(true);
  indicator.start();
  indicator.addStateDelegate(
      new AbstractProgressIndicatorExBase() {
        @Override
        public void cancel() {
          super.cancel();
          future.cancel(true);
        }
      });
  try {
    getFutureHandlingErrors();
  } finally {
    if (indicator.isRunning()) {
      indicator.stop();
      indicator.processFinish();
    }
  }
}
 
Example #10
Source File: VcsBackgroundTaskWithLocalHistory.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected VcsBackgroundTaskWithLocalHistory(Project project,
                                            @Nonnull String title,
                                            @Nonnull PerformInBackgroundOption backgroundOption,
                                            Collection<T> itemsToProcess,
                                            boolean canBeCanceled, String actionName) {
  super(project, title, backgroundOption, itemsToProcess, canBeCanceled);
  myActionName = actionName;
}
 
Example #11
Source File: VcsBackgroundTaskWithLocalHistory.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected VcsBackgroundTaskWithLocalHistory(Project project,
                                            @Nonnull String title,
                                            @Nonnull PerformInBackgroundOption backgroundOption,
                                            Collection<T> itemsToProcess,
                                            String actionName) {
  super(project, title, backgroundOption, itemsToProcess);
  myActionName = actionName;
}
 
Example #12
Source File: ResolveConflictHelper.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Resolve the conflicts based on auto resolve type and then refresh the table model to update the list of conflicts
 *
 * @param conflicts
 * @param type
 */
public void acceptChangeAsync(final List<Conflict> conflicts, final ResolveConflictsCommand.AutoResolveType type, final ResolveConflictsModel model) {
    logger.info(String.format("Accepting changes to %s for file %s", type.name(), Arrays.toString(conflicts.toArray())));
    final Task.Backgroundable loadConflictsTask = new Task.Backgroundable(project, TfPluginBundle.message(TfPluginBundle.KEY_TFVC_CONFLICT_RESOLVING_PROGRESS_BAR),
            true, PerformInBackgroundOption.DEAF) {

        @Override
        public void run(@NotNull final ProgressIndicator progressIndicator) {
            acceptChange(conflicts, progressIndicator, project, type, model);
        }
    };
    loadConflictsTask.queue();
}
 
Example #13
Source File: BackgroundableProcessIndicator.java    From consulo with Apache License 2.0 5 votes vote down vote up
public BackgroundableProcessIndicator(@Nullable final Project project, @Nonnull TaskInfo info, @Nonnull PerformInBackgroundOption option) {
  super(info.isCancellable(), true, project, info.getCancelText());
  setOwnerTask(info);
  myOption = option;
  myInfo = info;
  setTitle(info.getTitle());
  final Project nonDefaultProject = project == null || project.isDisposed() ? null : project.isDefault() ? null : project;
  final IdeFrame frame = ((WindowManagerEx)WindowManager.getInstance()).findFrameFor(nonDefaultProject);
  myStatusBar = frame != null ? (StatusBarEx)frame.getStatusBar() : null;
  myBackgrounded = shouldStartInBackground();
  if (myBackgrounded) {
    doBackground();
  }
}
 
Example #14
Source File: CreateBranchModel.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
/**
 * Creates a new branch on the server from an existing branch on the server
 * TODO: remove method if not needed for other create branch flows
 */
public void createBranch() {
    logger.info("CreateBranchModel.createBranch");
    final ModelValidationInfo validationInfo = validate();
    if (validationInfo == null) {
        final String gitRemoteUrl = TfGitHelper.getTfGitRemote(gitRepository).getFirstUrl();
        final Task.Backgroundable createBranchTask = new Task.Backgroundable(project, TfPluginBundle.message(TfPluginBundle.KEY_CREATE_BRANCH_DIALOG_TITLE),
                true, PerformInBackgroundOption.DEAF) {

            @Override
            public void run(@NotNull final ProgressIndicator progressIndicator) {
                progressIndicator.setText(TfPluginBundle.message(TfPluginBundle.KEY_CREATE_BRANCH_DIALOG_TITLE));
                // get context from manager, and store in active context
                final ServerContext context = ServerContextManager.getInstance().getUpdatedContext(
                        gitRemoteUrl, true);

                if (context == null) {
                    VcsNotifier.getInstance(project).notifyError(TfPluginBundle.message(
                                    TfPluginBundle.KEY_CREATE_BRANCH_ERRORS_AUTHENTICATION_FAILED_TITLE),
                            TfPluginBundle.message(TfPluginBundle.KEY_ERRORS_AUTH_NOT_SUCCESSFUL, gitRemoteUrl));
                    return;
                }
                doBranchCreate(context, progressIndicator);
            }
        };
        createBranchTask.queue();
    }
}
 
Example #15
Source File: QueryKBServerTask.java    From KodeBeagle with Apache License 2.0 5 votes vote down vote up
public QueryKBServerTask(final Project project, final Map<String, Set<String>> pFinalImports) {
    super(project, KODEBEAGLE, true,
            PerformInBackgroundOption.ALWAYS_BACKGROUND);
    this.finalImports = pFinalImports;
    jTree = windowObjects.getjTree();
    jTree.setVisible(true);
}
 
Example #16
Source File: WorkspaceModel.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
public void syncWorkspaceAsync(final ServerContext context, final Project project, final String workspaceRootPath) {
    final Task.Backgroundable backgroundTask = new Task.Backgroundable(project,
            TfPluginBundle.message(TfPluginBundle.KEY_WORKSPACE_DIALOG_PROGRESS_TITLE),
            true, PerformInBackgroundOption.DEAF) {
        @Override
        public void run(@NotNull final ProgressIndicator indicator) {
            try {
                IdeaHelper.setProgress(indicator, 0.30,
                        TfPluginBundle.message(TfPluginBundle.KEY_WORKSPACE_DIALOG_SAVE_PROGRESS_SYNCING));

                // Sync all files recursively
                CommandUtils.syncWorkspace(context, workspaceRootPath);

                // Notify the user of a successful sync
                VcsNotifier.getInstance(project).notifySuccess(
                        TfPluginBundle.message(TfPluginBundle.KEY_WORKSPACE_DIALOG_NOTIFY_SUCCESS_TITLE),
                        TfPluginBundle.message(TfPluginBundle.KEY_WORKSPACE_DIALOG_NOTIFY_SUCCESS_SYNC_MESSAGE));
            } catch (final Throwable t) {
                VcsNotifier.getInstance(project).notifyError(
                        TfPluginBundle.message(TfPluginBundle.KEY_WORKSPACE_DIALOG_NOTIFY_FAILURE_TITLE),
                        LocalizationServiceImpl.getInstance().getExceptionMessage(t));
            }

        }
    };
    backgroundTask.queue();
}
 
Example #17
Source File: VcsConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PerformInBackgroundOption getEditOption() {
  return myEditOption;
}
 
Example #18
Source File: ImportPageModelImpl.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
private void doImport(final Project project, final ServerContext context, final String repositoryName) {
    new Task.Backgroundable(project, TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_IMPORTING_PROJECT), true, PerformInBackgroundOption.DEAF) {
        @Override
        public void run(@NotNull final ProgressIndicator indicator) {
            // Local context can change if the creation of the repo succeeds
            ServerContext localContext = context;
            String remoteUrlForDisplay = "";

            try {
                if (!projectSupportsGitRepos(project, context, indicator)) {
                    logger.error("doImport: the team project {} on collection {} , " +
                                    "server {} does not support Git repositories or is not a hybrid project",
                            localContext.getTeamProjectReference().getName(),
                            localContext.getTeamProjectCollectionReference().getName(), localContext.getUri());
                    return;
                }

                final GitRepository repo = getRepositoryForProject(project);
                final VirtualFile rootVirtualFile = repo != null ? repo.getRoot() : project.getBaseDir();

                final GitRepository localRepository = repo != null ? repo :
                        setupGitRepositoryForProject(project, rootVirtualFile, localContext, indicator);
                if (localRepository == null) {
                    logger.error("doImport: current project {} is not in a Git repository", project.getName());
                    return;
                }

                if (!doFirstCommitIfRequired(project, localRepository, rootVirtualFile, localContext, indicator)) {
                    logger.error("doImport: failed to do first commit on the local repository at: {}", localRepository.getRoot().getUrl());
                    return;
                }

                final com.microsoft.alm.sourcecontrol.webapi.model.GitRepository remoteRepository =
                        createRemoteGitRepo(project, context, localContext, indicator);
                if (remoteRepository != null) {
                    //remote repo creation succeeded, save active context with the repository information
                    localContext = new ServerContextBuilder(localContext).uri(remoteRepository.getRemoteUrl()).repository(remoteRepository).build();
                    ServerContextManager.getInstance().add(localContext);
                } else {
                    logger.error("doImport: failed to create remote repository with name: {} on server: {}, collection: {}",
                            repositoryName, localContext.getUri(), localContext.getTeamProjectCollectionReference().getName());
                    return;
                }

                if (!setupRemoteOnLocalRepo(project, localRepository, remoteRepository, localContext, indicator)) {
                    logger.error("doImport: failed to setup remote origin on local repository at: {} to point to remote repository: {}",
                            localRepository.getRoot().getUrl(), remoteRepository.getRemoteUrl());
                    return;
                }

                if (!pushChangesToRemoteRepo(project, localRepository, remoteRepository, localContext, indicator)) {
                    logger.error("doImport: failed to push changes to remote repository: {}", remoteRepository.getRemoteUrl());
                    return;
                }

                //all steps completed successfully
                remoteUrlForDisplay = remoteRepository.getRemoteUrl();

            } catch (Throwable unexpectedError) {
                remoteUrlForDisplay = "";
                logger.error("doImport: Unexpected error during import");
                logger.warn("doImport", unexpectedError);
                notifyImportError(project, TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_ERRORS_UNEXPECTED, unexpectedError.getLocalizedMessage()));

            } finally {
                if (StringUtils.isNotEmpty(remoteUrlForDisplay)) {
                    // Notify the user that we are done and provide a link to the repo
                    VcsNotifier.getInstance(project).notifyImportantInfo(TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_SUCCEEDED),
                            TfPluginBundle.message(TfPluginBundle.KEY_IMPORT_SUCCEEDED_MESSAGE, project.getName(), remoteUrlForDisplay, repositoryName),
                            NotificationListener.URL_OPENING_LISTENER);
                }
            }
        }

    }.queue();

}
 
Example #19
Source File: CreatePullRequestModel.java    From azure-devops-intellij with MIT License 4 votes vote down vote up
/**
 * Create pull request on a background thread
 * <p/>
 * This method will first check to see if the local branch has a tracking branch:
 * yes:
 * push the commits to the remote tracking branch
 * no:
 * try create a remote branch matching the local branch name exactly, with the remote set to the GitRemote of
 * the target branch
 * <p/>
 * If push fails for whatever reason, stop and show an error message
 * <p/>
 * After we push the local branch, then create the pull request.  Pull request link should be returned
 * in a notification bubble
 */
public void createPullRequest() {
    /* verifying branch selections */
    final GitLocalBranch sourceBranch = this.getSourceBranch();
    final GitRemoteBranch targetBranch = this.getTargetBranch();

    if (sourceBranch == null) {
        // how did we get here? validation failed?
        notifyCreateFailedError(project,
                TfPluginBundle.message(TfPluginBundle.KEY_CREATE_PR_ERRORS_SOURCE_EMPTY));
        return;
    }

    if (targetBranch == null) {
        // how did we get here? validation failed?
        notifyCreateFailedError(project,
                TfPluginBundle.message(TfPluginBundle.KEY_CREATE_PR_ERRORS_TARGET_NOT_SELECTED));
        return;
    }

    if (targetBranch.equals(this.getRemoteTrackingBranch())) {
        // how did we get here? Didn't we filter you out?
        notifyCreateFailedError(project,
                TfPluginBundle.message(TfPluginBundle.KEY_CREATE_PR_ERRORS_TARGET_IS_LOCAL_TRACKING));
        return;
    }

    //TODO Determine the correct/best way to get the remote url
    final String gitRemoteUrl = TfGitHelper.getTfGitRemote(gitRepository).getFirstUrl();
    final CreatePullRequestModel createModel = this;
    /* Let's keep all server interactions to a background thread */
    final Task.Backgroundable createPullRequestTask = new Task.Backgroundable(project, TfPluginBundle.message(TfPluginBundle.KEY_CREATE_PR_DIALOG_TITLE),
            true, PerformInBackgroundOption.DEAF) {
        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            ListenableFuture<Pair<String, GitCommandResult>> pushResult
                    = doPushCommits(gitRepository, sourceBranch, targetBranch.getRemote(), progressIndicator);

            Futures.addCallback(pushResult, new FutureCallback<Pair<String, GitCommandResult>>() {
                @Override
                public void onSuccess(@Nullable Pair<String, GitCommandResult> result) {
                    if (result != null && StringUtils.isNotEmpty(result.getFirst())) {
                        final String title = createModel.getTitle();
                        final String description = createModel.getDescription();
                        final String branchNameOnRemoteServer = result.getFirst();

                        // get context from manager, we want to do this after push completes since credentials could have changed during the Git push
                        final ServerContext context = ServerContextManager.getInstance().getUpdatedContext(
                                gitRemoteUrl, true);

                        if (context == null) {
                            notifyCreateFailedError(project, TfPluginBundle.message(TfPluginBundle.KEY_ERRORS_AUTH_NOT_SUCCESSFUL, gitRemoteUrl));
                            return;
                        }

                        doCreatePullRequest(project, context, title, description, branchNameOnRemoteServer, targetBranch);
                    } else {
                        // I really don't have anything else to say, push failed, the title says it all
                        // I have no error message to be more specific
                        notifyPushFailedError(createModel.getProject(), StringUtils.EMPTY);
                    }
                }

                @Override
                public void onFailure(Throwable t) {
                    notifyPushFailedError(createModel.getProject(), t.getLocalizedMessage());
                }
            }, directExecutor());
        }
    };

    createPullRequestTask.queue();
}
 
Example #20
Source File: FetchFileContentTask.java    From KodeBeagle with Apache License 2.0 4 votes vote down vote up
public FetchFileContentTask(final Project project, final CodeInfo pCodeInfo) {
    super(project, KODE_BEAGLE, true, PerformInBackgroundOption.ALWAYS_BACKGROUND);
    this.codeInfo = pCodeInfo;
}
 
Example #21
Source File: ModalityIgnorantBackgroundableTask.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ModalityIgnorantBackgroundableTask(@javax.annotation.Nullable Project project,
                                          @Nonnull String title,
                                          boolean canBeCancelled,
                                          @Nullable PerformInBackgroundOption backgroundOption) {
  super(project, title, canBeCancelled, backgroundOption);
}
 
Example #22
Source File: AttachToProcessActionBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  final Project project = getEventProject(e);
  if (project == null) return;


  new Task.Backgroundable(project, XDebuggerBundle.message("xdebugger.attach.action.collectingItems"), true, PerformInBackgroundOption.DEAF) {
    @Override
    public void run(@Nonnull ProgressIndicator indicator) {

      List<AttachItem> allItems = ContainerUtil.immutableList(getTopLevelItems(indicator, project));

      ApplicationManager.getApplication().invokeLater(() -> {
        AttachListStep step = new AttachListStep(allItems, XDebuggerBundle.message("xdebugger.attach.popup.title.default"), project);

        final ListPopup popup = JBPopupFactory.getInstance().createListPopup(step);
        final JList mainList = ((ListPopupImpl)popup).getList();

        ListSelectionListener listener = event -> {
          if (event.getValueIsAdjusting()) return;

          Object item = ((JList)event.getSource()).getSelectedValue();

          // if a sub-list is closed, fallback to the selected value from the main list
          if (item == null) {
            item = mainList.getSelectedValue();
          }

          if (item instanceof AttachToProcessItem) {
            popup.setCaption(((AttachToProcessItem)item).getSelectedDebugger().getDebuggerSelectedTitle());
          }

          if (item instanceof AttachHostItem) {
            AttachHostItem hostItem = (AttachHostItem)item;
            String attachHostName = hostItem.getText(project);
            attachHostName = StringUtil.shortenTextWithEllipsis(attachHostName, 50, 0);

            popup.setCaption(XDebuggerBundle.message("xdebugger.attach.host.popup.title", attachHostName));
          }
        };
        popup.addListSelectionListener(listener);

        // force first valueChanged event
        listener.valueChanged(new ListSelectionEvent(mainList, mainList.getMinSelectionIndex(), mainList.getMaxSelectionIndex(), false));

        popup.showCenteredInCurrentWindow(project);
      }, project.getDisposed());
    }
  }.queue();
}
 
Example #23
Source File: VcsBackgroundTask.java    From consulo with Apache License 2.0 4 votes vote down vote up
public VcsBackgroundTask(final Project project, @Nonnull final String title, @Nonnull final PerformInBackgroundOption backgroundOption,
                         final Collection<T> itemsToProcess) {
  this(project, title, backgroundOption, itemsToProcess, false);
}
 
Example #24
Source File: VcsBackgroundTask.java    From consulo with Apache License 2.0 4 votes vote down vote up
public VcsBackgroundTask(final Project project, @Nonnull final String title, @Nonnull final PerformInBackgroundOption backgroundOption,
                         final Collection<T> itemsToProcess, final boolean canBeCanceled) {
  super(project, title, canBeCanceled, backgroundOption);
  myItems = itemsToProcess;
}
 
Example #25
Source File: VcsConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PerformInBackgroundOption getAddRemoveOption() {
  return myAddRemoveOption;
}
 
Example #26
Source File: VcsConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PerformInBackgroundOption getCheckoutOption() {
  return myCheckoutOption;
}
 
Example #27
Source File: VcsConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PerformInBackgroundOption getCommitOption() {
  return myCommitOption;
}
 
Example #28
Source File: VcsConfiguration.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PerformInBackgroundOption getUpdateOption() {
  return myUpdateOption;
}
 
Example #29
Source File: BackgroundFromStartOption.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static PerformInBackgroundOption getInstance() {
  return ourInstance;
}
 
Example #30
Source File: DWBulkFileListener.java    From intellij-demandware with MIT License 4 votes vote down vote up
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
    Project[] projects = ProjectManager.getInstance().getOpenProjects();

    for (VFileEvent event : events) {
        VirtualFile eventFile = event.getFile();

        if (eventFile != null && !eventFile.isDirectory()) {
            for (Project project : projects) {
                Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(eventFile);

                if (module != null) {
                    ModuleType CurrentModuleType = ModuleType.get(module);

                    // Bail out if auto uploads are not enabled.
                    if (!DWSettingsProvider.getInstance(module).getAutoUploadEnabled()) {
                        return;
                    }

                    if (CurrentModuleType instanceof DWModuleType) {
                        for (VirtualFile sourceRoot : ModuleRootManager.getInstance(module).getSourceRoots()) {
                            if (eventFile.getPath().contains(sourceRoot.getPath())) {
                                ProgressManager.getInstance().run(
                                    new DWUpdateFileTask(
                                        project,
                                        module,
                                        "Syncing files to: " + DWSettingsProvider.getInstance(module).getHostname(),
                                        true,
                                        PerformInBackgroundOption.ALWAYS_BACKGROUND,
                                        sourceRoot.getPath(),
                                        eventFile.getPath()
                                    )
                                );
                            }
                        }
                    }
                }
            }
        }
    }
}