public void setSelected(AnActionEvent e, boolean state) { VcsContext context = VcsContextFactory.SERVICE.getInstance().createContextOn(e); Editor editor = context.getEditor(); if (!state) { if (editor != null) { editor.getGutter().closeAllAnnotations(); } } else { if (editor == null) { VirtualFile selectedFile = context.getSelectedFile(); if (selectedFile == null) { return; } FileEditor[] fileEditors = FileEditorManager.getInstance(context.getProject()).openFile(selectedFile, false); for (FileEditor fileEditor : fileEditors) { if (fileEditor instanceof TextEditor) { editor = ((TextEditor) fileEditor).getEditor(); } } } LOGGER.assertTrue(editor != null); doAnnotate(editor, context.getProject()); } }
public boolean isSelected(AnActionEvent e) { VcsContext context = VcsContextFactory.SERVICE.getInstance().createContextOn(e); Editor editor = context.getEditor(); if (editor == null) { return false; } Collection annotations = editor.getUserData(KEY_IN_EDITOR); return annotations != null && !annotations.isEmpty(); }
@Override public Editor getEditor() { return myVcsContext.getEditor(); }