Java Code Examples for com.intellij.openapi.progress.ProgressIndicator.setText2()

The following are Jave code examples for showing how to use setText2() of the com.intellij.openapi.progress.ProgressIndicator class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: StAnalysisRunner   File: AnalysisTask.java   Source Code and License Vote up 6 votes
@NotNull
private String getAnalysisOutput(@NotNull final ProgressIndicator progressIndicator) throws Exception {
    final List<String> gradlewCommand = System.getProperty("os.name").startsWith("Windows")
            ? Arrays.asList("cmd", "/c", "gradlew.bat", "staticAnalys")
            : Arrays.asList("./gradlew", "staticAnalys");
    gradlewProcess = new ProcessBuilder(gradlewCommand)
            .directory(new File(project.getBasePath()))
            .redirectErrorStream(true)
            .start();
    BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(gradlewProcess.getInputStream()));
    StringBuilder analysisOutputBuilder = new StringBuilder();

    String outputLine;
    while ((outputLine = bufferedReader.readLine()) != null) {
        progressIndicator.setText2(outputLine);
        progressIndicator.checkCanceled();
        analysisOutputBuilder.append(outputLine);
        analysisOutputBuilder.append('\n');
    }

    return analysisOutputBuilder.toString();
}
 
Example 2
Project: mule-intellij-plugins   File: MuleSdkSelectionDialog.java   Source Code and License Vote up 6 votes
private boolean download(ProgressIndicator progressIndicator, URL url, File outputFile, String version) {
    try {
        HttpURLConnection httpConnection = (HttpURLConnection) (url.openConnection());
        long completeFileSize = httpConnection.getContentLength();
        java.io.BufferedInputStream in = new java.io.BufferedInputStream(httpConnection.getInputStream());
        java.io.FileOutputStream fos = new java.io.FileOutputStream(outputFile);
        java.io.BufferedOutputStream bout = new BufferedOutputStream(fos, BUFFER_SIZE);
        byte[] data = new byte[BUFFER_SIZE];
        long downloadedFileSize = 0;
        int x;
        while (!progressIndicator.isCanceled() && (x = in.read(data, 0, BUFFER_SIZE)) >= 0) {
            downloadedFileSize += x;
            // calculate progress
            final double currentProgress = ((double) downloadedFileSize) / ((double) completeFileSize);
            progressIndicator.setFraction(currentProgress);
            progressIndicator.setText2(Math.ceil(downloadedFileSize / (1024 * 1024)) + "/" + (Math.ceil(completeFileSize / (1024 * 1024)) + " MB"));
            bout.write(data, 0, x);
        }
        bout.close();
        in.close();
    } catch (IOException e) {
        Messages.showErrorDialog("An error occurred while trying to download " + version + ".\n" + e.getMessage(), "Mule SDK Download Error");
        return false;
    }
    return !progressIndicator.isCanceled();
}
 
Example 3
Project: intellij-ce-playground   File: Waiter.java   Source Code and License Vote up 6 votes
public void run(@NotNull ProgressIndicator indicator) {
  indicator.setIndeterminate(true);
  indicator.setText2(VcsBundle.message("commit.wait.util.synched.text"));
  synchronized (myLock) {
    if (myStarted) {
      LOG.error("Waiter running under progress being started again.");
      return;
    }
    myStarted = true;
    while (! myDone) {
      try {
        // every second check whether we are canceled
        myLock.wait(500);
      }
      catch (InterruptedException e) {
        // ok
      }
      indicator.checkCanceled();
    }
  }
}
 
Example 4
Project: intellij-ce-playground   File: HistoryCacheManager.java   Source Code and License Vote up 6 votes
@Override
public void run(@NotNull ProgressIndicator indicator) {
  try {
    //indicator.setText2("Checking and possibly creating database");
    indicator.setText2("Updating VCS and roots");
    final MultiMap<String, String> map = new MultiMap<String, String>();
    myCachesHolder.iterateAllRepositoryLocations(new PairProcessor<RepositoryLocation, AbstractVcs>() {
      @Override
      public boolean process(RepositoryLocation location, AbstractVcs vcs) {
        map.putValue(vcs.getName(), location2string(location));
        return true;
      }
    });
    myDbUtil.checkVcsRootsAreTracked(map);
  }
  catch (VcsException e) {
    LOG.info(e);
    myException = e;
  }
}
 
