From 34d1109a315a19f2aaad3d254d29c68e7d404132 Mon Sep 17 00:00:00 2001 From: Sergey Evdokimov Date: Mon, 27 Jan 2014 14:43:03 +0400 Subject: [PATCH] IDEA-118601 New Module: Maven: click on "Create from archetype" reverts typed coordinates. --- .../maven/wizards/MavenModuleWizardStep.java | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleWizardStep.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleWizardStep.java index 15813ad5efbb..eabc34c6b0d7 100644 --- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleWizardStep.java +++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/wizards/MavenModuleWizardStep.java @@ -25,6 +25,7 @@ import com.intellij.openapi.util.IconLoader; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VirtualFile; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.idea.maven.model.MavenArchetype; import org.jetbrains.idea.maven.model.MavenId; @@ -209,6 +210,12 @@ public class MavenModuleWizardStep extends ModuleWizardStep { return MavenProjectsManager.getInstance(project).findProject(parentPom); } + private static void setTestIfEmpty(@NotNull JTextField artifactIdField, @Nullable String text) { + if (StringUtil.isEmpty(artifactIdField.getText())) { + artifactIdField.setText(StringUtil.notNullize(text)); + } + } + @Override public void updateStep() { if (myArchetypes != null && myArchetypes.isSkipUpdateUI()) return; @@ -222,14 +229,14 @@ public class MavenModuleWizardStep extends ModuleWizardStep { MavenId projectId = myBuilder.getProjectId(); if (projectId == null) { - myArtifactIdField.setText(myBuilder.getName()); - myGroupIdField.setText(myParent == null ? myBuilder.getName() : myParent.getMavenId().getGroupId()); - myVersionField.setText(myParent == null ? "1.0-SNAPSHOT" : myParent.getMavenId().getVersion()); + setTestIfEmpty(myArtifactIdField, myBuilder.getName()); + setTestIfEmpty(myGroupIdField, myParent == null ? myBuilder.getName() : myParent.getMavenId().getGroupId()); + setTestIfEmpty(myVersionField, myParent == null ? "1.0-SNAPSHOT" : myParent.getMavenId().getVersion()); } else { - myArtifactIdField.setText(projectId.getArtifactId()); - myGroupIdField.setText(projectId.getGroupId()); - myVersionField.setText(projectId.getVersion()); + setTestIfEmpty(myArtifactIdField, projectId.getArtifactId()); + setTestIfEmpty(myGroupIdField, projectId.getGroupId()); + setTestIfEmpty(myVersionField, projectId.getVersion()); } myInheritGroupIdCheckBox.setSelected(myBuilder.isInheritGroupId());