private void removeAnathema() { if (!myAnathemaThrown) return; myAnathemaThrown = false; final FileEditor[] editors = myFileEditorManager.getEditors(myVirtualFile); for (FileEditor editor : editors) { final CanNotCalculateDiffPanel panel = editor.getUserData(PANEL_KEY); if (panel != null) { myFileEditorManager.removeTopComponent(editor, panel); editor.putUserData(PANEL_KEY, null); } } }
private static boolean activatePsiElementIfOpen( @NotNull PsiElement elt, boolean searchForOpen, boolean requestFocus) { if (!elt.isValid()) return false; elt = elt.getNavigationElement(); final PsiFile file = elt.getContainingFile(); if (file == null || !file.isValid()) return false; VirtualFile vFile = file.getVirtualFile(); if (vFile == null) return false; if (!EditorHistoryManager.getInstance(elt.getProject()).hasBeenOpen(vFile)) return false; final FileEditorManager fem = FileEditorManager.getInstance(elt.getProject()); if (!fem.isFileOpen(vFile)) { fem.openFile(vFile, requestFocus, searchForOpen); } final TextRange range = elt.getTextRange(); if (range == null) return false; final FileEditor[] editors = fem.getEditors(vFile); for (FileEditor editor : editors) { if (editor instanceof TextEditor) { final Editor text = ((TextEditor) editor).getEditor(); final int offset = text.getCaretModel().getOffset(); if (range.containsOffset(offset)) { // select the file fem.openFile(vFile, requestFocus, searchForOpen); return true; } } } return false; }