Example 5
Project: intellij-ce-playground   File: CodeStyleSettingsCodeFragmentFilter.java   Source Code and License Vote up 6 votes
@Override
public boolean iteration() {
  popUntilCurrentTaskUnfinishedOrNull();

  if (myCurrentTask != null) {
    ProgressIndicator indicator = myProgressTask.getIndicator();
    if (indicator != null) {
      if (myProgressText != null) indicator.setText(myProgressText);
      if (myProgressText2 != null) indicator.setText2(myProgressText2);
      indicator.setFraction((double)myIterationsFinished++ / myTotalIterations);
    }
    myCurrentTask.iteration();
  }

  return true;
}
 
Example 6
Project: intellij-ce-playground   File: RepositoryBrowserDialog.java   Source Code and License Vote up 6 votes
private void doCopy(final SVNURL src, final SVNURL dst, final boolean move, final String comment) {
  final Ref<Exception> exception = new Ref<Exception>();
  Runnable command = new Runnable() {
    public void run() {
      ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      if (progress != null) {
        progress.setText((move ? SvnBundle.message("progress.text.browser.moving", src) : SvnBundle.message("progress.text.browser.copying", src)));
        progress.setText2(SvnBundle.message("progress.text.browser.remote.destination", dst));
      }
      SvnVcs vcs = SvnVcs.getInstance(myProject);
      try {
        vcs.getFactoryFromSettings().createCopyMoveClient().copy(SvnTarget.fromURL(src), SvnTarget.fromURL(dst), SVNRevision.HEAD, true,
                                                                 move, comment, null);
      }
      catch (VcsException e) {
        exception.set(e);
      }
    }
  };
  String progressTitle = move ? SvnBundle.message("progress.title.browser.move") : SvnBundle.message("progress.title.browser.copy");
  ProgressManager.getInstance().runProcessWithProgressSynchronously(command, progressTitle, false, myProject);
  if (!exception.isNull()) {
    Messages.showErrorDialog(exception.get().getMessage(), SvnBundle.message("message.text.error"));
  }
}
 
Example 7
Project: intellij-ce-playground   File: SvnLogUtil.java   Source Code and License Vote up 6 votes
@NotNull
private LogEntryConsumer createLogHandler(final SVNRevision fromIncluding,
                                             final SVNRevision toIncluding,
                                             final boolean includingYoungest,
                                             final boolean includeOldest, final List<CommittedChangeList> result) {
  return new LogEntryConsumer() {
    @Override
    public void consume(LogEntry logEntry) {
      if (myProject.isDisposed()) throw new ProcessCanceledException();
      final ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      if (progress != null) {
        progress.setText2(SvnBundle.message("progress.text2.processing.revision", logEntry.getRevision()));
        progress.checkCanceled();
      }
      if ((!includingYoungest) && (logEntry.getRevision() == fromIncluding.getNumber())) {
        return;
      }
      if ((!includeOldest) && (logEntry.getRevision() == toIncluding.getNumber())) {
        return;
      }
      result.add(new SvnChangeList(myVcs, myLocation, logEntry, myRepositoryRoot.toString()));
    }
  };
}
 
Example 8
Project: educational-plugin   File: CCStepicConnector.java   Source Code and License Vote up 5 votes
private static void postAdditionalFiles(Course course, @NotNull final Project project, int id) {
  final Lesson lesson = CCUtils.createAdditionalLesson(course, project);
  if (lesson != null) {
    final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
    if (indicator != null) {
      indicator.setText2("Publishing additional files");
    }
    final int sectionId = postModule(id, 2, EduNames.PYCHARM_ADDITIONAL, project);
    final int lessonId = postLesson(project, lesson);
    postUnit(lessonId, 1, sectionId, project);
  }
}
 
