Remove GitShowAllSubmittedFilesAction, use ShowAllAffectedGenericAction
authorKirill Likhodedov <Kirill.Likhodedov@jetbrains.com>
Sun, 12 Aug 2012 10:49:40 +0000 (14:49 +0400)
committerKirill Likhodedov <Kirill.Likhodedov@jetbrains.com>
Sun, 12 Aug 2012 10:49:40 +0000 (14:49 +0400)
Move showSubmittedFiles() to GitUtil, because it has some custom parameters used by callers.

plugins/git4idea/src/git4idea/GitUtil.java
plugins/git4idea/src/git4idea/actions/GitShowAllSubmittedFilesAction.java [deleted file]
plugins/git4idea/src/git4idea/history/GitHistoryProvider.java
plugins/git4idea/src/git4idea/rebase/GitRebaseEditor.java
plugins/git4idea/src/git4idea/ui/GitReferenceValidator.java
plugins/git4idea/src/git4idea/ui/GitUnstashDialog.java
plugins/git4idea/src/git4idea/update/GitSkippedCommits.java

index bf17f84d4c274d08837ce26ba91594d01b9aa92b..5628715c036273c8eda17ddc782b3d4e4a1bcb9f 100644 (file)
@@ -17,21 +17,26 @@ package git4idea;
 
 import com.intellij.openapi.components.ServiceManager;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.progress.ProgressIndicator;
+import com.intellij.openapi.progress.Task;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.openapi.vcs.AbstractVcsHelper;
 import com.intellij.openapi.vcs.FilePath;
 import com.intellij.openapi.vcs.ProjectLevelVcsManager;
 import com.intellij.openapi.vcs.VcsException;
 import com.intellij.openapi.vcs.changes.Change;
 import com.intellij.openapi.vcs.changes.ChangeListManager;
 import com.intellij.openapi.vcs.changes.FilePathsHelper;
+import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
 import com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile;
 import com.intellij.openapi.vfs.LocalFileSystem;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.util.Consumer;
 import com.intellij.util.Function;
+import com.intellij.util.ui.UIUtil;
 import com.intellij.vcsUtil.VcsFileUtil;
 import com.intellij.vcsUtil.VcsUtil;
 import git4idea.changes.GitChangeUtils;
@@ -44,6 +49,7 @@ import git4idea.i18n.GitBundle;
 import git4idea.repo.GitRemote;
 import git4idea.repo.GitRepository;
 import git4idea.repo.GitRepositoryManager;
+import git4idea.util.GitUIUtil;
 import git4idea.util.StringScanner;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -865,4 +871,43 @@ public class GitUtil {
       return "File";
     }
   }
+
+  /**
+   * Show changes made in the specified revision.
+   *
+   * @param project     the project
+   * @param revision    the revision number
+   * @param file        the file affected by the revision
+   * @param local       pass true to let the diff be editable, i.e. making the revision "at the right" be a local (current) revision.
+   *                    pass false to let both sides of the diff be non-editable.
+   * @param revertable  pass true to let "Revert" action be active.
+   */
+  public static void showSubmittedFiles(final Project project, final String revision, final VirtualFile file,
+                                        final boolean local, final boolean revertable) {
+    new Task.Backgroundable(project, GitBundle.message("changes.retrieving", revision)) {
+      public void run(@NotNull ProgressIndicator indicator) {
+        indicator.setIndeterminate(true);
+        try {
+          VirtualFile vcsRoot = getGitRoot(file);
+          final CommittedChangeList changeList = GitChangeUtils.getRevisionChanges(project, vcsRoot, revision, true, local, revertable);
+          if (changeList != null) {
+            UIUtil.invokeLaterIfNeeded(new Runnable() {
+              public void run() {
+                AbstractVcsHelper.getInstance(project).showChangesListBrowser(changeList,
+                                                                              GitBundle.message("paths.affected.title", revision));
+              }
+            });
+          }
+        }
+        catch (final VcsException e) {
+          UIUtil.invokeLaterIfNeeded(new Runnable() {
+            public void run() {
+              GitUIUtil.showOperationError(project, e, "git show");
+            }
+          });
+        }
+      }
+    }.queue();
+  }
+
 }
