@Override public boolean isSelected(AnActionEvent e) { DataContext context = e.getDataContext(); VirtualFile file = getFile(context); if (file != null) { // 1. Check editor EditorWindow editorWindow = getEditorWindow(context); if (editorWindow != null) { if (!editorWindow.isFileOpen(file)) { file = editorWindow.getSelectedFile(); if (file == null) return false; } return editorWindow.isFilePinned(file); } } // 2. Check content final Content content = getContent(context); if (content != null) { return content.isPinned(); } else { return false; } }
protected boolean isFileToClose(final EditorComposite editor, final EditorWindow window) { return !window.getManager().isChanged(editor) && !window.isFilePinned(editor.getFile()); }