Example 9
Project: intellij-ce-playground   File: SpellCheckerDictionaryGenerator.java   Source Code and License Vote up 5 votes
private void generateDictionary(final Project project, final Collection<VirtualFile> folderPaths, final String outFile,
                                final ProgressIndicator progressIndicator) {
  final HashSet<String> seenNames = new HashSet<String>();
  // Collect stuff
  for (VirtualFile folder : folderPaths) {
    progressIndicator.setText2("Scanning folder: " + folder.getPath());
    final PsiManager manager = PsiManager.getInstance(project);
    processFolder(seenNames, manager, folder);
  }

  if (seenNames.isEmpty()) {
    LOG.info("  No new words was found.");
    return;
  }

  final StringBuilder builder = new StringBuilder();
  // Sort names
  final ArrayList<String> names = new ArrayList<String>(seenNames);
  Collections.sort(names);
  for (String name : names) {
    if (builder.length() > 0){
      builder.append("\n");
    }
    builder.append(name);
  }
  try {
    final File dictionaryFile = new File(outFile);
    FileUtil.createIfDoesntExist(dictionaryFile);
    final FileWriter writer = new FileWriter(dictionaryFile.getPath());
    try {
      writer.write(builder.toString());
    }
    finally {
      writer.close();
    }
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
 
Example 10
Project: intellij-ce-playground   File: SvnFileRevision.java   Source Code and License Vote up 5 votes
public void run() {
  ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
  if (progress != null) {
    progress.setText(SvnBundle.message("progress.text.loading.contents", myURL));
    progress.setText2(SvnBundle.message("progress.text2.revision.information", myRevision));
  }

  try {
    myContents = SvnUtil.getFileContents(myVCS, SvnTarget.fromURL(SvnUtil.parseUrl(myURL)), myRevision, myPegRevision);
  }
  catch (VcsException e) {
    myException = e;
  }
}
 
Example 11
Project: intellij-ce-playground   File: AnalysisScope.java   Source Code and License Vote up 5 votes
public int getFileCount() {
  if (myFilesSet == null) initFilesSet();
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null) { //clear text after building analysis scope set
    indicator.setText("");
    indicator.setText2("");
  }
  return myFilesSet.size();
}
 
Example 12
Project: intellij-ce-playground   File: EditorsSplitters.java   Source Code and License Vote up 5 votes
private void initializeProgress() {
  ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null) {
    indicator.setText(IdeBundle.message("loading.editors"));
    indicator.setText2("");
    indicator.setIndeterminate(false);
    indicator.setFraction(0);

    myProgressMaximum = countFiles(mySplittersElement);
    myCurrentProgress = 0;
  }
}
 
Example 13
Project: intellij-ce-playground   File: SvnFormatWorker.java   Source Code and License Vote up 5 votes
private static ProgressTracker createUpgradeHandler(@NotNull final ProgressIndicator indicator,
                                                     @NotNull final String cleanupMessage,
                                                     @NotNull final String upgradeMessage) {
  return new ProgressTracker() {
    @Override
    public void consume(ProgressEvent event) throws SVNException {
      if (event.getFile() != null) {
        if (EventAction.UPGRADED_PATH.equals(event.getAction())) {
          indicator.setText2("Upgraded path " + VcsUtil.getPathForProgressPresentation(event.getFile()));
        }
        // fake event indicating cleanup start
        if (EventAction.UPDATE_STARTED.equals(event.getAction())) {
          indicator.setText(cleanupMessage);
        }
        // fake event indicating upgrade start
        if (EventAction.UPDATE_COMPLETED.equals(event.getAction())) {
          indicator.setText(upgradeMessage);
        }
      }
    }

    @Override
    public void checkCancelled() throws SVNCancelException {
      indicator.checkCanceled();
    }
  };
}
 