diff --git a/plugins/git4idea/src/git4idea/actions/GitShowAllSubmittedFilesAction.java b/plugins/git4idea/src/git4idea/actions/GitShowAllSubmittedFilesAction.java
deleted file mode 100644 (file)
index 31b0d0b..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright 2000-2009 JetBrains s.r.o.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package git4idea.actions;
-
-import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.AnActionEvent;
-import com.intellij.openapi.actionSystem.PlatformDataKeys;
-import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.progress.Task;
-import com.intellij.openapi.project.DumbAware;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.IconLoader;
-import com.intellij.openapi.vcs.AbstractVcsHelper;
-import com.intellij.openapi.vcs.VcsDataKeys;
-import com.intellij.openapi.vcs.VcsException;
-import com.intellij.openapi.vcs.history.VcsFileRevision;
-import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
-import com.intellij.openapi.vfs.VirtualFile;
-import com.intellij.util.ui.UIUtil;
-import git4idea.GitFileRevision;
-import git4idea.GitUtil;
-import git4idea.changes.GitChangeUtils;
-import git4idea.i18n.GitBundle;
-import git4idea.util.GitUIUtil;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Initial code for show submitted files action, this action is accessed from history view
- */
-public class GitShowAllSubmittedFilesAction extends AnAction implements DumbAware {
-
-  /**
-   * A constructor
-   */
-  public GitShowAllSubmittedFilesAction() {
-    super(GitBundle.message("show.all.paths.affected.action.name"), null, IconLoader.getIcon("/icons/allRevisions.png"));
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public void update(AnActionEvent e) {
-    super.update(e);
-    final Project project = e.getData(PlatformDataKeys.PROJECT);
-    if (project == null) {
-      e.getPresentation().setEnabled(false);
-      return;
-    }
-    final VirtualFile revisionVirtualFile = e.getData(VcsDataKeys.VCS_VIRTUAL_FILE);
-    e.getPresentation().setEnabled((e.getData(VcsDataKeys.VCS_FILE_REVISION) != null) && (revisionVirtualFile != null));
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  public void actionPerformed(AnActionEvent e) {
-    final Project project = e.getData(PlatformDataKeys.PROJECT);
-    if (project == null) return;
-    final VcsFileRevision revision = e.getData(VcsDataKeys.VCS_FILE_REVISION);
-    final VirtualFile revisionVirtualFile = e.getData(VcsDataKeys.VCS_VIRTUAL_FILE);
-    if ((revision != null) && (revisionVirtualFile != null)) {
-      final GitFileRevision gitRevision = ((GitFileRevision)revision);
-      showSubmittedFiles(project, gitRevision, revisionVirtualFile);
-    }
-  }
-
-  /**
-   * Show submitted files
-   *
-   * @param project  a project
-   * @param revision a file revision
-   * @param file     file affected by the revision
-   */
-  public static void showSubmittedFiles(final Project project, final VcsFileRevision revision, final VirtualFile file) {
-    showSubmittedFiles(project, revision.getRevisionNumber().asString(), file, false, true);
-  }
-
-  /**
-   * Show submitted files
-   *
-   * @param project  a project
-   * @param revision a revision number
-   * @param file     file affected by the revision
-   * @param local
-   * @param revertable
-   */
-  public static void showSubmittedFiles(final Project project, final String revision, final VirtualFile file,
-                                        final boolean local, final boolean revertable) {
-    new Task.Backgroundable(project, GitBundle.message("changes.retrieving", revision)) {
-      public void run(@NotNull ProgressIndicator indicator) {
-        indicator.setIndeterminate(true);
-        try {
-          VirtualFile vcsRoot = GitUtil.getGitRoot(file);
-          final CommittedChangeList changeList = GitChangeUtils.getRevisionChanges(project, vcsRoot, revision, true, local, revertable);
-          if (changeList != null) {
-            UIUtil.invokeLaterIfNeeded(new Runnable() {
-              public void run() {
-                AbstractVcsHelper.getInstance(project)
-                  .showChangesListBrowser(changeList, GitShowAllSubmittedFilesAction.getTitle(revision));
-              }
-            });
-          }
-        }
-        catch (final VcsException e) {
-          UIUtil.invokeLaterIfNeeded(new Runnable() {
-            public void run() {
-              GitUIUtil.showOperationError(project, e, "git show");
-            }
-          });
-        }
-      }
-    }.queue();
-  }
-
-
-  /**
-   * Get dialog title
-   *
-   * @param revNumber a revision number for the dialog
-   * @return a dialog title
-   */
-  private static String getTitle(final String revNumber) {
-    return GitBundle.message("paths.affected.title", revNumber);
-  }
-}
index 5b90c14b07e36918d65ec88dbbec3bf7c922f168..422c1286e5ec9cb4eb88fa6e704f8c5cc2a68d11 100644 (file)
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vcs.FilePath;
 import com.intellij.openapi.vcs.FilePathImpl;
 import com.intellij.openapi.vcs.VcsException;
+import com.intellij.openapi.vcs.annotate.ShowAllAffectedGenericAction;
 import com.intellij.openapi.vcs.changes.ContentRevision;
 import com.intellij.openapi.vcs.history.*;
 import com.intellij.openapi.vfs.VirtualFile;
@@ -32,7 +33,6 @@ import git4idea.GitFileRevision;
 import git4idea.GitRevisionNumber;
 import git4idea.GitUtil;
 import git4idea.GitVcs;
-import git4idea.actions.GitShowAllSubmittedFilesAction;
 import git4idea.changes.GitChangeUtils;
 import git4idea.config.GitExecutableValidator;
 import git4idea.history.browser.SHAHash;
@@ -63,7 +63,7 @@ public class GitHistoryProvider implements VcsHistoryProvider, VcsCacheableHisto
   }
 
   public AnAction[] getAdditionalActions(Runnable refresher) {
-    return new AnAction[]{new GitShowAllSubmittedFilesAction(), new GitCopyHistoryRevisionNumberAction()};
+    return new AnAction[]{new ShowAllAffectedGenericAction(), new GitCopyHistoryRevisionNumberAction()};
   }
 
   public boolean isDateOmittable() {
index 2ec97fc95d70b4adb48edfd61b8b19a35709475d..5e0b960ed26914e76cfbac0589f790c74fc28fa9 100644 (file)
@@ -24,10 +24,10 @@ import com.intellij.util.ArrayUtil;
 import com.intellij.util.ListWithSelection;
 import com.intellij.util.ui.ComboBoxTableCellEditor;
 import com.intellij.util.ui.ComboBoxTableCellRenderer;
-import git4idea.actions.GitShowAllSubmittedFilesAction;
-import git4idea.util.StringScanner;
+import git4idea.GitUtil;
 import git4idea.config.GitConfigUtil;
 import git4idea.i18n.GitBundle;
+import git4idea.util.StringScanner;
 import org.jetbrains.annotations.NonNls;
 
 import javax.swing.*;
@@ -133,7 +133,7 @@ public class GitRebaseEditor extends DialogWrapper {
           return;
         }
         GitRebaseEntry entry = myTableModel.myEntries.get(row);
-        GitShowAllSubmittedFilesAction.showSubmittedFiles(project, entry.getCommit(), gitRoot, false, false);
+        GitUtil.showSubmittedFiles(project, entry.getCommit(), gitRoot, false, false);
       }
     });
 
