diff: fix annotations in modal windows
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Mon, 29 Jun 2015 17:17:27 +0000 (20:17 +0300)
committerAleksey Pivovarov <AMPivovarov@gmail.com>
Thu, 3 Sep 2015 16:28:08 +0000 (19:28 +0300)
ProgressManager.getInstance().run() calls callback in ModalityState.NON_MODAL

platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateDiffViewerAction.java

index be98ea124bb142d61c4cee6df5e07c8e1bf6deba..e1587fca84a555e99e8bd13d413e313c74c40a3c 100644 (file)
@@ -32,12 +32,15 @@ import com.intellij.diff.util.Side;
 import com.intellij.icons.AllIcons;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
 import com.intellij.icons.AllIcons;
 import com.intellij.openapi.actionSystem.AnActionEvent;
 import com.intellij.openapi.actionSystem.CommonDataKeys;
+import com.intellij.openapi.application.ModalityState;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.progress.Task;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.localVcs.UpToDateLineNumberProvider;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.progress.Task;
+import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
+import com.intellij.openapi.progress.impl.ProgressManagerImpl;
 import com.intellij.openapi.project.DumbAwareAction;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Key;
 import com.intellij.openapi.project.DumbAwareAction;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Key;
@@ -74,6 +77,7 @@ public class AnnotateDiffViewerAction extends DumbAwareAction {
 
   public AnnotateDiffViewerAction() {
     super("Annotate", null, AllIcons.Actions.Annotate);
 
   public AnnotateDiffViewerAction() {
     super("Annotate", null, AllIcons.Actions.Annotate);
+    setEnabledInModalContext(true);
   }
 
   @Override
   }
 
   @Override
@@ -145,8 +149,8 @@ public class AnnotateDiffViewerAction extends DumbAwareAction {
 
     // TODO: show progress in diff viewer
     // TODO: we can abort loading on DiffViewer.dispose(). But vcs can't stop gracefully anyway.
 
     // TODO: show progress in diff viewer
     // TODO: we can abort loading on DiffViewer.dispose(). But vcs can't stop gracefully anyway.
-    ProgressManager.getInstance().run(new Task.Backgroundable(project, VcsBundle.message("retrieving.annotations"), true,
-                                                              BackgroundFromStartOption.getInstance()) {
+    Task.Backgroundable task = new Task.Backgroundable(project, VcsBundle.message("retrieving.annotations"), true,
+                                                       BackgroundFromStartOption.getInstance()) {
       public void run(@NotNull ProgressIndicator indicator) {
         loader.run();
       }
       public void run(@NotNull ProgressIndicator indicator) {
         loader.run();
       }
@@ -172,7 +176,10 @@ public class AnnotateDiffViewerAction extends DumbAwareAction {
           putDataToCache(viewer, side, loader.getResult());
         }
       }
           putDataToCache(viewer, side, loader.getResult());
         }
       }
-    });
+    };
+    ProgressIndicator indicator = new BackgroundableProcessIndicator(task);
+    ProgressManagerImpl progressManager = (ProgressManagerImpl)ProgressManager.getInstance();
+    progressManager.runProcessWithProgressAsynchronously(task, indicator, null, ModalityState.current());
   }
 
   @Nullable
   }
 
   @Nullable