Java源码示例:com.intellij.openapi.progress.PerformInBackgroundOption

示例1
/** 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());
}
 
示例2
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();
}
 
示例3
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);
}
 
示例4
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)
                );

            }
        }
    }

}
 
示例5
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);
        }
      }
    });
  }
}
 
示例6
@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();
}
 
示例7
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);
}
 
示例8
/**
 * 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();
    }
  }
}
 
示例9
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();
}
 
示例10
/**
 * 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();
}
 
示例11
/**
 * 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();
    }
}
 
示例12
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);
}
 
示例13
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();
  }
}
 
示例14
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);
}
 
示例15
protected VcsBackgroundTaskWithLocalHistory(Project project,
                                            @Nonnull String title,
                                            @Nonnull PerformInBackgroundOption backgroundOption,
                                            Collection<T> itemsToProcess,
                                            String actionName) {
  super(project, title, backgroundOption, itemsToProcess);
  myActionName = actionName;
}
 
示例16
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;
}
 
示例17
/**
 * Runs the given task on the specified executor (defaulting to BlazeExecutor's executor) with a
 * progress dialog.
 */
public <T> ListenableFuture<T> submitTaskWithResult(ProgressiveWithResult<T> progressive) {
  // The progress indicator must be created on the UI thread.
  final ProgressWindow indicator =
      UIUtil.invokeAndWaitIfNeeded(
          () -> {
            if (modality == Modality.MODAL) {
              ProgressWindow window = new ProgressWindow(cancelable, project);
              window.setTitle(title);
              return window;
            } else {
              PerformInBackgroundOption backgroundOption =
                  modality == Modality.BACKGROUNDABLE
                      ? PerformInBackgroundOption.DEAF
                      : PerformInBackgroundOption.ALWAYS_BACKGROUND;
              return new BackgroundableProcessIndicator(
                  project, title, backgroundOption, "Cancel", "Cancel", cancelable);
            }
          });

  indicator.setIndeterminate(true);
  indicator.start();
  final ListenableFuture<T> future =
      executor.submit(
          () ->
              ProgressManager.getInstance()
                  .runProcess(() -> progressive.compute(indicator), indicator));
  if (cancelable) {
    indicator.addStateDelegate(
        new AbstractProgressIndicatorExBase() {
          @Override
          public void cancel() {
            super.cancel();
            future.cancel(true);
          }
        });
  }
  future.addListener(
      () -> {
        if (indicator.isRunning()) {
          indicator.stop();
          indicator.processFinish();
        }
      },
      MoreExecutors.directExecutor());
  return future;
}
 
示例18
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();

}
 
