@Override
    public void actionPerformed(@NotNull final AnActionEvent e) {
      NamedConfigurable<?> namedConfigurable = getSelectedConfigurable();
      if (!(namedConfigurable instanceof ModuleConfigurable)) {
        copyByExtension(namedConfigurable);
      }

      try {
        ModuleEditor moduleEditor = ((ModuleConfigurable)namedConfigurable).getModuleEditor();
        String modulePresentation = IdeCoreBundle.message("project.new.wizard.module.identification");
        NamePathComponent component = new NamePathComponent(JavaUiBundle.message("label.module.name"),
                                                            JavaUiBundle.message("label.component.file.location", StringUtil.capitalize(modulePresentation)),
                                                            JavaUiBundle
                                                              .message("title.select.project.file.directory", modulePresentation),
                                                            JavaUiBundle.message("description.select.project.file.directory",
                                                                                 StringUtil.capitalize(modulePresentation)),
                                                            true,
                                                            false);
        Module originalModule = moduleEditor.getModule();
        if (originalModule != null) {
          component.setPath(FileUtil.toSystemDependentName(originalModule.getModuleNioFile().getParent().toString()));
        }

        DialogBuilder dialogBuilder = new DialogBuilder(myTree);
        dialogBuilder.setTitle(JavaUiBundle.message("copy.module.dialog.title"));
        dialogBuilder.setCenterPanel(component);
        dialogBuilder.setPreferredFocusComponent(component.getNameComponent());
        dialogBuilder.setOkOperation(() -> {
          final String name = component.getNameValue();
          if (name.isEmpty()) {
            Messages.showErrorDialog(JavaUiBundle.message("enter.module.copy.name.error.message"), CommonBundle.getErrorTitle());
            return;
          }
          if (getModule(name) != null) {
            Messages
              .showErrorDialog(JavaUiBundle.message("module.0.already.exists.error.message", name), CommonBundle.getErrorTitle());
            return;
          }

          if (component.getPath().isEmpty()) {
            Messages.showErrorDialog(JavaUiBundle.message("prompt.enter.project.file.location", modulePresentation),
                                     CommonBundle.getErrorTitle());
            return;
          }
          if (!ProjectWizardUtil
            .createDirectoryIfNotExists(JavaUiBundle.message("directory.project.file.directory", modulePresentation), component.getPath(),
                                        true)) {
            Messages.showErrorDialog(JavaUiBundle.message("path.0.is.invalid.error.message", component.getPath()),
                                     CommonBundle.getErrorTitle());
            return;
          }
          dialogBuilder.getDialogWrapper().close(DialogWrapper.OK_EXIT_CODE);
        });
        if (dialogBuilder.show() != DialogWrapper.OK_EXIT_CODE) {
          return;
        }

        ModifiableRootModel rootModel = moduleEditor.getModifiableRootModel();
        Path path = Paths.get(component.getPath());
        ModuleBuilder builder = new CopiedModuleBuilder(rootModel, path, myProject);
        builder.setName(component.getNameValue());
        builder.setModuleFilePath(path.resolve(builder.getName() + ModuleFileType.DOT_DEFAULT_EXTENSION).toString());
        Module module = myContext.myModulesConfigurator.addModule(builder);
        if (module != null) {
          addModuleNode(module);
        }
      }
      catch (Exception e1) {
        LOG.error(e1);
      }
    }
@Override
    public void actionPerformed(@NotNull final AnActionEvent e)