arguments = buf.toString();
} else {
arguments = "";
}
AbstractLaunchShortcut shortcut = new AbstractLaunchShortcut() {
@Override
protected String getLaunchConfigurationType() {
return launchConfigurationTypeAndInterpreterManager.o1;
}
@Override
protected IInterpreterManager getInterpreterManager(IProject project) {
return launchConfigurationTypeAndInterpreterManager.o2;
}
@Override
public ILaunchConfigurationWorkingCopy createDefaultLaunchConfigurationWithoutSaving(
FileOrResource[] resource) throws CoreException {
ILaunchConfigurationWorkingCopy workingCopy = super
.createDefaultLaunchConfigurationWithoutSaving(resource);
if (arguments.length() > 0) {
workingCopy.setAttribute(Constants.ATTR_UNITTEST_TESTS, arguments);
}
return workingCopy;
}
@Override
protected List<ILaunchConfiguration> findExistingLaunchConfigurations(FileOrResource[] file) {
List<ILaunchConfiguration> ret = new ArrayList<ILaunchConfiguration>();
List<ILaunchConfiguration> existing = super.findExistingLaunchConfigurations(file);
for (ILaunchConfiguration launch : existing) {
boolean matches = false;
try {
matches = launch.getAttribute(Constants.ATTR_UNITTEST_TESTS, "").equals(arguments);
} catch (CoreException e) {
//ignore
}
if (matches) {
ret.add(launch);
}
}
return ret;
}
};
shortcut.launch(pyEdit, "run");
}