示例19
/**
 * 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();
}
 
示例20
public FetchFileContentTask(final Project project, final CodeInfo pCodeInfo) {
    super(project, KODE_BEAGLE, true, PerformInBackgroundOption.ALWAYS_BACKGROUND);
    this.codeInfo = pCodeInfo;
}
 
示例21
@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()
                                    )
                                );
                            }
                        }
                    }
                }
            }
        }
    }
}
 
示例22
public DWCleanTask(Project project, Module module, String title, boolean canBeCancelled, PerformInBackgroundOption backgroundOption) {
    super(project, title, canBeCancelled, backgroundOption);
    this.module = module;
    this.project = project;
}
 
示例23
private void execute(final Project project, final VCSBuilder vcsBuilder, VirtualFile[] vFiles) throws Exception {
    vcsBuilder.build(project, vFiles);
    final String diff = vcsBuilder.getDiff();
    if (diff == null) {
        Messages.showMessageDialog(project, "No diff generated", "Warn", null);
        return;
    }

    final ReviewBoardClient reviewBoardClient = new ReviewBoardClient();
    Task.Backgroundable task = new Task.Backgroundable(project, "Query Repository...", false, new PerformInBackgroundOption() {
        @Override
        public boolean shouldStartInBackground() {
            return false;
        }

        @Override
        public void processSentToBackground() {
        }
    }) {

        @Override
        public void run(@NotNull ProgressIndicator progressIndicator) {
            progressIndicator.setIndeterminate(true);
            Repository[] repositories;
            try {
                repositories = reviewBoardClient.getRepositories().repositories;
            } catch (Exception e) {
                PopupUtil.showBalloonForActiveFrame("Error to list repository:" + e.getMessage(), MessageType.ERROR);
                throw new RuntimeException(e);
            }
            if (repositories != null) {
                final Repository[] finalRepositories = repositories;
                ApplicationManager.getApplication().invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        showPostForm(project, vcsBuilder, finalRepositories);
                    }
                });

            }
        }
    };
    ProgressManager.getInstance().run(task);
}
 
示例24
private void showPostForm(final Project project, final VCSBuilder vcsBuilder, Repository[] repositories) {
        int possibleRepoIndex = getPossibleRepoIndex(vcsBuilder.getRepositoryURL(), repositories);
        final PrePostReviewForm prePostReviewForm = new PrePostReviewForm(project, changeMessage, vcsBuilder.getDiff(), repositories, possibleRepoIndex) {

            @Override
            protected void doOKAction() {
                if (!isOKActionEnabled()) {
                    return;
                }
                final ReviewSettings setting = this.getSetting();
                if (setting == null) {
                    return;
                }
                if (vcsBuilder.getBasePath() == null) {
                    setting.setSvnBasePath("");
                } else {
                    setting.setSvnBasePath(vcsBuilder.getBasePath());
                }
                setting.setSvnRoot(vcsBuilder.getRepositoryURL());
                if (this.getDiff() != null) {
                    setting.setDiff(this.getDiff());
                } else {
                    setting.setDiff(vcsBuilder.getDiff());
                }
                Task.Backgroundable task = new Task.Backgroundable(project, "Running", false, new PerformInBackgroundOption() {
                    @Override
                    public boolean shouldStartInBackground() {
                        return false;
                    }

                    @Override
                    public void processSentToBackground() {
                    }
                }) {
                    boolean result;

                    @Override
                    public void onSuccess() {
                        if (result) {
                            String url = ReviewBoardSettings.getSettings().getServer() + "/r/" + setting.getReviewId() + "/diff/";
                            int success = Messages.showYesNoDialog("The review url is " + url + "\r\n" +
                                    "Open the url?", "Success", null);
                            if (success == 0) {
                                BrowserUtil.browse(url);
                            }
                        } else {
//                            Messages.showErrorDialog("Post review failure", "Error");
                            PopupUtil.showBalloonForActiveFrame("Post review failure", MessageType.ERROR);
                        }
                    }

                    @Override
                    public void run(@NotNull ProgressIndicator progressIndicator) {
                        progressIndicator.setIndeterminate(true);
                        try {
                            result = ReviewBoardClient.postReview(setting, progressIndicator);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                };
                ProgressManager.getInstance().run(task);
                super.doOKAction();
            }
        };
        prePostReviewForm.show();
    }
 
示例25
/**
 * Runs {@link AbstractIncomingResourceNegotiation#run(java.util.Map, IProgressMonitor)} as a
 * background task through {@link #runTask(Runnable, String)}.
 *
 * <p>On success, a success notification is displayed, on error, a dialog is shown.
 */
private void triggerResourceNegotiation() {

  if (triggered) return;

  triggered = true;

  ProgressManager.getInstance()
      .run(
          new Task.Backgroundable(
              project,
              Messages.AddReferencePointToSessionWizard_negotiation_progress_title,
              true,
              PerformInBackgroundOption.DEAF) {

            @Override
            public void run(@NotNull ProgressIndicator indicator) {
              final ResourceNegotiation.Status status =
                  negotiation.run(localReferencePoints, new ProgressMonitorAdapter(indicator));

              indicator.stop();

              if (status == ResourceNegotiation.Status.ERROR) {
                NotificationPanel.showError(
                    MessageFormat.format(
                        Messages.AddReferencePointToSessionWizard_negotiation_error_message,
                        negotiation.getErrorMessage()),
                    Messages.AddReferencePointToSessionWizard_negotiation_error_title);

              } else if (status == ResourceNegotiation.Status.OK) {
                NotificationPanel.showInformation(
                    Messages.AddReferencePointToSessionWizard_negotiation_successful_message,
                    Messages.AddReferencePointToSessionWizard_negotiation_successful_title);

              } else
                NotificationPanel.showError(
                    Messages.AddReferencePointToSessionWizard_negotiation_aborted_message,
                    Messages.AddReferencePointToSessionWizard_negotiation_aborted_title);
            }
          });

  close();
}
 
示例26
public static PerformInBackgroundOption getInstance() {
  return ourInstance;
}
 
示例27
public PerformInBackgroundOption getUpdateOption() {
  return myUpdateOption;
}
 
示例28
public PerformInBackgroundOption getCommitOption() {
  return myCommitOption;
}
 
示例29
public PerformInBackgroundOption getEditOption() {
  return myEditOption;
}
 
示例30
public PerformInBackgroundOption getCheckoutOption() {
  return myCheckoutOption;
}