Author: fbricon
Date: 2012-01-11 09:15:05 -0500 (Wed, 11 Jan 2012)
New Revision: 37762
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
Log:
JBIDE-10411 : add default values for project name and package
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2012-01-11
14:13:42 UTC (rev 37761)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizard.java 2012-01-11
14:15:05 UTC (rev 37762)
@@ -175,7 +175,9 @@
@Override
public void modifyText(ModifyEvent e) {
wizardPage.setArtifactId(simplePage.getProjectName());
- ArchetypeExamplesWizard.this.getContainer().updateButtons();
+ if (ArchetypeExamplesWizard.this.getContainer().getCurrentPage() != null) {
+ ArchetypeExamplesWizard.this.getContainer().updateButtons();
+ }
}
});
@@ -185,7 +187,9 @@
public void modifyText(ModifyEvent e) {
String packageName = ((Combo)e.getSource()).getText();
wizardPage.setPackageName(packageName);
- ArchetypeExamplesWizard.this.getContainer().updateButtons();
+ if (ArchetypeExamplesWizard.this.getContainer().getCurrentPage() != null) {
+ ArchetypeExamplesWizard.this.getContainer().updateButtons();
+ }
}
});
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2012-01-11
14:13:42 UTC (rev 37761)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2012-01-11
14:15:05 UTC (rev 37762)
@@ -19,6 +19,7 @@
import java.util.Set;
import java.util.regex.Pattern;
+import org.codehaus.plexus.util.StringUtils;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
@@ -124,7 +125,7 @@
if (packageNameModifyListener != null) {
packageCombo.addModifyListener(packageNameModifyListener);
}
-
+
//TODO read facet version from project example metadata
IProjectFacetVersion facetVersion;
try {
@@ -260,12 +261,36 @@
public void setVisible(boolean visible) {
super.setVisible(visible);
- if (visible) {
+ if (visible && !initialized) {
+ //Set defaults values from history here as the history is loaded in super.visible()
+ initDefaultValues();
initialized = true;
- // validate();
+ validate();
}
}
+
+ private void initDefaultValues() {
+ //JBIDE-10411 : provide sensible defaults for project name and package
+ String projectName = projectDescription.getArchetypeModel().getArtifactId();
+ if (StringUtils.isNotBlank(projectName)) {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (!p.exists()) {
+ projectNameCombo.setText(projectName);
+ }
+ }
+
+ String packageName = null;
+ if (packageCombo.getItemCount() > 0) {
+ packageName = packageCombo.getItem(0);
+ } else {
+ packageName = projectDescription.getArchetypeModel().getJavaPackage();
+ }
+ if (packageName != null) {
+ packageCombo.setText(packageName);
+ }
+ }
+
private void createMissingRepositoriesWarning(Composite parent,
GridData gridData) {
//TODO make that damn component align correctly
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java
===================================================================
---
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2012-01-11
14:13:42 UTC (rev 37761)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardPage.java 2012-01-11
14:15:05 UTC (rev 37762)
@@ -77,10 +77,7 @@
Archetype archetype = new Archetype();
ArchetypeModel archetypeModel = projectDescription.getArchetypeModel();
- final String groupId = archetypeModel.getGroupId();
- final String artifactId = archetypeModel.getArtifactId();
final String version = archetypeModel.getVersion();
- final String javaPackage = archetypeModel.getJavaPackage();
archetype.setGroupId(archetypeModel.getArchetypeGroupId());
archetype.setArtifactId(archetypeModel.getArchetypeArtifactId());
@@ -112,19 +109,6 @@
// It needs to be called AFTER setArchetype(archetype) !!!
archetypeChanged = false;
- //Check if project already exists
- IStatus nameStatus = getImportConfiguration().validateProjectName(getModel());
- if(nameStatus.isOK()) {
- artifactIdCombo.setText(artifactId);
- } else {
- //Force the user to change the name if the project exists
- artifactIdCombo.setText("");//$NON-NLS-1$
- }
-
- groupIdCombo.setText(groupId);
- versionCombo.setText(version);
- packageCombo.setText(javaPackage);
-
resolverConfigurationComponent.setExpanded(!resolverConfigurationComponent.getResolverConfiguration().getActiveProfileList().isEmpty());
}
Show replies by date