@Override public void run(@NotNull ProgressIndicator progressIndicator) { progressIndicator.setIndeterminate(true); long currentTimeMillis = System.currentTimeMillis(); execute(); progressIndicator.setIndeterminate(false); progressIndicator.setFraction(1.0); StringBuffer sb = new StringBuffer(); sb.append("GsonFormat [" + (System.currentTimeMillis() - currentTimeMillis) + " ms]\n"); // sb.append("generate class : ( "+generateClassList.size()+" )\n"); // for (String item: generateClassList) { // sb.append(" at "+item+"\n"); // } // sb.append(" \n"); // NotificationCenter.info(sb.toString()); Toast.make(project, MessageType.INFO, sb.toString()); } });
@Override public void run(@NotNull ProgressIndicator progressIndicator) { final ClassEntity entity = new ClassEntity(packageName, version); DownloadManager.getInstance().downloadFile(new ClassEntity[]{entity}, new File(Constant.CACHE_PATH + entity.getParentPath()), new DownloadResult<File>() { @Override public void onSuccess(List<File> output) { Log.debug("success: length=" + output.size()); if (output.isEmpty()) { NotificationUtils.errorNotification("Error: Download " + entity.getPackageName() + " Failure"); return; } Utils.openFileInPanel(output.get(0).getPath(), SourceViewerAction.this.project); } @Override public void onFailure(String msg, Throwable throwable) { NotificationUtils.errorNotification("Error:" + msg); } }); progressIndicator.setFraction(0.5); } });
private void refactor() throws IOException, ProcessCanceledException { progressIndicator.checkCanceled(); progressIndicator.setIndeterminate(false); for (int i = 0; i < imageInformationList.size(); i++) { ImageInformation information = imageInformationList.get(i); progressIndicator.setText2(information.getExportName()); progressIndicator.checkCanceled(); if (information.isVector()) { copyTempImage(information); } else { exportTempImage(information); } progressIndicator.setFraction((float) (i + 1) / (float) imageInformationList.size()); } progressIndicator.setIndeterminate(true); progressIndicator.setText2("Finishing"); UIUtil.invokeLaterIfNeeded(new DumbAwareRunnable() { public void run() { try { move(project, imageInformationList); LocalFileSystem.getInstance().refresh(true); } catch (IOException e) { LOGGER.error(e); } } }); }
/** * Handles the approximate fraction of the task completed. * * @param fraction Number between 0.0f and 1.0f */ @Override public void setFraction(float fraction) { indicator.setFraction(fraction); }
public static void setFraction(@Nullable ProgressIndicator progressIndicator,double fraction) { if (progressIndicator != null) { ProgressWrapper.unwrap(progressIndicator).setFraction(fraction); } }
private static void updateProgress(ProgressIndicator indicator, String message, double fraction) { indicator.setText(message); indicator.setFraction(fraction); } }
} else { progress.setIndeterminate(false); progress.setFraction( pos / (((double) estimatedRemainingItems) + pos) );
public List<Resource> getAllProjectsAndModules() { List<Resource> allResources = new LinkedList<>(); final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); indicator.setText("Downloading SonarQube projects"); List<Component> projects = getAllProjects(sonarClient); projects = projects.stream().sorted(comparing(Component::getName)).collect(toList()); indicator.setText("Downloading SonarQube modules"); int i = 0; for (Component project : projects) { if (indicator.isCanceled()) break; i++; indicator.setFraction(1.0 * i / projects.size()); indicator.setText2(project.getName()); allResources.add(new Resource(project.getKey(), project.getName(), project.getQualifier())); List<Component> modules = getAllModules(sonarClient, project.getId()); modules = modules.stream().sorted(comparing(Component::getName)).collect(toList()); for (Component module : modules) { allResources.add(new Resource(module.getKey(), module.getName(), module.getQualifier())); } } return allResources; }
throws ProcessCanceledException { ProgressIndicator progressIndicator = DummyProgressIndicator.nullSafe(pi); progressIndicator.setFraction(0.0); final SyncUpdateSession ret = new SyncUpdateSession(); ProjectConfigRegistry registry = ProjectConfigRegistry.getInstance(project); updateForResult(res, groups); pos[0] += inc; progressIndicator.setFraction(pos[0]); } catch (P4CommandRunner.ServerResultException e) { ret.exceptions.add(e);
@Test public void createServiceAccountAndDownloadKey_withNoRoles_createsKey() { Set<Role> roles = ImmutableSet.of(); CloudApiManager.createServiceAccountAndDownloadKey( roles, SERVICE_ACCOUNT_NAME, downloadDir.toPath(), cloudProject, testFixture.getProject()); verify(progressIndicator, times(3)).setText(anyString()); verify(progressIndicator, times(3)).setFraction(anyDouble()); String[] contents = downloadDir.list(); assertThat(contents.length).isEqualTo(1); assertThat(contents[0]).startsWith(CLOUD_PROJECT_NAME); }
@Test public void createServiceAccountAndDownloadKey_withRoles_createsKey() { Role role = new Role(); role.setName("my-role"); Set<Role> roles = ImmutableSet.of(role); CloudApiManager.createServiceAccountAndDownloadKey( roles, SERVICE_ACCOUNT_NAME, downloadDir.toPath(), cloudProject, testFixture.getProject()); verify(progressIndicator, times(4)).setText(anyString()); verify(progressIndicator, times(4)).setFraction(anyDouble()); String[] contents = downloadDir.list(); assertThat(contents.length).isEqualTo(1); assertThat(contents[0]).startsWith(CLOUD_PROJECT_NAME); }
@Override public void run(ProgressIndicator indicator) { AccumulatorIssueListener listener = new AccumulatorIssueListener(); try { checkCanceled(indicator, myProject); List<AnalysisResults> results = analyze(myProject, indicator, listener); //last chance to cancel (to avoid the possibility of having interrupt flag set) checkCanceled(indicator, myProject); LOGGER.info("SonarLint analysis done"); indicator.setIndeterminate(false); indicator.setFraction(.9); List<Issue> issues = listener.getIssues(); indicator.setText("Creating SonarLint issues: " + issues.size()); List<ClientInputFile> allFailedAnalysisFiles = results.stream() .flatMap(r -> r.failedAnalysisFiles().stream()) .collect(Collectors.toList()); processor.process(job, indicator, issues, allFailedAnalysisFiles); } catch (CanceledException e1) { console.info("Analysis canceled"); } catch (Throwable e) { handleError(e, indicator); } finally { myProject.getMessageBus().syncPublisher(TaskListener.SONARLINT_TASK_TOPIC).ended(job); } }
progress.setFraction(lastFraction); if (cachedMaps.first == null || cachedMaps.second == null) { progress.setFraction(1.0); return; progress.setFraction(lastFraction); InternalErrorMessage.send(project).cacheLockTimeoutError(new ErrorEvent<>( new VcsInterruptedException("Update Changelists interrupted", e))); progress.setFraction(1.0); return; progress.setFraction(lastFraction); if (dirtyFiles == null || dirtyFiles.isEmpty()) { LOG.info("No dirty files."); progress.setFraction(1.0); return; progress.setFraction(lastFraction); progress.setFraction(1.0); } finally { active = false;
private void runInner(ProgressIndicator indicator) { for (int i = 0, l = bnfFiles.size(); i < l; i++) { VirtualFile file = bnfFiles.get(i); indicator.setFraction((double)i / l); indicator.setText2(file.getPath()); String sourcePath = FileUtil.toSystemDependentName(PathUtil.getCanonicalPath(file.getParent().getPath()));
indicator.setFraction(filesCounter / allXSFiles.size());
@Test public void should_wrap() { monitor.finishNonCancelableSection(); verify(wrapped).finishNonCancelableSection(); monitor.isCanceled(); verify(wrapped).isCanceled(); monitor.setFraction(0.5f); verify(wrapped).setFraction(0.5f); monitor.setIndeterminate(true); verify(wrapped).setIndeterminate(true); monitor.setMessage("message"); verify(wrapped).setText("message"); monitor.startNonCancelableSection(); verify(wrapped).startNonCancelableSection(); } }