Merge branch 'master' into no-reformat-dialog-on-reformat-code-action
[idea/community.git] / platform / lang-impl / src / com / intellij / codeInsight / actions / AbstractLayoutCodeProcessor.java
index 359e7e1273a2c1debec866cabbbd1e34cee04cc4..5613b489e71ca940d7571969ff730e5fe9426acd 100644 (file)
@@ -21,6 +21,7 @@ import com.intellij.lang.LanguageFormatting;
 import com.intellij.notification.Notification;
 import com.intellij.notification.NotificationType;
 import com.intellij.openapi.application.ApplicationBundle;
+import com.intellij.openapi.application.ApplicationBundle;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.command.CommandProcessor;
@@ -36,6 +37,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;
@@ -522,16 +524,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() {
@@ -560,11 +564,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);
       }
     }