Example 14
Project: intellij-ce-playground   File: GenerateBinaryStubsFix.java   Source Code and License Vote up 5 votes
private boolean generateSkeletonsForList(@NotNull final PySkeletonRefresher refresher,
                                         ProgressIndicator indicator,
                                         @Nullable final String currentBinaryFilesPath) throws InvalidSdkException {
  final PySkeletonGenerator generator = new PySkeletonGenerator(refresher.getSkeletonsPath(), mySdk, currentBinaryFilesPath);
  indicator.setIndeterminate(false);
  final String homePath = mySdk.getHomePath();
  if (homePath == null) return false;
  GeneralCommandLine cmd = PythonHelper.EXTRA_SYSPATH.newCommandLine(homePath, Lists.newArrayList(myQualifiedName));
  final ProcessOutput runResult = PySdkUtil.getProcessOutput(cmd,
                                                             new File(homePath).getParent(),
                                                             PythonSdkType.getVirtualEnvExtraEnv(homePath), 5000
  );
  if (runResult.getExitCode() == 0 && !runResult.isTimeout()) {
    final String extraPath = runResult.getStdout();
    final PySkeletonGenerator.ListBinariesResult binaries = generator.listBinaries(mySdk, extraPath);
    final List<String> names = Lists.newArrayList(binaries.modules.keySet());
    Collections.sort(names);
    final int size = names.size();
    for (int i = 0; i != size; ++i) {
      final String name = names.get(i);
      indicator.setFraction((double)i / size);
      if (needBinaryList(name)) {
        indicator.setText2(name);
        final PySkeletonRefresher.PyBinaryItem item = binaries.modules.get(name);
        final String modulePath = item != null ? item.getPath() : "";
        //noinspection unchecked
        refresher.generateSkeleton(name, modulePath, new ArrayList<String>(), Consumer.EMPTY_CONSUMER);
      }
    }
  }
  return true;
}
 
Example 15
Project: intellij-ce-playground   File: MavenProgressIndicator.java   Source Code and License Vote up 5 votes
public synchronized void setIndicator(ProgressIndicator i) {
  i.setText(myIndicator.getText());
  i.setText2(myIndicator.getText2());
  i.setFraction(myIndicator.getFraction());
  if (i.isCanceled()) i.cancel();
  myIndicator = i;
}
 
Example 16
Project: intellij-ce-playground   File: MavenExecutor.java   Source Code and License Vote up 5 votes
void displayProgress() {
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null) {
    indicator.setText(MessageFormat.format("{0} {1}", myAction != null ? myAction : RunnerBundle.message("maven.running"),
                                           myParameters.getWorkingDirPath()));
    indicator.setText2(myParameters.getGoals().toString());
  }
}
 
Example 17
Project: intellij-ce-playground   File: HgRegularUpdater.java   Source Code and License Vote up 5 votes
private void updateToPulledHead(VirtualFile repo, UpdatedFiles updatedFiles, HgRevisionNumber newHead, ProgressIndicator indicator) {
  indicator.setText2(HgVcsMessages.message("hg4idea.update.progress.updating.to.pulled.head"));
  HgRevisionNumber parentBeforeUpdate = new HgWorkingCopyRevisionsCommand(project).firstParent(repo);
  HgUpdateCommand updateCommand = new HgUpdateCommand(project, repoRoot);
  updateCommand.setRevision(newHead.getChangeset());
  updateCommand.setClean(true);
  updateCommand.execute();

  HgRevisionNumber commonParent = findCommonParent(newHead, parentBeforeUpdate);
  addUpdatedFiles(repo, updatedFiles, commonParent, newHead);
}
 
