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

The following are Jave code examples for showing how to use setText() 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: intellij-ce-playground   File: ShareProjectAction.java   Source Code and License Vote up 6 votes
private static void addRecursively(@NotNull final SvnVcs activeVcs, @NotNull final ClientFactory factory, final VirtualFile file)
  throws VcsException {
  final SvnExcludingIgnoredOperation operation = new SvnExcludingIgnoredOperation(activeVcs.getProject(), new SvnExcludingIgnoredOperation.Operation() {
    public void doOperation(final VirtualFile virtualFile) throws VcsException {
      final File ioFile = new File(virtualFile.getPath());
      final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
      if (indicator != null) {
        indicator.checkCanceled();
        indicator.setText(SvnBundle.message("share.or.import.add.progress.text", virtualFile.getPath()));
      }
      factory.createAddClient().add(ioFile, Depth.EMPTY, false, false, true, null);
    }
  }, Depth.INFINITY);

  operation.execute(file);
}
 
Example 2
Project: intellij-ce-playground   File: InstallComponentsPath.java   Source Code and License Vote up 6 votes
@NotNull
@Override
protected File perform(@NotNull ProgressIndicator indicator, @NotNull File destination) throws WizardException {
  indicator.setText("Installing Android SDK");
  try {
    FileUtil.ensureExists(destination);
    if (!FileUtil.filesEqual(destination.getCanonicalFile(), myRepo.getCanonicalFile())) {
      SdkMerger.mergeSdks(myRepo, destination, indicator);
      myRepoWasMerged = true;
    }
    myContext.print(String.format("Android SDK was installed to %1$s\n", destination), ConsoleViewContentType.SYSTEM_OUTPUT);
    return destination;
  }
  catch (IOException e) {
    throw new WizardException(e.getMessage(), e);
  }
  finally {
    indicator.stop();
  }
}
 
Example 3
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 4
Project: intellij-ce-playground   File: AbstractExternalSystemTask.java   Source Code and License Vote up 6 votes
@Override
public boolean cancel(@NotNull final ProgressIndicator indicator, @NotNull ExternalSystemTaskNotificationListener... listeners) {
  indicator.setIndeterminate(true);
  ExternalSystemTaskNotificationListenerAdapter adapter = new ExternalSystemTaskNotificationListenerAdapter() {
    @Override
    public void onStatusChange(@NotNull ExternalSystemTaskNotificationEvent event) {
      indicator.setText(wrapProgressText(event.getDescription()));
    }
  };
  final ExternalSystemTaskNotificationListener[] ls;
  if (listeners.length > 0) {
    ls = ArrayUtil.append(listeners, adapter);
  }
  else {
    ls = new ExternalSystemTaskNotificationListener[]{adapter};
  }

  return cancel(ls);
}
 
Example 5
Project: intellij-ce-playground   File: RepositoryBrowserDialog.java   Source Code and License Vote up 6 votes
private boolean doDelete(final SVNURL url, final String comment) {
  final Ref<Exception> exception = new Ref<Exception>();
  final Project project = myBrowserComponent.getProject();
  Runnable command = new Runnable() {
    public void run() {
      ProgressIndicator progress = ProgressManager.getInstance().getProgressIndicator();
      if (progress != null) {
        progress.setText(SvnBundle.message("progres.text.deleting", url.toString()));
      }
      SvnVcs vcs = SvnVcs.getInstance(project);
      try {
        vcs.getFactoryFromSettings().createDeleteClient().delete(url, comment);
      }
      catch (VcsException e) {
        exception.set(e);
      }
    }
  };
  ProgressManager.getInstance().runProcessWithProgressSynchronously(command, SvnBundle.message("progress.title.browser.delete"), false, project);
  if (!exception.isNull()) {
    Messages.showErrorDialog(exception.get().getMessage(), SvnBundle.message("message.text.error"));
  }
  return exception.isNull();
}
 
Example 6
Project: intellij-ce-playground   File: RollbackDeletionAction.java   Source Code and License Vote up 6 votes
protected List<VcsException> processFiles(final AbstractVcs vcs, final List<FilePath> files) {
  RollbackEnvironment environment = vcs.getRollbackEnvironment();
  if (environment == null) return Collections.emptyList();
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null) {
    indicator.setText(vcs.getDisplayName() + ": performing rollback...");
  }
  final List<VcsException> result = new ArrayList<VcsException>(0);
  try {
    environment.rollbackMissingFileDeletion(files, result, new RollbackProgressModifier(files.size(), indicator));
  }
  catch (ProcessCanceledException e) {
    // for files refresh
  }
  LocalFileSystem.getInstance().refreshIoFiles(ChangesUtil.filePathsToFiles(files));
  return result;
}
 
Example 7
Project: epigraph   File: SchemaTypeParentsSearcher.java   Source Code and License Vote up 6 votes
@Override
public void processQuery(@NotNull SchemaTypeParentsSearch.SearchParameters parameters, @NotNull Processor<SchemaTypeDef> consumer) {
  SchemaTypeDef baseType = parameters.schemaTypeDef;

  ProgressIndicator progress = ProgressIndicatorProvider.getGlobalProgressIndicator();
  if (progress != null) {
    progress.pushState();

    String typeName = ApplicationManager.getApplication().runReadAction((Computable<String>) baseType::getName);
    progress.setText(typeName == null ?
        "Searching for parents" : "Searching for parents of " + typeName
    );
  }

  try {
    processParents(consumer, baseType, parameters);
  } finally {
    if (progress != null) progress.popState();
  }
}
 
