use of org.eclipse.debug.core.ILaunchConfigurationType in project linuxtools by eclipse.
the class ProfileLaunchShortcut method findLaunchConfiguration.
/**
* Locate a configuration to relaunch for the given type. If one cannot be found, create one.
* @param bin The binary to look launch for.
* @param mode Launch mode.
*
* @return A re-useable config or <code>null</code> if none.
*/
protected ILaunchConfiguration findLaunchConfiguration(IBinary bin, String mode) {
ILaunchConfiguration configuration = null;
ILaunchConfigurationType configType = getLaunchConfigType();
List<ILaunchConfiguration> candidateConfigs = Collections.emptyList();
try {
ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
candidateConfigs = new ArrayList<>(configs.length);
for (ILaunchConfiguration config : configs) {
IPath programPath = CDebugUtils.getProgramPath(config);
String projectName = CDebugUtils.getProjectName(config);
IPath binPath = bin.getResource().getProjectRelativePath();
if (programPath != null && programPath.equals(binPath)) {
if (projectName != null && projectName.equals(bin.getCProject().getProject().getName())) {
candidateConfigs.add(config);
}
}
}
} catch (CoreException e) {
e.printStackTrace();
}
// If there are no existing configs associated with the IBinary, create one.
// If there is exactly one config associated with the IBinary, return it.
// Otherwise, if there is more than one config associated with the IBinary, prompt the
// user to choose one.
int candidateCount = candidateConfigs.size();
if (candidateCount < 1) {
configuration = createConfiguration(bin);
} else if (candidateCount == 1) {
configuration = candidateConfigs.get(0);
} else {
// Prompt the user to choose a config. A null result means the user
// cancelled the dialog, in which case this method returns null,
// since cancelling the dialog should also cancel launching anything.
configuration = chooseConfiguration(candidateConfigs, mode);
}
return configuration;
}
use of org.eclipse.debug.core.ILaunchConfigurationType in project linuxtools by eclipse.
the class AbstractTest method createConfiguration.
protected ILaunchConfiguration createConfiguration(IProject proj) throws CoreException {
String projectName = proj.getName();
String binPath = "";
ILaunchConfigurationType configType = getLaunchConfigType();
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(projectName));
if (proj.getLocation() == null) {
IFileStore fileStore = null;
try {
fileStore = EFS.getStore(new URI(proj.getLocationURI() + BIN_DIR + IPath.SEPARATOR + projectName));
} catch (URISyntaxException e) {
fail(NLS.bind(Messages.getString("AbstractTest.No_binary"), // $NON-NLS-1$
projectName));
}
if ((fileStore instanceof LocalFile)) {
fail(NLS.bind(Messages.getString("AbstractTest.No_binary"), // $NON-NLS-1$
projectName));
}
binPath = EFSExtensionManager.getDefault().getPathFromURI(proj.getLocationURI()) + BIN_DIR + IPath.SEPARATOR + proj.getName();
} else {
IResource bin = proj.findMember(new Path(BIN_DIR).append(projectName));
if (bin == null) {
fail(NLS.bind(Messages.getString("AbstractTest.No_binary"), // $NON-NLS-1$
projectName));
}
binPath = bin.getProjectRelativePath().toString();
wc.setMappedResources(new IResource[] { bin, proj });
}
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, binPath);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectName);
wc.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null);
// Make launch run in foreground
wc.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, false);
setProfileAttributes(wc);
return wc.doSave();
}
use of org.eclipse.debug.core.ILaunchConfigurationType in project derby by apache.
the class DerbyUtils method launch.
protected static ILaunch launch(IProject proj, String name, String mainClass, String args, String vmargs, String app) throws CoreException {
ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
ILaunchConfigurationType type = null;
if (app.equalsIgnoreCase(CommonNames.START_DERBY_SERVER)) {
// type= manager.getLaunchConfigurationType("org.apache.derby.ui.startDerbyServerLaunchConfigurationType");
type = manager.getLaunchConfigurationType(CommonNames.START_SERVER_LAUNCH_CONFIG_TYPE);
} else if (app.equalsIgnoreCase(CommonNames.SHUTDOWN_DERBY_SERVER)) {
// type= manager.getLaunchConfigurationType("org.apache.derby.ui.stopDerbyServerLaunchConfigurationType");
type = manager.getLaunchConfigurationType(CommonNames.STOP_SERVER_LAUNCH_CONFIG_TYPE);
} else if (app.equalsIgnoreCase(CommonNames.IJ)) {
// type= manager.getLaunchConfigurationType("org.apache.derby.ui.ijDerbyLaunchConfigurationType");
type = manager.getLaunchConfigurationType(CommonNames.IJ_LAUNCH_CONFIG_TYPE);
} else if (app.equalsIgnoreCase(CommonNames.SYSINFO)) {
// type= manager.getLaunchConfigurationType("org.apache.derby.ui.sysinfoDerbyLaunchConfigurationType");
type = manager.getLaunchConfigurationType(CommonNames.SYSINFO_LAUNCH_CONFIG_TYPE);
} else {
type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
}
ILaunchConfiguration config = null;
// if the configuration already exists, delete it
ILaunchConfiguration[] configurations = manager.getLaunchConfigurations(type);
for (int i = 0; i < configurations.length; i++) {
if (configurations[i].getName().equals(name))
configurations[i].delete();
}
// else create a new one
if (config == null) {
ILaunchConfigurationWorkingCopy wc = type.newInstance(null, name);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, proj.getProject().getName());
// current directory should be the project root
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, proj.getProject().getLocation().toString());
// use the suplied args
if ((vmargs != null) && !(vmargs.equals(""))) {
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, vmargs);
}
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, mainClass);
wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, args);
// saves the new config
config = wc.doSave();
}
ILaunch launch = config.launch(ILaunchManager.RUN_MODE, null);
config.delete();
return launch;
}
use of org.eclipse.debug.core.ILaunchConfigurationType in project webtools.sourceediting by eclipse.
the class XSLLaunchShortcut method createConfiguration.
private ILaunchConfiguration createConfiguration() {
ILaunchConfiguration config = null;
try {
ILaunchConfigurationType configType = getConfigurationType();
// $NON-NLS-1$
String lastSegment = xmlFile != null ? xmlFile.getName() : xmlFilePath != null ? xmlFilePath.lastSegment() : "XSLTransformation";
ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager().generateUniqueLaunchConfigurationNameFrom(lastSegment));
if (xmlFile != null)
wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_INPUT_FILE, // $NON-NLS-1$ //$NON-NLS-2$
"${workspace_loc:" + xmlFile.getFullPath().toPortableString() + "}");
else
wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_INPUT_FILE, xmlFilePath.toPortableString());
wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_USE_DEFAULT_OUTPUT_FILE, true);
wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_OPEN_FILE, true);
if (pipeline == null)
pipeline = new LaunchPipeline();
for (IFile element : xslFiles) {
pipeline.addTransformDef(new LaunchTransform(element.getFullPath().toPortableString(), LaunchTransform.RESOURCE_TYPE));
}
if (xslFilePath != null) {
pipeline.addTransformDef(new LaunchTransform(xslFilePath, LaunchTransform.EXTERNAL_TYPE));
}
if (!pipeline.getTransformDefs().isEmpty()) {
LaunchTransform lastDef = pipeline.getTransformDefs().get(pipeline.getTransformDefs().size() - 1);
String outputFormat = guessOutputMethod(lastDef);
if (outputFormat != null) {
wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_DEFAULT_OUTPUT_METHOD, outputFormat);
}
}
wc.setAttribute(XSLLaunchConfigurationConstants.ATTR_PIPELINE, pipeline.toXML());
if (xmlFile != null)
wc.setMappedResources(new IResource[] { xmlFile.getProject() });
config = wc.doSave();
} catch (CoreException exception) {
MessageDialog.openError(getShell(), Messages.XSLLaunchShortcut_6, exception.getStatus().getMessage());
}
return config;
}
use of org.eclipse.debug.core.ILaunchConfigurationType in project webtools.sourceediting by eclipse.
the class XSLDebugUILaunchListener method launchesTerminated.
public void launchesTerminated(ILaunch[] launches) {
for (ILaunch launch : launches) {
ILaunchConfigurationType configType = null;
try {
configType = launch.getLaunchConfiguration().getType();
} catch (CoreException e) {
// do nothing
}
if (configType != null && XSL_LAUNCH_CONFIGURATION_TYPE.equals(configType.getIdentifier())) {
try {
BaseLaunchHelper launchHelper = new BaseLaunchHelper(launch.getLaunchConfiguration());
File file = launchHelper.getTarget();
IFile ifile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(file.getAbsolutePath()));
if (ifile != null) {
// refresh this workspace file..
try {
ifile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
} catch (CoreException e) {
XSLDebugUIPlugin.log(e);
}
}
openFileIfRequired(launchHelper);
} catch (CoreException e) {
XSLDebugUIPlugin.log(e);
}
}
}
}
Aggregations