Author: fbricon
Date: 2011-12-02 12:23:30 -0500 (Fri, 02 Dec 2011)
New Revision: 36884
Modified:
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java
Log:
JBIDE-10322 : Reuse the last selected target runtime in the Archetype-based Project
Example wizard
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 2011-12-02
15:59:13 UTC (rev 36883)
+++
trunk/maven/plugins/org.jboss.tools.maven.project.examples/src/org/jboss/tools/maven/project/examples/wizard/ArchetypeExamplesWizardFirstPage.java 2011-12-02
17:23:30 UTC (rev 36884)
@@ -65,6 +65,7 @@
*/
public class ArchetypeExamplesWizardFirstPage extends MavenProjectWizardLocationPage {
+ private static final String TARGET_RUNTIME = "targetRuntime";
private Label projectNameLabel;
private Combo projectNameCombo;
private Label packageLabel;
@@ -88,6 +89,7 @@
}
+
@Override
protected void createAdditionalControls(Composite container) {
@@ -162,11 +164,21 @@
serverTargetCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY);
serverTargetCombo.setLayoutData(gridData);
serverRuntimes = getServerRuntimes(facetVersion);
- for (String runtimeName : serverRuntimes.keySet()) {
- serverTargetCombo.add(runtimeName);
+ serverTargetCombo.add(Messages.ArchetypeExamplesWizardFirstPage_No_TargetRuntime);
+ int i =0, selectedRuntimeIdx = 0;
+ String lastUsedRuntime = dialogSettings.get(TARGET_RUNTIME);
+
+ for (Map.Entry<String, IRuntime> entry : serverRuntimes.entrySet()) {
+ serverTargetCombo.add(entry.getKey());
+ ++i;
+ IRuntime runtime = entry.getValue();
+ if (lastUsedRuntime != null && lastUsedRuntime.equals(runtime.getId())) {
+ selectedRuntimeIdx = i;
+ }
}
- serverTargetCombo.add(Messages.ArchetypeExamplesWizardFirstPage_No_TargetRuntime);
- serverTargetCombo.select(0);
+
+ serverTargetCombo.select(selectedRuntimeIdx);
+
serverTargetCombo.addModifyListener(new ModifyListener() {
@Override
@@ -174,6 +186,7 @@
validateEnterpriseRepo();
}
});
+
}
protected void validate() {
@@ -355,4 +368,16 @@
MavenProjectExamplesActivator.log(e);
}
}
+
+ @Override
+ public void dispose() {
+ if (dialogSettings != null && serverRuntimes != null &&
serverTargetCombo != null) {
+ IRuntime lastUsedRuntime = serverRuntimes.get(serverTargetCombo.getText());
+ if (lastUsedRuntime != null) {
+ dialogSettings.put(TARGET_RUNTIME, lastUsedRuntime.getId());
+ }
+ }
+ super.dispose();
+ }
+
}
Show replies by date