if (matchingConfigs.size() == 1) {
Activator.getLogger().info("Using existing launch configuration");
return matchingConfigs.get(0);
} else if (matchingConfigs.size() > 1) {
final IDebugModelPresentation labelProvider = DebugUITools
.newDebugModelPresentation();
ElementListSelectionDialog dialog = new ElementListSelectionDialog(
getShell(), //
new ILabelProvider() {
@Override
public Image getImage(Object element) {
return labelProvider.getImage(element);
}
@Override
public String getText(Object element) {
if (element instanceof ILaunchConfiguration) {
ILaunchConfiguration configuration = (ILaunchConfiguration) element;
try {
return labelProvider
.getText(element)
+ " : "
+ configuration
.getAttribute(
MavenLaunchConstants.ATTR_GOALS,
"");
} catch (CoreException ex) {
// ignore
}
}
return labelProvider.getText(element);
}
@Override
public boolean isLabelProperty(Object element,
String property) {
return labelProvider.isLabelProperty(
element, property);
}
@Override
public void addListener(
ILabelProviderListener listener) {
labelProvider.addListener(listener);
}
@Override
public void removeListener(
ILabelProviderListener listener) {
labelProvider.removeListener(listener);
}
@Override
public void dispose() {
labelProvider.dispose();
}
});
dialog.setElements(matchingConfigs
.toArray(new ILaunchConfiguration[matchingConfigs
.size()]));
dialog.setTitle("Select Configuration");
if (mode.equals(ILaunchManager.DEBUG_MODE)) {
dialog.setMessage("Select a launch configuration to debug:");
} else {
dialog.setMessage("Select a launch configuration to run:");
}
dialog.setMultipleSelection(false);
int result = dialog.open();
labelProvider.dispose();
return result == Window.OK ? (ILaunchConfiguration) dialog
.getFirstResult() : null;
}
} catch (CoreException ex) {