Example 8
Project: intellij-ce-playground   File: CommitHelper.java   Source Code and License Vote up 6 votes
public void customRefresh() {
  final List<Change> toRefresh = new ArrayList<Change>();
  ChangesUtil.processChangesByVcs(myProject, myIncludedChanges, new ChangesUtil.PerVcsProcessor<Change>() {
    @Override
    public void process(AbstractVcs vcs, List<Change> items) {
      CheckinEnvironment ce = vcs.getCheckinEnvironment();
      if (ce != null && ce.isRefreshAfterCommitNeeded()) {
        toRefresh.addAll(items);
      }
    }
  });

  if (toRefresh.isEmpty()) {
    return;
  }
  
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null) {
    indicator.setText(VcsBundle.message("commit.dialog.refresh.files"));
  }
  RefreshVFsSynchronously.updateChanges(toRefresh);
}
 
Example 9
Project: lua-for-idea   File: UrlConnectionUtil.java   Source Code and License Vote up 5 votes
public static InputStream getConnectionInputStreamWithException(@NotNull URLConnection connection, @NotNull ProgressIndicator pi)
        throws IOException {
    InputStreamGetter getter = new InputStreamGetter(connection);
    final Future<?> getterFuture = ApplicationManager.getApplication().executeOnPooledThread(getter);
    while (true) {
        pi.checkCanceled();
        try {
            try {
                getterFuture.get(50, TimeUnit.MILLISECONDS);
            }
            catch (TimeoutException ignored) {
            }

            pi.setIndeterminate(true);
            pi.setText(pi.getText());
            if (getterFuture.isDone()) {
                break;
            }
        }
        catch (Exception e) {
            throw new ProcessCanceledException(e);
        }
    }
    //noinspection ThrowableResultOfMethodCallIgnored
    if (getter.getException() != null) {
        throw getter.getException();
    }

    return getter.getInputStream();
}
 
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: SvnIntegrateEnvironment.java   Source Code and License Vote up 5 votes
protected void showProgressMessage(final ProgressIndicator progress, final File root) {
  if (SvnConfiguration.getInstance(myVcs.getProject()).isMergeDryRun()) {
    progress.setText(SvnBundle.message("progress.text.merging.dry.run.changes", root.getAbsolutePath()));
  }
  else {
    progress.setText(SvnBundle.message("progress.text.merging.changes", root.getAbsolutePath()));
  }
}
 
Example 12
Project: intellij-ce-playground   File: ZipUtil.java   Source Code and License Vote up 5 votes
private static File getUnzipToDir(@Nullable ProgressIndicator progress,
                                  @NotNull File targetDir,
                                  boolean unwrapSingleTopLevelFolder) throws IOException {
  if (progress != null) {
    progress.setText("Extracting...");
  }
  if (unwrapSingleTopLevelFolder) {
    return FileUtil.createTempDirectory("unzip-dir-", null);
  }
  return targetDir;
}
 
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: ShowImageDuplicatesAction.java   Source Code and License Vote up 5 votes
private static void collectAndShowDuplicates(final Project project) {
  final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null && !indicator.isCanceled()) {
    indicator.setText("Collecting project images...");
    indicator.setIndeterminate(false);
    final List<VirtualFile> images = new ArrayList<VirtualFile>();
    for (String ext : IMAGE_EXTENSIONS) {
      images.addAll(FilenameIndex.getAllFilesByExt(project, ext));
    }

    final Map<Long, Set<VirtualFile>> duplicates = new HashMap<Long, Set<VirtualFile>>();
    final Map<Long, VirtualFile> all = new HashMap<Long, VirtualFile>();
    for (int i = 0; i < images.size(); i++) {
      indicator.setFraction((double)(i + 1) / (double)images.size());
      final VirtualFile file = images.get(i);
      if (!(file.getFileSystem() instanceof LocalFileSystem)) continue;
      final long length = file.getLength();
      if (all.containsKey(length)) {
        if (!duplicates.containsKey(length)) {
          final HashSet<VirtualFile> files = new HashSet<VirtualFile>();
          files.add(all.get(length));
          duplicates.put(length, files);
        }
        duplicates.get(length).add(file);
      } else {
        all.put(length, file);
      }
      indicator.checkCanceled();
    }
    showResults(project, images, duplicates, all);
  }
}
 
Example 15
Project: intellij-ce-playground   File: FindDependencyUtil.java   Source Code and License Vote up 5 votes
private static int updateIndicator(final ProgressIndicator indicator, final int totalCount, int count, final PsiFile psiFile) {
  if (indicator != null) {
    if (indicator.isCanceled()) throw new ProcessCanceledException();
    indicator.setFraction(((double)++count) / totalCount);
    final VirtualFile virtualFile = psiFile.getVirtualFile();
    if (virtualFile != null) {
      indicator.setText(AnalysisScopeBundle.message("find.dependencies.progress.text", virtualFile.getPresentableUrl()));
    }
  }
  return count;
}
 
Example 16
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 17
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 18
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 19
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 20
Project: intellij-ce-playground   File: FormattingProgressTask.java   Source Code and License Vote up 4 votes
private void updateTextIfNecessary(@NotNull FormattingStateId currentState) {
  ProgressIndicator indicator = getIndicator();
  if (myLastState != currentState && indicator != null) {
    indicator.setText(currentState.getDescription());
  }
}
 
Example 21
Project: intellij-ce-playground   File: OutputParser.java   Source Code and License Vote up 4 votes
private void setProgressText(String s) {
  final ProgressIndicator progress = myProgress.get();
  if (progress != null) {
    progress.setText(s);
  }
}
 
Example 22
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];
  }
}