@Override
  public void update(@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 = Arrays.asList(view.getDirectories());
    if (directories.isEmpty()) {
      presentation.setEnabledAndVisible(false);
      return;
    }

    presentation.setEnabledAndVisible(true);

    boolean isPackage = isPackage(project, directories);

    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);
    }
  }
@Override
  public void update(@NotNull AnActionEvent event)