use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project bndtools by bndtools.
the class OSGiJUnitLaunchDelegate method getLaunch.
// A couple of hacks to make sure the JUnit plugin is active and notices our
// launch.
@Override
public ILaunch getLaunch(ILaunchConfiguration configuration, String mode) throws CoreException {
// start the JUnit plugin
try {
Bundle jdtJUnitBundle = BundleUtils.findBundle(Plugin.getDefault().getBundleContext(), JDT_JUNIT_BSN, null);
if (jdtJUnitBundle == null)
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Bundle \"{0}\" was not found. Cannot report JUnit results via the Workbench.", JDT_JUNIT_BSN), null));
jdtJUnitBundle.start();
} catch (BundleException e) {
throw new CoreException(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error starting bundle \"{0}\". Cannot report JUnit results via the Workbench.", JDT_JUNIT_BSN), null));
}
// JUnit plugin ignores the launch unless attribute
// "org.eclipse.jdt.launching.PROJECT_ATTR" is set.
ILaunchConfigurationWorkingCopy modifiedConfig = configuration.getWorkingCopy();
IResource launchResource = LaunchUtils.getTargetResource(configuration);
if (launchResource != null) {
String launchProjectName = LaunchUtils.getLaunchProjectName(launchResource);
IProject launchProject = ResourcesPlugin.getWorkspace().getRoot().getProject(launchProjectName);
if (!launchProject.exists()) {
launchProjectName = launchResource.getProject().getName();
}
modifiedConfig.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, launchProjectName);
}
return super.getLaunch(modifiedConfig.doSave(), mode);
}
use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project bndtools by bndtools.
the class AbstractLaunchShortcut method launch.
protected void launch(IPath targetPath, IProject targetProject, String mode) {
IPath tp = targetPath.makeRelative();
try {
ILaunchConfiguration config = findLaunchConfig(tp);
if (config == null) {
ILaunchConfigurationWorkingCopy wc = createConfiguration(tp, targetProject);
config = wc.doSave();
}
DebugUITools.launch(config, mode);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project bndtools by bndtools.
the class AbstractLaunchShortcut method createConfiguration.
protected ILaunchConfigurationWorkingCopy createConfiguration(IPath targetPath, IProject targetProject) throws CoreException {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType configType = manager.getLaunchConfigurationType(launchId);
ILaunchConfigurationWorkingCopy wc;
wc = configType.newInstance(null, manager.generateLaunchConfigurationName(targetPath.lastSegment()));
wc.setAttribute(LaunchConstants.ATTR_LAUNCH_TARGET, targetPath.toString());
wc.setAttribute(LaunchConstants.ATTR_CLEAN, LaunchConstants.DEFAULT_CLEAN);
wc.setAttribute(LaunchConstants.ATTR_DYNAMIC_BUNDLES, LaunchConstants.DEFAULT_DYNAMIC_BUNDLES);
if (targetProject != null) {
IJavaProject javaProject = JavaCore.create(targetProject);
if (javaProject.exists()) {
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, targetProject.getName());
}
}
return wc;
}
use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.
the class LaunchConfigurationUtils method updateLaunchConfigurations.
/**
* Updates all {@link ILaunchConfiguration} of the given {@code type} where
* there is an attribute with the given {@code attributeName} of the given
* {@code oldValue}, and sets the {@code newValue} instead.
*
* @param type
* the type of {@link ILaunchConfiguration} to find
* @param attributeName
* the name of the attribute to look-up
* @param oldValue
* the old value to match
* @param newValue
* the new value to set
*/
public static void updateLaunchConfigurations(final String type, final String attributeName, final String oldValue, final String newValue) {
final ILaunchConfigurationType configType = LaunchConfigurationUtils.getLaunchConfigType(type);
final ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
try {
for (ILaunchConfiguration config : manager.getLaunchConfigurations(configType)) {
try {
if (// $NON-NLS-1$
config.getAttribute(attributeName, "").equals(oldValue)) {
final ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy();
workingCopy.setAttribute(attributeName, newValue);
workingCopy.doSave();
}
} catch (CoreException e) {
Activator.logErrorMessage(LaunchMessages.getFormattedString(// $NON-NLS-1$
"UpdateLaunchConfiguration.named.error", config.getName()), e);
}
}
} catch (CoreException e) {
Activator.logErrorMessage(// $NON-NLS-1$
LaunchMessages.getString(// $NON-NLS-1$
"UpdateLaunchConfiguration.error"), e);
Activator.logErrorMessage("Failed to retrieve launch configurations after connection name changed", e);
}
}
use of org.eclipse.debug.core.ILaunchConfigurationWorkingCopy in project linuxtools by eclipse.
the class LaunchConfigurationUtils method createBuildImageLaunchConfiguration.
/**
* Creates a new {@link ILaunchConfiguration} to build an
* {@link IDockerImage} from a Dockerfile {@link IResource}.
*
* @param connection
* the connection to use to submit the build
* @param repoName
* the repo/name of the {@link IDockerImage} to build
* @param dockerfile
* the dockerfile to use to build the {@link IDockerImage}
* @return the created {@link ILaunchConfiguration}
* @throws CoreException
*/
public static ILaunchConfiguration createBuildImageLaunchConfiguration(final IDockerConnection connection, final String repoName, final IResource dockerfile) throws CoreException {
final ILaunchConfigurationType configType = LaunchConfigurationUtils.getLaunchConfigType(IBuildDockerImageLaunchConfigurationConstants.CONFIG_TYPE_ID);
final ILaunchConfigurationWorkingCopy wc = getLaunchConfigurationWorkingCopy(configType, createBuildImageLaunchConfigurationName(repoName, dockerfile));
wc.setAttribute(IBuildDockerImageLaunchConfigurationConstants.SOURCE_PATH_LOCATION, dockerfile.getFullPath().removeLastSegments(1).toString());
wc.setAttribute(IBuildDockerImageLaunchConfigurationConstants.SOURCE_PATH_WORKSPACE_RELATIVE_LOCATION, true);
wc.setAttribute(IDockerImageBuildOptions.DOCKER_CONNECTION, connection.getName());
wc.setAttribute(IDockerImageBuildOptions.REPO_NAME, repoName);
return wc.doSave();
}
Aggregations