mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Setting proper text on progress indicator (IDEA-34049) on bulk reformat/optimize actions
This commit is contained in:
+22
-6
@@ -18,6 +18,7 @@ package com.intellij.codeInsight.actions;
|
||||
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.lang.LanguageFormatting;
|
||||
import com.intellij.openapi.application.ApplicationBundle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
@@ -32,6 +33,7 @@ import com.intellij.openapi.progress.util.ProgressWindow;
|
||||
import com.intellij.openapi.project.IndexNotReadyException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectCoreUtil;
|
||||
import com.intellij.openapi.project.ProjectUtil;
|
||||
import com.intellij.openapi.roots.GeneratedSourcesFilter;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.ex.MessagesEx;
|
||||
@@ -498,16 +500,18 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
}
|
||||
|
||||
if (!myFilesCountingFinished) {
|
||||
updateIndicatorText(ApplicationBundle.message("bulk.reformat.prepare.progress.text"), "");
|
||||
countingIteration();
|
||||
return true;
|
||||
}
|
||||
|
||||
updateIndicator(myFilesProcessed);
|
||||
updateIndicatorFraction(myFilesProcessed);
|
||||
|
||||
if (myFileTreeIterator.hasNext()) {
|
||||
final PsiFile file = myFileTreeIterator.next();
|
||||
myFilesProcessed++;
|
||||
if (file.isWritable() && canBeFormatted(file) && acceptedByFilters(file)) {
|
||||
updateIndicatorText(ApplicationBundle.message("bulk.reformat.process.progress.text"), getPresentablePath(file));
|
||||
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -536,11 +540,23 @@ public abstract class AbstractLayoutCodeProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateIndicator(int filesProcessed) {
|
||||
if (myCompositeTask != null) {
|
||||
ProgressIndicator indicator = myCompositeTask.getIndicator();
|
||||
if (indicator != null)
|
||||
indicator.setFraction((double)filesProcessed / myTotalFiles);
|
||||
private void updateIndicatorText(@NotNull String upperLabel, @NotNull String downLabel) {
|
||||
ProgressIndicator indicator = myCompositeTask.getIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.setText(upperLabel);
|
||||
indicator.setText2(downLabel);
|
||||
}
|
||||
}
|
||||
|
||||
private String getPresentablePath(@NotNull PsiFile file) {
|
||||
VirtualFile vFile = file.getVirtualFile();
|
||||
return vFile != null ? ProjectUtil.calcRelativeToProjectPath(vFile, myProject) : file.getName();
|
||||
}
|
||||
|
||||
private void updateIndicatorFraction(int processed) {
|
||||
ProgressIndicator indicator = myCompositeTask.getIndicator();
|
||||
if (indicator != null) {
|
||||
indicator.setFraction((double)processed / myTotalFiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -682,6 +682,8 @@ wrapping.after.annotations=After last field annotation
|
||||
reformat.changed.text.file.too.big.notification.groupId=Reformat changed text
|
||||
reformat.changed.text.file.too.big.notification.title=Couldn't calculate changed ranges
|
||||
reformat.changed.text.file.too.big.notification.text=file {0} is too big or there are too many changes
|
||||
bulk.reformat.prepare.progress.text=Preparing...
|
||||
bulk.reformat.process.progress.text=Processing...
|
||||
|
||||
code.style.indents.detector.display.name=Automatic indent options detector
|
||||
code.style.indents.detector.message=Indent options for the file are overwritten by {0}
|
||||
|
||||
Reference in New Issue
Block a user