void (@NotNull AnActionEvent e) { Project project = e.getProject(); ProjectFileIndex index = project == null ? null : ProjectFileIndex.getInstance(project); JBIterable<VirtualFile> files = JBIterable.of(e.getData(CommonDataKeys.VIRTUAL_FILE_ARRAY)); boolean enabled = index != null && files.isNotEmpty() && files.filter(o -> !o.equals(index.getContentRootForFile(o))).isEmpty(); e.getPresentation().setEnabledAndVisible(enabled); if (enabled) { e.getPresentation().setText(getTitle(files.take(2).size())); } }