boolean (Project project, AnActionEvent event) { List<Pair<EditorComposite,EditorWindow>> filesToClose = getFilesToClose(event); if (filesToClose.isEmpty()) { return false; } Set<EditorWindow> checked = new HashSet<>(); boolean hasPinned = false; boolean hasUnpinned = false; for (Pair<EditorComposite, EditorWindow> pair : filesToClose) { final EditorWindow window = pair.second; if (checked.add(window)) { for (EditorComposite composite : window.getAllComposites()) { if (composite.isPinned()) { hasPinned = true; } else { hasUnpinned = true; } } if ((hasPinned || !event.isFromContextMenu()) && hasUnpinned) { return true; } } } return false; }