Example 18
Project: educational-plugin   File: CCStepicConnector.java   Source Code and License Vote up 4 votes
private static void postCourse(final Project project, @NotNull Course course) {
  if (!checkIfAuthorized(project, "post course")) return;

  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null) {
    indicator.setText("Uploading course to " + EduStepicNames.STEPIC_URL);
    indicator.setIndeterminate(false);
  }
  final HttpPost request = new HttpPost(EduStepicNames.STEPIC_API_URL + "/courses");

  final StepicUser currentUser = EduStepicAuthorizedClient.getCurrentUser();
  if (currentUser != null) {
    final List<StepicUser> courseAuthors = course.getAuthors();
    for (int i = 0; i < courseAuthors.size(); i++) {
      if (courseAuthors.size() > i) {
        final StepicUser courseAuthor = courseAuthors.get(i);
        currentUser.setFirstName(courseAuthor.getFirstName());
        currentUser.setLastName(courseAuthor.getLastName());
      }
    }
    course.setAuthors(Collections.singletonList(currentUser));
  }

  String requestBody = new Gson().toJson(new StepicWrappers.CourseWrapper(course));
  request.setEntity(new StringEntity(requestBody, ContentType.APPLICATION_JSON));

  try {
    final CloseableHttpClient client = EduStepicAuthorizedClient.getHttpClient();
    if (client == null) {
      LOG.warn("Http client is null");
      return;
    }
    final CloseableHttpResponse response = client.execute(request);
    final HttpEntity responseEntity = response.getEntity();
    final String responseString = responseEntity != null ? EntityUtils.toString(responseEntity) : "";
    final StatusLine line = response.getStatusLine();
    EntityUtils.consume(responseEntity);
    if (line.getStatusCode() != HttpStatus.SC_CREATED) {
      final String message = FAILED_TITLE + "course ";
      LOG.error(message + responseString);
      showErrorNotification(project, FAILED_TITLE, responseString);
      return;
    }
    final RemoteCourse postedCourse = new Gson().fromJson(responseString, StepicWrappers.CoursesContainer.class).courses.get(0);
    postedCourse.setLessons(course.getLessons(true));
    postedCourse.setAuthors(course.getAuthors());
    postedCourse.setCourseMode(CCUtils.COURSE_MODE);
    postedCourse.setLanguage(course.getLanguageID());
    final int sectionId = postModule(postedCourse.getId(), 1, String.valueOf(postedCourse.getName()), project);
    int position = 1;
    for (Lesson lesson : course.getLessons()) {
      if (indicator != null) {
        indicator.checkCanceled();
        indicator.setText2("Publishing lesson " + lesson.getIndex());
      }
      final int lessonId = postLesson(project, lesson);
      postUnit(lessonId, position, sectionId, project);
      if (indicator != null) {
        indicator.setFraction((double)lesson.getIndex()/course.getLessons().size());
        indicator.checkCanceled();
      }
      position += 1;
    }
    ApplicationManager.getApplication().runReadAction(() -> postAdditionalFiles(course, project, postedCourse.getId()));
    StudyTaskManager.getInstance(project).setCourse(postedCourse);
    showNotification(project, "Course published");
  }
  catch (IOException e) {
    LOG.error(e.getMessage());
  }
}
 
Example 19
Project: ApkMultiChannelPlugin   File: BuildHelper.java   Source Code and License Vote up 4 votes
private static void writeApkComment(ProgressIndicator progressIndicator, Options options,
                                    File apkFile, String outPath, String tempPath,
                                    String apkNameWithoutExtension) {
    try {
        if (ZipHelper.hasCommentSign(apkFile)) {
            String comment = ZipHelper.readZipComment(apkFile);
            NotificationHelper.error("the apk comment already exists, the comment is " + comment);
            return;
        }

        if (ApkHelper.isV2Signature(apkFile)) {
            log.info("the apk is v2 signature");
            String tempApkPath = createNotSignApk(apkFile, tempPath, apkNameWithoutExtension);

            //apkSigner is not support write zip comment
            options.signer = "jarsigner";
            CommandHelper.execSigner(options, tempApkPath);
            String zipalignApkPath = tempPath + File.separator + apkNameWithoutExtension + ".apk";
            CommandHelper.execZipalign(options, tempApkPath, zipalignApkPath);

            apkFile = new File(zipalignApkPath);
        }

        for (int i = 0, count = options.channels.size(); i < count; i++) {
            String channel = options.channels.get(i);
            progressIndicator.setText("Creating " + channel + " apk");
            progressIndicator.setText2(i + 1 + "/" + count);

            String newApkPath = outPath + File.separator + apkNameWithoutExtension + "-" + channel + ".apk";
            File newApkFile = new File(newApkPath);
            FileUtil.createIfDoesntExist(newApkFile);

            FileUtil.copy(apkFile, newApkFile);
            ZipHelper.writeComment(newApkFile, channel);
        }
    } catch (IOException | ApkFormatException | NoSuchAlgorithmException e) {
        e.printStackTrace();
        progressIndicator.setText("Build failed");
    } finally {
        ZipHelper.deleteTemp(tempPath);
    }

    progressIndicator.setFraction(1);
}
 
