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()); } }
@Override public VirtualFile getSelectedFile() { return myVcsContext.getSelectedFile(); }