index eb1c76c671d8b08b37720982d4954ba7be302b2f..d0f0b78b84dfa955ea784f6ca6b47d55fa20e19e 100644 (file)
@@ -20,7 +20,7 @@ import com.intellij.openapi.vcs.VcsException;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.ui.DocumentAdapter;
 import git4idea.GitRevisionNumber;
-import git4idea.actions.GitShowAllSubmittedFilesAction;
+import git4idea.GitUtil;
 import git4idea.util.GitUIUtil;
 
 import javax.swing.*;
@@ -94,7 +94,7 @@ public class GitReferenceValidator {
         myLastResult = false;
         try {
           GitRevisionNumber revision = GitRevisionNumber.resolve(myProject, gitRoot(), revisionExpression);
-          GitShowAllSubmittedFilesAction.showSubmittedFiles(myProject, revision.asString(), gitRoot(), false, false);
+          GitUtil.showSubmittedFiles(myProject, revision.asString(), gitRoot(), false, false);
           myLastResult = true;
         }
         catch (VcsException ex) {
index 5f1c8b1a5a2315ecf784d215db117d85371a83b4..0942eb7fa93ad6b2cfdad9026096b5cf1b2f3499 100644 (file)
@@ -35,11 +35,7 @@ import com.intellij.openapi.vcs.merge.MergeDialogCustomizer;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.ui.DocumentAdapter;
 import com.intellij.util.Consumer;
-import git4idea.GitBranch;
-import git4idea.GitRevisionNumber;
-import git4idea.GitVcs;
-import git4idea.PlatformFacade;
-import git4idea.actions.GitShowAllSubmittedFilesAction;
+import git4idea.*;
 import git4idea.commands.*;
 import git4idea.config.GitVersionSpecialty;
 import git4idea.i18n.GitBundle;
@@ -224,7 +220,7 @@ public class GitUnstashDialog extends DialogWrapper {
           GitUIUtil.showOperationError(myProject, ex, "resolving revision");
           return;
         }
-        GitShowAllSubmittedFilesAction.showSubmittedFiles(myProject, resolvedStash, root, true, false);
+        GitUtil.showSubmittedFiles(myProject, resolvedStash, root, true, false);
       }
     });
     init();
index a2569aa1f7988fc0d4a706cf7d74e3f02d9bcce3..7a1e99d115b880a5d8da566c5e9b9a34e7c2f556 100644 (file)
@@ -22,6 +22,7 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.PanelWithActionsAndCloseButton;
 import com.intellij.openapi.vcs.VcsDataKeys;
+import com.intellij.openapi.vcs.annotate.ShowAllAffectedGenericAction;
 import com.intellij.openapi.vcs.ex.ProjectLevelVcsManagerEx;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.openapi.wm.ToolWindowId;
@@ -36,7 +37,6 @@ import com.intellij.util.ui.UIUtil;
 import com.intellij.util.ui.tree.TreeUtil;
 import com.intellij.vcsUtil.VcsUtil;
 import git4idea.GitFileRevision;
-import git4idea.actions.GitShowAllSubmittedFilesAction;
 import git4idea.rebase.GitRebaseUtils;
 import org.jetbrains.annotations.NotNull;
 
@@ -143,7 +143,7 @@ public class GitSkippedCommits extends PanelWithActionsAndCloseButton {
   @Override
   protected void addActionsTo(DefaultActionGroup group) {
     super.addActionsTo(group);
-    GitShowAllSubmittedFilesAction showCommit = new GitShowAllSubmittedFilesAction();
+    ShowAllAffectedGenericAction showCommit = new ShowAllAffectedGenericAction();
     showCommit.registerCustomShortcutSet(new CustomShortcutSet(
       CommonShortcuts.DOUBLE_CLICK_1.getShortcuts()[0]), myTree);
     group.addAction(showCommit);