void (@NotNull AnActionEvent e) { Project project = getEventProject(e); Presentation presentation = e.getPresentation(); if (project == null || project.isDisposed()) { presentation.setEnabledAndVisible(false); return; } ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(myToolWindowId); if (toolWindow == null) { presentation.setEnabledAndVisible(hasEmptyState(project)); } else { presentation.setVisible(true); boolean available = toolWindow.isAvailable() || hasEmptyState(project); if (e.getPlace().equals(ActionPlaces.POPUP)) { presentation.setVisible(available); } else { presentation.setEnabled(available); } updatePresentation(presentation, toolWindow); } }