void (@NotNull final AnActionEvent e) { super.update(e); final Project project = e.getData(CommonDataKeys.PROJECT); final Presentation presentation = e.getPresentation(); if (presentation.isEnabled()) { final IdeView view = e.getData(LangDataKeys.IDE_VIEW); if (view != null) { final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final PsiDirectory[] dirs = view.getDirectories(); for (final PsiDirectory dir : dirs) { if (projectFileIndex.isUnderSourceRootOfType(dir.getVirtualFile(), JavaModuleSourceRootTypes.SOURCES) && JavaDirectoryService.getInstance().getPackage(dir) != null) { return; } } } presentation.setEnabledAndVisible(false); } }