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;
final MergeSourceAvailableMarkerGutter mergeSourceGutter =
new MergeSourceAvailableMarkerGutter(fileAnnotation, editor, null, presentation, bgColorMap);
+ presentation.addAction(new SwitchAnnotationSourceAction(switcher, editorGutter));
presentation.addSourceSwitchListener(currentRevisionGutter);
presentation.addSourceSwitchListener(mergeSourceGutter);
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;
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) {