Example 20
Project: intellij-ce-playground   File: XPathEvalAction.java   Source Code and License Vote up 4 votes
@Override
public void generate(@NotNull final Processor<Usage> processor) {
    Runnable runnable = new Runnable() {
        @Override
        @SuppressWarnings({"unchecked"})
        public void run() {
            final List<?> list;
            if (myResult.isEmpty()) {
                try {
                    list = (List<?>)myXPath.selectNodes(myContextNode);
                } catch (JaxenException e) {
                    LOG.debug(e);
                    Messages.showMessageDialog(myContextNode.getProject(), e.getMessage(), "XPath error", Messages.getErrorIcon());
                    return;
                }
            } else {
                list = myResult;
            }

            final int size = list.size();
            final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
            indicator.setText("Collecting matches...");

            Collections.sort(list, new Comparator() {
                @Override
                public int compare(Object o1, Object o2) {
                    indicator.checkCanceled();
                    if (o1 instanceof PsiElement && o2 instanceof PsiElement) {
                        return ((PsiElement)o1).getTextRange().getStartOffset() - ((PsiElement)o2).getTextRange().getStartOffset();
                    } else {
                        return String.valueOf(o1).compareTo(String.valueOf(o2));
                    }
                }
            });
            for (int i = 0; i < size; i++) {
                indicator.checkCanceled();
                Object o = list.get(i);
                if (o instanceof PsiElement) {
                    final PsiElement element = (PsiElement)o;
                    processor.process(new UsageInfo2UsageAdapter(new UsageInfo(element)));
                    indicator.setText2(element.getContainingFile().getName());
                }
                indicator.setFraction(i / (double)size);
            }
            list.clear();
        }
    };
    ApplicationManager.getApplication().runReadAction(runnable);
}
 
Example 21
Project: intellij-ce-playground   File: SvnUtil.java   Source Code and License Vote up 4 votes
public static void doLockFiles(Project project, final SvnVcs activeVcs, @NotNull final File[] ioFiles) throws VcsException {
  final String lockMessage;
  final boolean force;
  // TODO[yole]: check for shift pressed
  if (activeVcs.getCheckoutOptions().getValue()) {
    LockDialog dialog = new LockDialog(project, true, ioFiles.length > 1);
    if (!dialog.showAndGet()) {
      return;
    }
    lockMessage = dialog.getComment();
    force = dialog.isForce();
  }
  else {
    lockMessage = "";
    force = false;
  }

  final VcsException[] exception = new VcsException[1];
  final Collection<String> failedLocks = new ArrayList<String>();
  final int[] count = new int[]{ioFiles.length};
  final ProgressTracker eventHandler = new ProgressTracker() {
    public void consume(ProgressEvent event) {
      if (event.getAction() == EventAction.LOCK_FAILED) {
        failedLocks.add(event.getErrorMessage() != null ?
                        event.getErrorMessage().getFullMessage() :
                        event.getFile().getAbsolutePath());
        count[0]--;
      }
    }

    public void checkCancelled() {
    }
  };

  Runnable command = new Runnable() {
    public void run() {
      ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();

      try {
        if (progress != null) {
          progress.setText(SvnBundle.message("progress.text.locking.files"));
        }
        for (File ioFile : ioFiles) {
          if (progress != null) {
            progress.checkCanceled();
          }
          if (progress != null) {
            progress.setText2(SvnBundle.message("progress.text2.processing.file", ioFile.getName()));
          }
          activeVcs.getFactory(ioFile).createLockClient().lock(ioFile, force, lockMessage, eventHandler);
        }
      }
      catch (VcsException e) {
        exception[0] = e;
      }
    }
  };

  ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("progress.title.lock.files"), false, project);
  if (!failedLocks.isEmpty()) {
    String[] failedFiles = ArrayUtil.toStringArray(failedLocks);
    List<VcsException> exceptions = new ArrayList<VcsException>();
    for (String file : failedFiles) {
      exceptions.add(new VcsException(SvnBundle.message("exception.text.locking.file.failed", file)));
    }
    final StringBuilder sb = new StringBuilder(SvnBundle.message("message.text.files.lock.failed", failedFiles.length == 1 ? 0 : 1));
    for (VcsException vcsException : exceptions) {
      if (sb.length() > 0) sb.append('\n');
      sb.append(vcsException.getMessage());
    }
    //AbstractVcsHelper.getInstance(project).showErrors(exceptions, SvnBundle.message("message.title.lock.failures"));
    throw new VcsException(sb.toString());
  }

  StatusBarUtil.setStatusBarInfo(project, SvnBundle.message("message.text.files.locked", count[0]));
  if (exception[0] != null) {
    throw exception[0];
  }
}
 
