vcs annotate: cleanup
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Sat, 20 Jun 2015 12:02:13 +0000 (15:02 +0300)
committerAleksey Pivovarov <AMPivovarov@gmail.com>
Thu, 3 Sep 2015 16:28:02 +0000 (19:28 +0300)
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotateToggleAction.java
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationPresentation.java

index 0273c10a834ee83836c37ba79d2fa7a35bc703f4..969b2601906699b887cea9626dbb447f3357359c 100644 (file)
@@ -246,14 +246,13 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware, Ann
     final EditorGutterComponentEx editorGutter = (EditorGutterComponentEx)editor.getGutter();
     final List<AnnotationFieldGutter> gutters = new ArrayList<AnnotationFieldGutter>();
     final AnnotationSourceSwitcher switcher = fileAnnotation.getAnnotationSourceSwitcher();
-    final List<AnAction> additionalActions = new ArrayList<AnAction>();
+
+    final AnnotationPresentation presentation = new AnnotationPresentation(fileAnnotation, switcher);
     if (vcs.getCommittedChangesProvider() != null) {
-      additionalActions.add(new ShowDiffFromAnnotation(getUpToDateLineNumber, fileAnnotation, vcs, file));
+      presentation.addAction(new ShowDiffFromAnnotation(getUpToDateLineNumber, fileAnnotation, vcs, file));
     }
-    additionalActions.add(new CopyRevisionNumberFromAnnotateAction(getUpToDateLineNumber, fileAnnotation));
-    final AnnotationPresentation presentation =
-      new AnnotationPresentation(fileAnnotation, switcher, editorGutter,
-                                 additionalActions.toArray(new AnAction[additionalActions.size()]));
+    presentation.addAction(new CopyRevisionNumberFromAnnotateAction(getUpToDateLineNumber, fileAnnotation));
+    presentation.addAction(Separator.getInstance());
 
     final Couple<Map<VcsRevisionNumber, Color>> bgColorMap =
       Registry.is("vcs.show.colored.annotations") ? computeBgColors(fileAnnotation) : null;
@@ -267,6 +266,7 @@ public class AnnotateToggleAction extends ToggleAction implements DumbAware, Ann
       final MergeSourceAvailableMarkerGutter mergeSourceGutter =
         new MergeSourceAvailableMarkerGutter(fileAnnotation, editor, null, presentation, bgColorMap);
 
+      presentation.addAction(new SwitchAnnotationSourceAction(switcher, editorGutter));
       presentation.addSourceSwitchListener(currentRevisionGutter);
       presentation.addSourceSwitchListener(mergeSourceGutter);
 
index 6186a244782b176a0bfbfa33fdd9edc1c03d9d03..66db4fc76f5e48d0c4aaec31f07ede59d57115b0 100644 (file)
 package com.intellij.openapi.vcs.actions;
 
 import com.intellij.openapi.actionSystem.AnAction;
-import com.intellij.openapi.actionSystem.Separator;
 import com.intellij.openapi.editor.colors.ColorKey;
 import com.intellij.openapi.editor.colors.EditorFontType;
-import com.intellij.openapi.editor.ex.EditorGutterComponentEx;
 import com.intellij.openapi.vcs.annotate.*;
 import com.intellij.openapi.vcs.history.VcsRevisionNumber;
 import com.intellij.util.Consumer;
@@ -28,37 +26,19 @@ import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.List;
 
 class AnnotationPresentation implements TextAnnotationPresentation {
   private final FileAnnotation myFileAnnotation;
   @Nullable
   private final AnnotationSourceSwitcher mySwitcher;
-  private final ArrayList<AnAction> myActions;
+  private final ArrayList<AnAction> myActions = new ArrayList<AnAction>();
   private SwitchAnnotationSourceAction mySwitchAction;
   private final List<LineNumberListener> myPopupLineNumberListeners = ContainerUtil.createLockFreeCopyOnWriteList();
 
-  AnnotationPresentation(@NotNull FileAnnotation fileAnnotation,
-                         @Nullable final AnnotationSourceSwitcher switcher,
-                         final EditorGutterComponentEx gutter,
-                         final AnAction... actions) {
+  AnnotationPresentation(@NotNull FileAnnotation fileAnnotation, @Nullable final AnnotationSourceSwitcher switcher) {
     myFileAnnotation = fileAnnotation;
     mySwitcher = switcher;
-
-    myActions = new ArrayList<AnAction>();
-    myActions.add(Separator.getInstance());
-    if (actions != null) {
-      final List<AnAction> actionsList = Arrays.asList(actions);
-      if (!actionsList.isEmpty()) {
-        myActions.addAll(actionsList);
-        myActions.add(new Separator());
-      }
-    }
-    if (mySwitcher != null) {
-      mySwitchAction = new SwitchAnnotationSourceAction(mySwitcher, gutter);
-      myActions.add(mySwitchAction);
-    }
   }
 
   public void addLineNumberListener(final LineNumberListener listener) {