*/
public class AnnotateToggleAction extends ToggleAction implements DumbAware, AnnotationColors {
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.vcs.actions.AnnotateToggleAction");
- protected static final Key<Collection<ActiveAnnotationGutter>> KEY_IN_EDITOR = Key.create("Annotations");
@Override
public void update(@NotNull AnActionEvent e) {
}
private static boolean isAnnotated(@NotNull Editor editor) {
- Collection annotations = editor.getUserData(KEY_IN_EDITOR);
- return annotations != null && !annotations.isEmpty();
+ return editor.getGutter().isAnnotationsShown();
}
@Override
final Project project,
final VirtualFile file,
final FileAnnotation fileAnnotation,
- final AbstractVcs vcs, final boolean onCurrentRevision) {
+ final AbstractVcs vcs,
+ final boolean onCurrentRevision) {
final UpToDateLineNumberProvider getUpToDateLineNumber = new UpToDateLineNumberProviderImpl(editor.getDocument(), project);
editor.getGutter().closeAllAnnotations();
- final VcsAnnotationLocalChangesListener listener = ProjectLevelVcsManager.getInstance(project).getAnnotationLocalChangesListener();
fileAnnotation.setCloser(new Runnable() {
@Override
}
});
if (onCurrentRevision) {
- listener.registerAnnotation(file, fileAnnotation);
- }
-
- // be careful, not proxies but original items are put there (since only their presence not behaviour is important)
- Collection<ActiveAnnotationGutter> annotations = editor.getUserData(KEY_IN_EDITOR);
- if (annotations == null) {
- annotations = new HashSet<ActiveAnnotationGutter>();
- editor.putUserData(KEY_IN_EDITOR, annotations);
+ ProjectLevelVcsManager.getInstance(project).getAnnotationLocalChangesListener().registerAnnotation(file, fileAnnotation);
}
final EditorGutterComponentEx editorGutter = (EditorGutterComponentEx)editor.getGutter();
else {
editor.getGutter().registerTextAnnotation(proxy);
}
- annotations.add(gutter);
}
}
*/
public class AnnotationFieldGutter implements ActiveAnnotationGutter {
protected final FileAnnotation myAnnotation;
- private final Editor myEditor;
protected final LineAnnotationAspect myAspect;
private final TextAnnotationPresentation myPresentation;
private final boolean myIsGutterAction;
final TextAnnotationPresentation presentation,
Couple<Map<VcsRevisionNumber, Color>> colorScheme) {
myAnnotation = annotation;
- myEditor = editor;
myAspect = aspect;
myPresentation = presentation;
myIsGutterAction = myAspect instanceof EditorGutterAction;
public void gutterClosed() {
myAnnotation.unregister();
myAnnotation.dispose();
- final Collection<ActiveAnnotationGutter> gutters = myEditor.getUserData(AnnotateToggleAction.KEY_IN_EDITOR);
- if (gutters != null) {
- gutters.remove(this);
- }
}
@Nullable