void (@NotNull AnActionEvent event) { Presentation presentation = event.getPresentation(); Project project = event.getData(CommonDataKeys.PROJECT); if (project == null) { presentation.setEnabledAndVisible(false); return; } IdeView view = event.getData(LangDataKeys.IDE_VIEW); if (view == null) { presentation.setEnabledAndVisible(false); return; } List<@NotNull PsiDirectory> directories = Stream.of(view.getDirectories()).filter(d -> d != null).toList(); if (directories.isEmpty()) { presentation.setEnabledAndVisible(false); return; } presentation.setEnabledAndVisible(true); boolean isPackage = false; final PsiDirectoryFactory factory = PsiDirectoryFactory.getInstance(project); for (PsiDirectory directory : directories) { if (factory.isPackage(directory)) { isPackage = true; break; } } if (isPackage) { presentation.setText(IdeBundle.messagePointer("action.package")); presentation.setIcon(AllIcons.Nodes.Package); } else { presentation.setText(IdeBundle.messagePointer("action.directory")); presentation.setIcon(PlatformIcons.FOLDER_ICON); } }