package consulo.maven.newProject;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.ContentEntry;
import com.intellij.openapi.roots.ModifiableRootModel;
import consulo.annotation.access.RequiredReadAction;
import consulo.ide.newProject.NewModuleBuilder;
import consulo.ide.newProject.NewModuleBuilderProcessor;
import consulo.ide.newProject.NewModuleContext;
import consulo.ide.newProject.ui.ProjectOrModuleNameStep;
import consulo.ui.wizard.WizardStep;
import icons.MavenIcons;
import org.jetbrains.idea.maven.wizards.MavenModuleWizardStep;
import org.jetbrains.idea.maven.wizards.SelectPropertiesStep;

import javax.annotation.Nonnull;
import java.util.function.Consumer;

/**
 * @author VISTALL
 * @since 2019-10-06
 */
public class MavenNewModuleBuilder implements NewModuleBuilder
{
	@Override
	public void setupContext(@Nonnull NewModuleContext newModuleContext)
	{
		newModuleContext.get("java").add("From Maven", MavenIcons.MavenLogo, new NewModuleBuilderProcessor<MavenNewModuleContext>()
		{
			@Nonnull
			@Override
			public MavenNewModuleContext createContext(boolean isNewProject)
			{
				return new MavenNewModuleContext(isNewProject);
			}

			@Override
			public void buildSteps(@Nonnull Consumer<WizardStep<MavenNewModuleContext>> consumer, @Nonnull MavenNewModuleContext context)
			{
				consumer.accept(new MavenModuleWizardStep(context));
				consumer.accept(new SelectPropertiesStep());
				consumer.accept(new ProjectOrModuleNameStep<>(context));
			}

			@RequiredReadAction
			@Override
			public void process(@Nonnull MavenNewModuleContext context, @Nonnull ContentEntry contentEntry, @Nonnull ModifiableRootModel modifiableRootModel)
			{
				final Project project = modifiableRootModel.getProject();

				context.registerMavenInitialize(project, contentEntry.getFile());
			}
		});
	}
}

@@ -415,16 +415,23 @@
 ject.ui.
+Unified
 ProjectO
@@ -443,24 +443,66 @@
 leNameStep;%0A
+import consulo.maven.icon.MavenIconGroup;%0A
 import consu
@@ -530,33 +530,8 @@
 ep;%0A
-import icons.MavenIcons;%0A
 impo
@@ -944,19 +944,18 @@
 t.get(%22j
-ava
+vm
 %22).add(%22
@@ -980,19 +980,23 @@
 Icon
-s.M
+Group.m
 avenLogo
 , ne
@@ -991,16 +991,18 @@
 avenLogo
+()
 , new Ne
@@ -1459,24 +1459,24 @@
 iesStep());%0A
-
 %09%09%09%09consumer
@@ -1487,16 +1487,23 @@
 ept(new 
+Unified
 ProjectO

change group name. also use unified step