Example 22
Project: intellij-ce-playground   File: SvnUtil.java   Source Code and License Vote up 4 votes
public static void doUnlockFiles(Project project, final SvnVcs activeVcs, final File[] ioFiles) throws VcsException {
  final boolean force = true;
  final VcsException[] exception = new VcsException[1];
  final Collection<String> failedUnlocks = new ArrayList<String>();
  final int[] count = new int[]{ioFiles.length};
  final ProgressTracker eventHandler = new ProgressTracker() {
    public void consume(ProgressEvent event) {
      if (event.getAction() == EventAction.UNLOCK_FAILED) {
        failedUnlocks.add(event.getErrorMessage() != null ?
                          event.getErrorMessage().getFullMessage() :
                          event.getFile().getAbsolutePath());
        count[0]--;
      }
    }

    public void checkCancelled() {
    }
  };

  Runnable command = new Runnable() {
    public void run() {
      ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();

      try {
        if (progress != null) {
          progress.setText(SvnBundle.message("progress.text.unlocking.files"));
        }
        for (File ioFile : ioFiles) {
          if (progress != null) {
            progress.checkCanceled();
          }
          if (progress != null) {
            progress.setText2(SvnBundle.message("progress.text2.processing.file", ioFile.getName()));
          }
          activeVcs.getFactory(ioFile).createLockClient().unlock(ioFile, force, eventHandler);
        }
      }
      catch (VcsException e) {
        exception[0] = e;
      }
    }
  };

  ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("progress.title.unlock.files"), false, project);
  if (!failedUnlocks.isEmpty()) {
    String[] failedFiles = ArrayUtil.toStringArray(failedUnlocks);
    List<VcsException> exceptions = new ArrayList<VcsException>();

    for (String file : failedFiles) {
      exceptions.add(new VcsException(SvnBundle.message("exception.text.failed.to.unlock.file", file)));
    }
    AbstractVcsHelper.getInstance(project).showErrors(exceptions, SvnBundle.message("message.title.unlock.failures"));
  }

  StatusBarUtil.setStatusBarInfo(project, SvnBundle.message("message.text.files.unlocked", count[0]));
  if (exception[0] != null) {
    throw new VcsException(exception[0]);
  }
}
 
Example 23
Project: intellij-ce-playground   File: OutputParser.java   Source Code and License Vote up 4 votes
private void setProgressStatistics(String s) {
  final ProgressIndicator progress = myProgress.get();
  if (progress != null) {
    progress.setText2(s);
  }
}
 
Example 24
Project: intellij-ce-playground   File: FileMessage.java   Source Code and License Vote up 4 votes
public void showMessageIn(ProgressIndicator progress) {
  progress.setText2(getMyActionName() + ": " + myFileAbsolutePath);
}