Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2014-04-24 20:16:02 -0400
committerIgor Fedorenko2014-04-24 20:16:02 -0400
commitb8961958cf7f7770ab9aa0a7d0f9910ec896e889 (patch)
tree1355b3186b165672ffddbec47ff582716a6d66ea
parent79864201cd3ccad476fb148748ef5ef5ad6f4ec9 (diff)
downloadm2e-core-b8961958cf7f7770ab9aa0a7d0f9910ec896e889.tar.gz
m2e-core-b8961958cf7f7770ab9aa0a7d0f9910ec896e889.tar.xz
m2e-core-b8961958cf7f7770ab9aa0a7d0f9910ec896e889.zip
432436 fixed default runtime handling
Change-Id: I72180714a0de33e5ab1573d44193f959c7692b83 Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java4
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java2
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java23
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java2
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java5
5 files changed, 22 insertions, 14 deletions
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
index 147093bd..beed797c 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/preferences/launch/MavenInstallationsPreferencePage.java
@@ -91,7 +91,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
@Override
protected void performDefaults() {
runtimeManager.reset();
- defaultRuntime = runtimeManager.getDefaultRuntime().getName();
+ defaultRuntime = runtimeManager.getRuntime(MavenRuntimeManagerImpl.DEFAULT).getName();
runtimes = runtimeManager.getMavenRuntimes(false);
runtimesViewer.setInput(runtimes);
@@ -124,7 +124,7 @@ public class MavenInstallationsPreferencePage extends PreferencePage implements
createTable(composite);
new Label(composite, SWT.NONE);
- defaultRuntime = runtimeManager.getDefaultRuntime().getName();
+ defaultRuntime = runtimeManager.getRuntime(MavenRuntimeManagerImpl.DEFAULT).getName();
runtimes = runtimeManager.getMavenRuntimes(false);
runtimesViewer.setInput(runtimes);
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java
index ab426419..dfb76eaf 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/embedder/MavenRuntimeManager.java
@@ -55,7 +55,7 @@ public class MavenRuntimeManager {
}
public MavenRuntime getDefaultRuntime() {
- return impl.getDefaultRuntime();
+ return impl.getRuntime(DEFAULT);
}
public MavenRuntime getRuntime(String location) {
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java
index 3cdede27..c674d0a9 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/launch/MavenRuntimeManagerImpl.java
@@ -53,17 +53,24 @@ public class MavenRuntimeManagerImpl {
this.preferencesLookup[1] = DefaultScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
}
- public AbstractMavenRuntime getDefaultRuntime() {
- String selected = preferenceStore.get(MavenPreferenceConstants.P_DEFAULT_RUNTIME, null, preferencesLookup);
- if(selected == null) {
- return new MavenEmbeddedRuntime();
+ public AbstractMavenRuntime getRuntime(String name) {
+ if(name == null || name.trim().isEmpty() || DEFAULT.equals(name.trim())) {
+ return getDefaultRuntime();
}
- AbstractMavenRuntime runtime = getRuntimeByName(selected);
- return runtime != null && runtime.isAvailable() ? runtime : new MavenEmbeddedRuntime();
+ AbstractMavenRuntime runtime = getRuntimes().get(name);
+ if(runtime == null) {
+ runtime = getDefaultRuntime();
+ }
+ return runtime;
}
- public AbstractMavenRuntime getRuntimeByName(String name) {
- return getRuntimes().get(name);
+ private AbstractMavenRuntime getDefaultRuntime() {
+ String name = preferenceStore.get(MavenPreferenceConstants.P_DEFAULT_RUNTIME, null, preferencesLookup);
+ AbstractMavenRuntime runtime = getRuntimes().get(name);
+ if(runtime == null || !runtime.isAvailable()) {
+ runtime = new MavenEmbeddedRuntime();
+ }
+ return runtime;
}
public List<AbstractMavenRuntime> getMavenRuntimes() {
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java
index 0e753de1..d8575fc4 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java
@@ -42,7 +42,7 @@ public class MavenLaunchUtils {
public static AbstractMavenRuntime getMavenRuntime(ILaunchConfiguration configuration) throws CoreException {
MavenRuntimeManagerImpl runtimeManager = MavenPluginActivator.getDefault().getMavenRuntimeManager();
String name = configuration.getAttribute(MavenLaunchConstants.ATTR_RUNTIME, ""); //$NON-NLS-1$
- AbstractMavenRuntime runtime = runtimeManager.getRuntimeByName(name);
+ AbstractMavenRuntime runtime = runtimeManager.getRuntime(name);
if(runtime == null) {
throw new CoreException(new Status(IStatus.ERROR, MavenLaunchConstants.PLUGIN_ID, -1, //
NLS.bind(Messages.MavenLaunchUtils_error_no_maven_install, name), null));
diff --git a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
index a045f140..fbea9426 100644
--- a/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
+++ b/org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java
@@ -156,7 +156,8 @@ public class MavenRuntimeSelector extends Composite {
protected void setInput() {
MavenRuntimeManagerImpl runtimeManager = getRuntimeManager();
runtimeComboViewer.setInput(runtimeManager.getMavenRuntimes());
- runtimeComboViewer.setSelection(new StructuredSelection(runtimeManager.getDefaultRuntime()));
+ runtimeComboViewer
+ .setSelection(new StructuredSelection(runtimeManager.getRuntime(MavenRuntimeManagerImpl.DEFAULT)));
}
public void setSelectRuntime(AbstractMavenRuntime runtime) {
@@ -179,7 +180,7 @@ public class MavenRuntimeSelector extends Composite {
} catch(CoreException ex) {
// TODO log
}
- AbstractMavenRuntime runtime = getRuntimeManager().getRuntimeByName(name);
+ AbstractMavenRuntime runtime = getRuntimeManager().getRuntime(name);
if(runtime != null) {
setSelectRuntime(runtime);
}

Back to the top