Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2014-04-18 16:18:57 -0400
committerIgor Fedorenko2014-04-19 08:37:55 -0400
commit86e1ca34912a6da5882f6cc3283f84ed22bdf3b1 (patch)
treed9ee1dd91ee54ea26f722f15bb9d6e93d90b73ec /org.eclipse.m2e.launching
parent2423d3c11762f2c2295db757873b27c0a37ede17 (diff)
downloadm2e-core-86e1ca34912a6da5882f6cc3283f84ed22bdf3b1.tar.gz
m2e-core-86e1ca34912a6da5882f6cc3283f84ed22bdf3b1.tar.xz
m2e-core-86e1ca34912a6da5882f6cc3283f84ed22bdf3b1.zip
432436 use runtime name to identify runtimes WIP
Change-Id: Ic2c2f210065775805418e37b47df00b83237f35f Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
Diffstat (limited to 'org.eclipse.m2e.launching')
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/internal/launch/MavenLaunchUtils.java6
-rw-r--r--org.eclipse.m2e.launching/src/org/eclipse/m2e/ui/internal/launch/MavenRuntimeSelector.java52
2 files changed, 44 insertions, 14 deletions
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 0768fabf..7b3c231c 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
@@ -52,11 +52,11 @@ public class MavenLaunchUtils {
public static MavenRuntime getMavenRuntime(ILaunchConfiguration configuration) throws CoreException {
MavenRuntimeManager runtimeManager = MavenPlugin.getMavenRuntimeManager();
- String location = configuration.getAttribute(MavenLaunchConstants.ATTR_RUNTIME, ""); //$NON-NLS-1$
- MavenRuntime runtime = runtimeManager.getRuntime(location);
+ String name = configuration.getAttribute(MavenLaunchConstants.ATTR_RUNTIME, ""); //$NON-NLS-1$
+ MavenRuntime runtime = runtimeManager.getRuntimeByName(name);
if(runtime == null) {
throw new CoreException(new Status(IStatus.ERROR, MavenLaunchConstants.PLUGIN_ID, -1, //
- NLS.bind(Messages.MavenLaunchUtils_error_no_maven_install, location), null));
+ NLS.bind(Messages.MavenLaunchUtils_error_no_maven_install, name), null));
}
return runtime;
}
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 8e218495..fe8aafc1 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
@@ -17,6 +17,8 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -25,6 +27,7 @@ import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
@@ -36,16 +39,18 @@ import org.eclipse.m2e.actions.MavenLaunchConstants;
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.embedder.MavenRuntime;
import org.eclipse.m2e.core.embedder.MavenRuntimeManager;
+import org.eclipse.m2e.core.internal.launch.AbstractMavenRuntime;
/**
* @since 1.4
*/
+@SuppressWarnings("restriction")
public class MavenRuntimeSelector extends Composite {
ComboViewer runtimeComboViewer;
- private MavenRuntimeManager runtimeManager;
+ private static final MavenRuntimeManager runtimeManager = MavenPlugin.getMavenRuntimeManager();
public MavenRuntimeSelector(final Composite mainComposite) {
super(mainComposite, SWT.NONE);
@@ -74,11 +79,33 @@ public class MavenRuntimeSelector extends Composite {
}
});
+ runtimeComboViewer.setLabelProvider(new ILabelProvider() {
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void dispose() {
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public String getText(Object element) {
+ AbstractMavenRuntime runtime = (AbstractMavenRuntime) element;
+ return runtime.isLegacy() ? runtime.toString() : runtime.getName();
+ }
+
+ public Image getImage(Object element) {
+ return null;
+ }
+ });
try {
- runtimeManager = MavenPlugin.getMavenRuntimeManager();
- runtimeComboViewer.setInput(runtimeManager.getMavenRuntimes());
- runtimeComboViewer.setSelection(new StructuredSelection(runtimeManager.getDefaultRuntime()));
+ setInput();
} catch(NullPointerException e) {
// ignore, this only happens inside windowbuilder
}
@@ -90,13 +117,16 @@ public class MavenRuntimeSelector extends Composite {
public void widgetSelected(SelectionEvent e) {
PreferencesUtil.createPreferenceDialogOn(mainComposite.getShell(),
"org.eclipse.m2e.core.preferences.MavenInstallationsPreferencePage", null, null).open(); //$NON-NLS-1$
- MavenRuntimeManager runtimeManager = MavenPlugin.getMavenRuntimeManager();
- runtimeComboViewer.setInput(runtimeManager.getMavenRuntimes());
- runtimeComboViewer.setSelection(new StructuredSelection(runtimeManager.getDefaultRuntime()));
+ setInput();
}
});
}
+ protected void setInput() {
+ runtimeComboViewer.setInput(runtimeManager.getMavenRuntimes());
+ runtimeComboViewer.setSelection(new StructuredSelection(runtimeManager.getDefaultRuntime()));
+ }
+
public void setSelectRuntime(MavenRuntime runtime) {
this.runtimeComboViewer.setSelection(new StructuredSelection(runtime));
}
@@ -111,13 +141,13 @@ public class MavenRuntimeSelector extends Composite {
}
public void initializeFrom(ILaunchConfiguration configuration) {
- String location = "";
+ String name = "";
try {
- location = configuration.getAttribute(MavenLaunchConstants.ATTR_RUNTIME, ""); //$NON-NLS-1$
+ name = configuration.getAttribute(MavenLaunchConstants.ATTR_RUNTIME, ""); //$NON-NLS-1$
} catch(CoreException ex) {
// TODO log
}
- MavenRuntime runtime = runtimeManager.getRuntime(location);
+ MavenRuntime runtime = runtimeManager.getRuntimeByName(name);
if(runtime != null) {
setSelectRuntime(runtime);
}
@@ -125,6 +155,6 @@ public class MavenRuntimeSelector extends Composite {
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
MavenRuntime runtime = getSelectedRuntime();
- configuration.setAttribute(MavenLaunchConstants.ATTR_RUNTIME, runtime.getLocation());
+ configuration.setAttribute(MavenLaunchConstants.ATTR_RUNTIME, runtime.getName());
}
}

Back to the top