void (@NotNull AnActionEvent e) { final IdeView view = e.getData(LangDataKeys.IDE_VIEW); if (view == null) { return; } final Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) return; final PsiDirectory directory = DirectoryChooserUtil.getOrChooseDirectory(view); if (directory == null) return; Module module = e.getData(PlatformCoreDataKeys.MODULE); if (module == null) return; final CreateFileFromTemplateDialog.Builder builder = createDialogBuilder(project); final SmartPointerManager pointerManager = SmartPointerManager.getInstance(project); final SmartPsiElementPointer<PsiDirectory> directoryPointer = pointerManager.createSmartPsiElementPointer(directory); final CreateDirectoryOrPackageHandler newOrdinaryPackageHandler = getNewOrdinaryPackageHandler(project, directory, directoryPointer); final CreateDirectoryOrPackageHandler newNamespacePackageHandler = getNewNamespacePackageHandler(project, directory, directoryPointer, module); builder.show(PyBundle.message("dialog.title.can.t.create.package"), ORDINARY_PACKAGE_TYPE, new CreateFileFromTemplateDialog.FileCreator<PsiDirectory>() { @Override public PsiDirectory createFile(@NotNull String name, @NotNull String templateName) { if (templateName.equals(ORDINARY_PACKAGE_TYPE)) { createNewPackage(name, newOrdinaryPackageHandler, item -> { if (item != null) { view.selectElement(item); } }); } else if (templateName.equals(NAMESPACE_PACKAGE_TYPE)) { createNewPackage(name, newNamespacePackageHandler, item -> { if (item != null) { view.selectElement(item); } }); PyNamespacePackagesStatisticsCollector.logNamespacePackageCreatedByUser(); } return directory; } @Override public boolean startInWriteAction() { return false; } @Override @NotNull public String getActionName(@NotNull String name, @NotNull String templateName) { return PyBundle.message("command.name.create.new.package", name); } }, EmptyConsumer.getInstance()); }