本文整理汇总了Java中com.intellij.openapi.progress.ProgressIndicator类的典型用法代码示例。如果您正苦于以下问题:Java ProgressIndicator类的具体用法?Java ProgressIndicator怎么用?Java ProgressIndicator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProgressIndicator类属于com.intellij.openapi.progress包,在下文中一共展示了ProgressIndicator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
public void execute(ClassEntity targetClass) {
this.targetClass = targetClass;
ProgressManager.getInstance().run(new Task.Backgroundable(project, "GsonFormat") {
@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());
}
});
}
示例2: refresh
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
/**
* Refreshes the log console in background
*/
void refresh(final String task) {
SingleTaskBackgroundExecutor.executeIfPossible(myProject, new SingleTaskBackgroundExecutor.BackgroundTask() {
@Override
public void run(ProgressIndicator progressIndicator) {
try {
UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
progressIndicator.setFraction(0);
doFilter(progressIndicator);
});
} catch (Throwable ex) {
debug("Exception " + ex.getMessage());
}
}
@Override
public String getTaskName() {
return task;
}
});
}
示例3: doFilter
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
/**
* Filters the console
*/
private synchronized void doFilter(ProgressIndicator progressIndicator) {
final ConsoleView console = getConsole();
String allLInes = getOriginalDocument().toString();
final String[] lines = allLInes.split("\n");
if (console != null) {
console.clear();
}
myLogFilterModel.processingStarted();
int size = lines.length;
float current = 0;
for (String line : lines) {
printMessageToConsole(line);
current++;
progressIndicator.setFraction(current / size);
}
if (console != null) {
((ConsoleViewImpl) console).requestScrollingToEnd();
}
}
示例4: runAnalysis
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
private void runAnalysis(@NotNull final ProgressIndicator progressIndicator) throws Exception {
String analysisOutput = getAnalysisOutput(progressIndicator);
if (!analysisOutput.startsWith("Error") && !analysisOutput.startsWith("FAILURE")) {
if (Pattern.compile("Overall: PASSED").matcher(analysisOutput).find()) {
showInfoNotification("Overall: PASSED!");
requestIdeFocus();
} else if (!Pattern.compile("Overall: FAILED").matcher(analysisOutput).find()) {
showErrorNotification("Can't detect analysis result. Try to run it manually.");
} else {
Pattern errorsCountPattern = Pattern.compile("Overall: FAILED \\((.+)\\)\u001b");
Pattern urlPattern = Pattern.compile("file:.+full_report.html");
Matcher errorsCountMatcher = errorsCountPattern.matcher(analysisOutput);
Matcher urlMatcher = urlPattern.matcher(analysisOutput);
if (errorsCountMatcher.find() && urlMatcher.find()) {
showErrorNotification(String.format("Analysis failed: %s", errorsCountMatcher.group(1)));
(new OpenUrlHyperlinkInfo(urlMatcher.group())).navigate(project);
} else {
showErrorNotification("Can't detect analysis result. Try to run it manually.");
}
}
} else {
showErrorNotification(analysisOutput);
}
}
示例5: getAnalysisOutput
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
@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();
}
示例6: scanAndUpdate
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
/**
* Scan and update dependency components.
*/
private void scanAndUpdate(boolean quickScan, ProgressIndicator indicator, @Nullable Collection<DataNode<LibraryDependencyData>> libraryDependencies) {
// Don't scan if Xray is not configured
if (!GlobalSettings.getInstance().isCredentialsSet()) {
Utils.notify(logger, "JFrog Xray scan failed", "Xray server is not configured.", NotificationType.ERROR);
return;
}
// Prevent multiple simultaneous scans
if (!scanInProgress.compareAndSet(false, true)) {
if (!quickScan) {
Utils.notify(logger, "JFrog Xray", "Scan already in progress.", NotificationType.INFORMATION);
}
return;
}
try {
// Refresh dependencies -> Collect -> Scan and store to cache -> Update view
refreshDependencies(getRefreshDependenciesCbk(quickScan, indicator), libraryDependencies);
} finally {
scanInProgress.set(false);
}
}
示例7: asyncScanAndUpdateResults
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
/**
* Launch async dependency scan.
*/
public void asyncScanAndUpdateResults(boolean quickScan, @Nullable Collection<DataNode<LibraryDependencyData>> libraryDependencies) {
Task.Backgroundable scanAndUpdateTask = new Task.Backgroundable(project, "Xray: Scanning for Vulnerabilities...") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
scanAndUpdate(quickScan, indicator, libraryDependencies);
indicator.finishNonCancelableSection();
}
};
// The progress manager is only good for foreground threads.
if (SwingUtilities.isEventDispatchThread()) {
ProgressManager.getInstance().run(scanAndUpdateTask);
} else {
// Run the scan task when the thread is in the foreground.
SwingUtilities.invokeLater(() -> ProgressManager.getInstance().run(scanAndUpdateTask));
}
}
示例8: OnResult
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
@Override
public void OnResult(String result) {
int extPos = result.lastIndexOf('/');
if (extPos < 0 && extPos != result.length() - 1) {
return;
}
String fileName = result.substring(extPos + 1);
String title = "Download:" + fileName;
File downloadFile = new File(Constant.CACHE_PATH + "search/" + fileName);
ProgressManager.getInstance().run(new Task.Backgroundable(project, title) {
@Override
public void run(@NotNull ProgressIndicator progressIndicator) {
try {
DownloadUtil.downloadAtomically(null, result, downloadFile);
} catch (IOException e) {
e.printStackTrace();
}
if (downloadFile.exists()) {
Utils.openFileInPanel(downloadFile.getPath(), project);
}
}
});
}
示例9: filterElements
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
@Override
public boolean filterElements(@NotNull ChooseByNameBase base, @NotNull String pattern, boolean everywhere, @NotNull ProgressIndicator indicator, @NotNull Processor<Object> consumer) {
Collection<SearchResultElement> elements = getAllFilterItems();
if (elements != null) {
for (SearchResultElement element : elements) {
String value = element.getValue();
if (value == null) {
return false;
}
if (value.toLowerCase().contains(pattern.toLowerCase()) && !consumer.process(element)) {
return false;
}
}
}
return false;
}
示例10: afterCheck
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
@Override
public void afterCheck(@NotNull Project project, @NotNull Task task) {
Course course = task.getLesson().getCourse();
if (!(course instanceof RemoteCourse && course.isAdaptive())) {
return;
}
if (myStatusBeforeCheck == StudyStatus.Solved) {
return;
}
StudyStatus statusAfterCheck = task.getStatus();
if (statusAfterCheck != StudyStatus.Solved) {
return;
}
ProgressManager.getInstance().run(new com.intellij.openapi.progress.Task.Backgroundable(project, EduAdaptiveStepicConnector.LOADING_NEXT_RECOMMENDATION, false,
PerformInBackgroundOption.DEAF) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
indicator.setIndeterminate(true);
EduAdaptiveStepicConnector.addNextRecommendedTask(project, task.getLesson(), indicator, EduAdaptiveStepicConnector.NEXT_RECOMMENDATION_REACTION);
}
});
}
示例11: mouseClicked
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 1 && isEnabled()) {
final com.jetbrains.edu.learning.courseFormat.tasks.Task task = StudyUtils.getCurrentTask(myProject);
if (task != null && task.getStatus() != StudyStatus.Solved) {
final ProgressIndicatorBase progress = new ProgressIndicatorBase();
progress.setText(EduAdaptiveStepicConnector.LOADING_NEXT_RECOMMENDATION);
ProgressManager.getInstance().run(new Task.Backgroundable(myProject,
EduAdaptiveStepicConnector.LOADING_NEXT_RECOMMENDATION) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
StepicAdaptiveReactionsPanel.this.setEnabledRecursive(false);
ApplicationManager.getApplication().invokeLater(()->setBackground(UIUtil.getLabelBackground()));
EduAdaptiveStepicConnector.addNextRecommendedTask(StepicAdaptiveReactionsPanel.this.myProject, task.getLesson(), indicator,
myReaction);
StepicAdaptiveReactionsPanel.this.setEnabledRecursive(true);
}
});
}
}
}
示例12: isUpToDate
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
public boolean isUpToDate() {
if (id == 0) return true;
if (!EduNames.STUDY.equals(courseMode)) return true;
ProgressManager.getInstance().runProcessWithProgressAsynchronously(new Backgroundable(null, "Updating Course") {
@Override
public void run(@NotNull ProgressIndicator indicator) {
final Date date = EduStepicConnector.getCourseUpdateDate(id);
if (date == null) return;
if (date.after(myUpdateDate)) {
isUpToDate = false;
}
for (Lesson lesson : lessons) {
if (!lesson.isUpToDate()) {
isUpToDate = false;
}
}
}
}, new EmptyProgressIndicator());
return isUpToDate;
}
示例13: actionPerformed
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
final Project project = e.getData(CommonDataKeys.PROJECT);
if (view == null || project == null) {
return;
}
final String courseId = Messages.showInputDialog("Please, enter course id", "Get Course From Stepik", null);
if (StringUtil.isNotEmpty(courseId)) {
ProgressManager.getInstance().run(new Task.Modal(project, "Creating Course", true) {
@Override
public void run(@NotNull final ProgressIndicator indicator) {
createCourse(project, courseId);
}
});
}
}
示例14: dropResolveCacheRegularly
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
private static void dropResolveCacheRegularly(ProgressIndicator indicator, final Project project) {
if (indicator instanceof ProgressIndicatorEx) {
((ProgressIndicatorEx)indicator).addStateDelegate(new ProgressIndicatorBase() {
volatile long lastCleared = System.currentTimeMillis();
public void setFraction(double fraction) {
super.setFraction(fraction);
long current = System.currentTimeMillis();
if (current - this.lastCleared >= 500L) {
this.lastCleared = current;
PsiManager.getInstance(project).dropResolveCaches();
}
}
});
}
}
示例15: processNamesByPattern
import com.intellij.openapi.progress.ProgressIndicator; //导入依赖的package包/类
private static void processNamesByPattern(@NotNull final ChooseByNameBase base,
@NotNull final String[] names,
@NotNull final String pattern,
final ProgressIndicator indicator,
@NotNull final Consumer<MatchResult> consumer) {
final MinusculeMatcher matcher = buildPatternMatcher(pattern, NameUtil.MatchingCaseSensitivity.NONE);
Processor<String> processor = new Processor<String>() {
@Override
public boolean process(String name) {
ProgressManager.checkCanceled();
MatchResult result = matches(base, pattern, matcher, name);
if (result != null) {
consumer.consume(result);
}
return true;
}
};
if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(Arrays.asList(names), indicator, false, true, processor)) {
throw new ProcessCanceledException();
}
}