public void run(@NotNull final ProgressIndicator progressIndicator) { progressIndicator.setText(message("handler.before.checkin.scan.in-progress")); progressIndicator.setIndeterminate(true); scanResults.putAll(plugin.scanFiles(new ArrayList<>(checkinPanel.getVirtualFiles()))); } }.queue();
indicator.setText(sb.toString());
private void initListeners() { testConnectionButton.addActionListener(actionEvent -> { ServerConfiguration configuration = createServerConfigurationForTesting(); final Ref<Exception> excRef = new Ref<>(); final ProgressManager progressManager = ProgressManager.getInstance(); progressManager.runProcessWithProgressSynchronously(() -> { final ProgressIndicator progressIndicator = progressManager.getProgressIndicator(); if (progressIndicator != null) { progressIndicator.setText("Connecting to Mongo server..."); } try { mongoManager.connect(configuration); } catch (Exception ex) { excRef.set(ex); } }, "Testing Connection", true, ServerConfigurationPanel.this.project); if (!excRef.isNull()) { Messages.showErrorDialog(rootPanel, excRef.get().getMessage(), "Connection Test Failed"); } else { Messages.showInfoMessage(rootPanel, "Connection test successful", "Connection Test Successful"); } }); }
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; }
/** * Handles a message regarding the current action */ @Override public void setMessage(String msg) { indicator.setText(msg); }
public static void setText(@Nullable ProgressIndicator progressIndicator,String message) { if (progressIndicator != null) { ProgressWrapper.unwrap(progressIndicator).setText(message); } }
private static void updateProgress(ProgressIndicator indicator, String message, double fraction) { indicator.setText(message); indicator.setFraction(fraction); } }
@Override public Boolean compute() throws Exception { ProgressManager.getInstance().getProgressIndicator().setText("Trying to login to Gerrit"); return testConnection(gerritAuthData); } });
/** * Sets {@code newText} to the progress indicator if available. * * @return old indicator text */ @Nullable public static String setProgressText(@Nullable String newText) { ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { String oldText = indicator.getText(); indicator.setText(newText); return oldText; } return null; }
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setText("Connecting to " + server.getHostUrl() + "..."); indicator.setIndeterminate(false); try { ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server); indicator.setText("Searching organization"); WsHelper wsHelper = new WsHelperImpl(); organization = wsHelper.getOrganization(serverConfiguration, organizationKey, new TaskProgressMonitor(indicator)); } catch (Exception e) { LOGGER.info("Failed to fetch information", e); exception = e; } }
private List<AnalysisResults> analyze(Project project, ProgressIndicator indicator, AccumulatorIssueListener listener) { SonarLintAnalyzer analyzer = SonarLintUtils.get(project, SonarLintAnalyzer.class); indicator.setIndeterminate(true); int numModules = job.filesPerModule().keySet().size(); String suffix = ""; if (numModules > 1) { suffix = String.format(" in %d modules", numModules); } int numFiles = job.allFiles().size(); if (numFiles > 1) { indicator.setText("Running SonarLint Analysis for " + numFiles + " files" + suffix); } else { indicator.setText("Running SonarLint Analysis for '" + getFileName(job.allFiles().iterator().next()) + "'"); } LOGGER.info(indicator.getText()); ProgressMonitor progressMonitor = new TaskProgressMonitor(indicator); List<AnalysisResults> results = new LinkedList<>(); for (Map.Entry<Module, Collection<VirtualFile>> e : job.filesPerModule().entrySet()) { results.add(analyzer.analyzeModule(e.getKey(), e.getValue(), listener, progressMonitor)); checkCanceled(indicator, myProject); } indicator.startNonCancelableSection(); return results; } }
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setText("Connecting to " + server.getHostUrl() + "..."); indicator.setIndeterminate(false); try { ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server); indicator.setText("Checking support of notifications"); notificationsSupported = SonarQubeNotifications.get().isSupported(serverConfiguration); WsHelper wsHelper = new WsHelperImpl(); organizations = wsHelper.listUserOrganizations(serverConfiguration, new TaskProgressMonitor(indicator)); } catch (UnsupportedServerException e) { organizations = Collections.emptyList(); } catch (Exception e) { LOGGER.info("Failed to fetch information", e); exception = e; } }
@Override public List<ProjectInfo> compute() throws Exception { ProgressManager.getInstance().getProgressIndicator().setText("Extracting info about available repositories"); return gerritClient.projects().list().get(); } });
@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); }
@Override public void run(@NotNull ProgressIndicator indicator) { indicator.setText("Submitting BashSupport error report..."); indicator.setIndeterminate(true); LoggingEventSubmitter submitter = new TextStreamLoggingEventSubmitter(serverUrl); submitter.setPluginId(properties.getProperty(PLUGIN_ID_PROPERTY_KEY)); submitter.setPluginName(properties.getProperty(PLUGIN_NAME_PROPERTY_KEY)); submitter.setPluginVersion(properties.getProperty(PLUGIN_VERSION_PROPERTY_KEY)); submitter.setIdeaBuild(ApplicationInfo.getInstance().getBuild().asString()); submitter.setEmailTo(splitByBlanks(properties.getProperty(EMAIL_TO_PROPERTY_KEY))); submitter.setEmailCc(splitByBlanks(properties.getProperty(EMAIL_CC_PROPERTY_KEY))); try { submitter.submit(stacktrace, description, user); successConsumer.consume(new SubmittedReportInfo(SubmittedReportInfo.SubmissionStatus.NEW_ISSUE)); } catch (LoggingEventSubmitter.SubmitException e) { //ignore } } };
@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(@NotNull ProgressIndicator indicator) { indicator.setText("Connecting to " + server.getHostUrl() + "..."); indicator.setIndeterminate(true); try { ServerConfiguration serverConfiguration = SonarLintUtils.getServerConfiguration(server); WsHelper wsHelper = new WsHelperImpl(); result = wsHelper.validateConnection(serverConfiguration); } catch (Exception e) { String msg = "Connection test failed"; LOGGER.info(msg, e); GlobalLogOutput.get().logError(msg, e); exception = e; } }
@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); } }
@Override public void run(@NotNull ProgressIndicator indicator) { if(title.startsWith("WIP:")) { projectState.setMergeAsWorkInProgress(true); } else { projectState.setMergeAsWorkInProgress(false); } projectState.setDeleteMergedBranch(removeSourceBranch); indicator.setText("Pushing current branch..."); GitCommandResult result = git.push(gitRepository, branch.getRemoteName(), remoteUrl, gitLocalBranch.getName(), true); if (!result.success()) { showErrorDialog(project, "Push failed:<br/>" + result.getErrorOutputAsHtmlString(), CANNOT_CREATE_MERGE_REQUEST); return; } indicator.setText("Creating merge request..."); GitlabMergeRequest mergeRequest; try { mergeRequest = settingsState.api(gitRepository).createMergeRequest(gitlabProject, assignee, gitLocalBranch.getName(), branch.getName(), title, description, removeSourceBranch); } catch (IOException e) { showErrorDialog(project, "Cannot create Merge Request via GitLab REST API", CANNOT_CREATE_MERGE_REQUEST); return; } VcsNotifier.getInstance(project) .notifyImportantInfo(title, "<a href='" + generateMergeRequestUrl(settingsState.currentGitlabServer(gitRepository), mergeRequest) + "'>Merge request '" + title + "' created</a>", NotificationListener.URL_OPENING_LISTENER); } }.queue();
@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(); } }