Java Code Examples for org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setMappedResources()
The following examples show how to use
org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#setMappedResources() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractRunHTMLDebugTab.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { String programPath = this.programPathText.getText(); if (programPathText.isEnabled()) { configuration.setAttribute(AbstractHTMLDebugDelegate.PROGRAM, programPath); configuration.setAttribute(ChromeRunDAPDebugDelegate.URL, ""); } else if (urlText.isEnabled()) { configuration.setAttribute(ChromeRunDAPDebugDelegate.URL, urlText.getText()); configuration.setAttribute(AbstractHTMLDebugDelegate.PROGRAM, ""); } configuration.setAttribute(AbstractHTMLDebugDelegate.ARGUMENTS, this.argumentsText.getText()); String workingDirectory = this.workingDirectoryText.getText(); configuration.setAttribute(AbstractHTMLDebugDelegate.CWD, workingDirectory); configuration.setAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, workingDirectory); configuration.setMappedResources(ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new File(programPath).toURI())); }
Example 2
Source File: NpmLaunchTab.java From wildwebdeveloper with Eclipse Public License 2.0 | 6 votes |
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { String workingDirectory = pathOrEmpty(getSelectedProject()); if (this.packageJSONFile != null) { workingDirectory = pathOrEmpty(this.packageJSONFile.getParentFile()); } else if (defaultSelectedFile != null) { workingDirectory = pathOrEmpty(defaultSelectedFile.getParentFile()); } String programPath = this.programPathText.getText(); configuration.setAttribute(AbstractHTMLDebugDelegate.PROGRAM, programPath); configuration.setAttribute(AbstractHTMLDebugDelegate.ARGUMENTS, this.argumentsCombo.getText()); configuration.setAttribute(AbstractHTMLDebugDelegate.CWD, workingDirectory); configuration.setAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, workingDirectory); configuration.setMappedResources(ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new File(programPath).toURI())); }
Example 3
Source File: LaunchShortcut.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
private ILaunchConfiguration createConfiguration(IProject iProject) { ILaunchConfiguration config = null; try { XdsProjectConfiguration xdsProjectSettings = new XdsProjectConfiguration(iProject); ILaunchConfigurationType configType = getConfigurationType(LAUNCH_CONFIG_TYPE_ID); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(iProject.getName())); wc.setAttribute(ILaunchConfigConst.ATTR_PROJECT_NAME, iProject.getName()); wc.setAttribute(ILaunchConfigConst.ATTR_EXECUTABLE_PATH, xdsProjectSettings.getExePath()); wc.setAttribute(ILaunchConfigConst.ATTR_PROGRAM_ARGUMENTS, StringUtils.EMPTY); wc.setAttribute(ILaunchConfigConst.ATTR_DEBUGGER_ARGUMENTS, StringUtils.EMPTY); wc.setAttribute(ILaunchConfigConst.ATTR_SIMULATOR_ARGUMENTS, StringUtils.EMPTY); if (TextEncoding.isCodepageSupported(EncodingUtils.DOS_ENCODING)) { wc.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, EncodingUtils.DOS_ENCODING); } wc.setMappedResources(new IResource[] {iProject}); config = wc.doSave(); } catch (CoreException e) { MessageDialog.openError(getShell(), Messages.Common_Error, Messages.LaunchShortcut_CantCreateLaunchCfg + ": " + e); //$NON-NLS-1$ } return config; }
Example 4
Source File: GwtSuperDevModeCodeServerLaunchUtil.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
/** * Create a new GWT SDM Code Server Configuration. This will occur when running the debug * configuration from shortcut. */ public static ILaunchConfiguration createLaunchConfig(String launchConfigName, final IProject project) throws CoreException, OperationCanceledException { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(GwtSuperDevModeLaunchConfiguration.TYPE_ID); ILaunchConfigurationWorkingCopy launchConfig = type.newInstance(null, launchConfigName); // Project name LaunchConfigurationUtilities.setProjectName(launchConfig, project.getName()); launchConfig.setMappedResources(new IResource[] {project}); setDefaults(launchConfig, project); // Save the new launch configuration ILaunchConfiguration ilaunchConfig = launchConfig.doSave(); return ilaunchConfig; }
Example 5
Source File: CompilerLaunchShortcut.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
private ILaunchConfigurationWorkingCopy createLaunchConfigWorkingCopy(String launchConfigName, IProject project) throws CoreException { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(CompilerLaunchConfiguration.TYPE_ID); final ILaunchConfigurationWorkingCopy config = type.newInstance(null, launchConfigName); // Main type GWTLaunchConfigurationWorkingCopy.setMainType(config, GwtLaunchConfigurationProcessorUtilities.GWT_COMPILER); // project name LaunchConfigurationUtilities.setProjectName(config, project.getName()); // classpath config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, ModuleClasspathProvider.computeProviderId(project)); // Link the launch configuration to the project. // This will cause the launch config to be deleted automatically if the project is deleted. config.setMappedResources(new IResource[] { project }); // Modules LaunchConfigurationProcessorUtilities.updateViaProcessor(new ModuleArgumentProcessor(), config); return config; }
Example 6
Source File: WebAppMainTab.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 6 votes |
@Override public void doPerformApply(ILaunchConfigurationWorkingCopy configuration) { super.performApply(configuration); // Link the launch configuration to the project. This will cause the // launch config to be deleted automatically if the project is deleted. IProject project = getProjectNamed(getEnteredProjectName()); if (project != null) { configuration.setMappedResources(new IResource[] {project}); } try { saveLaunchConfiguration(configuration); } catch (CoreException e) { CorePluginLog.logError(e, "Could not update arguments to reflect main tab changes"); } }
Example 7
Source File: ProjectLaunchSettings.java From goclipse with Eclipse Public License 1.0 | 5 votes |
@Override public void saveToConfig(ILaunchConfigurationWorkingCopy config, boolean rename) throws CommonException { config.setAttribute(LaunchConstants.ATTR_PROJECT_NAME, projectName); config.setMappedResources(array(getProject())); if(rename) { String suggestedName = getSuggestedConfigName(); String newName = getLaunchManager().generateLaunchConfigurationName(suggestedName); config.rename(newName); } saveToConfig_rest(config); }
Example 8
Source File: AbstractDebugAdapterLaunchShortcut.java From wildwebdeveloper with Eclipse Public License 2.0 | 5 votes |
private ILaunchConfigurationWorkingCopy createNewLaunchConfiguration(File file) throws CoreException { String configName = launchManager.generateLaunchConfigurationName(file.getAbsolutePath()); ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, configName); wc.setAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, file.getParentFile().getAbsolutePath()); wc.setMappedResources(ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(file.toURI())); configureLaunchConfiguration(file, wc); return wc; }
Example 9
Source File: PythonFileRunner.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private static ILaunchConfigurationWorkingCopy getLaunchConfiguration(IFile resource, String programArguments) throws CoreException, MisconfigurationException, PythonNatureWithoutProjectException { String vmargs = ""; // Not sure if it should be a parameter or not IProject project = resource.getProject(); PythonNature nature = PythonNature.getPythonNature(project); ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager(); String launchConfigurationType = configurationFor(nature.getInterpreterType()); ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType); if (type == null) { throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Python launch configuration not found", null)); } String location = resource.getRawLocation().toString(); String name = manager.generateUniqueLaunchConfigurationNameFrom(resource.getName()); String baseDirectory = new File(location).getParent(); int resourceType = IResource.FILE; ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name); // Python Main Tab Arguments workingCopy.setAttribute(Constants.ATTR_PROJECT, project.getName()); workingCopy.setAttribute(Constants.ATTR_RESOURCE_TYPE, resourceType); workingCopy.setAttribute(Constants.ATTR_INTERPRETER, nature.getProjectInterpreter().getExecutableOrJar()); workingCopy.setAttribute(Constants.ATTR_LOCATION, location); workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY, baseDirectory); workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, programArguments); workingCopy.setAttribute(Constants.ATTR_VM_ARGUMENTS, vmargs); workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true); workingCopy.setMappedResources(new IResource[] { resource }); return workingCopy; }
Example 10
Source File: LaunchConfigurationConfigurator.java From sarl with Apache License 2.0 | 5 votes |
@Override public void detachResources(ILaunchConfigurationWorkingCopy configuration, IResource... resources) throws CoreException { final List<IResource> res = new ArrayList<>(); final IResource[] oldTab = configuration.getMappedResources(); if (oldTab != null) { res.addAll(Arrays.asList(oldTab)); } if (res.removeAll(Arrays.asList(resources))) { configuration.setMappedResources(res.toArray(new IResource[res.size()])); } }
Example 11
Source File: LaunchConfigurationConfigurator.java From sarl with Apache License 2.0 | 5 votes |
@Override public void attachResources(ILaunchConfigurationWorkingCopy configuration, IResource... resources) throws CoreException { final IResource[] oldTab = configuration.getMappedResources(); final IResource[] newTab; if (oldTab == null) { newTab = Arrays.copyOf(resources, resources.length); } else { newTab = Arrays.copyOf(oldTab, oldTab.length + resources.length); System.arraycopy(resources, 0, newTab, oldTab.length, resources.length); } configuration.setMappedResources(newTab); }
Example 12
Source File: LaunchConfigProviderPDETest.java From eclipse-extras with Eclipse Public License 1.0 | 5 votes |
private IResource createLaunchConfigForResource() throws CoreException { ILaunchConfigurationWorkingCopy launchConfig = launchConfigRule.createPublicLaunchConfig(); IFile resource = projectHelper.createFile(); launchConfig.setMappedResources( new IResource[] { resource } ); launchConfig.doSave(); return resource; }
Example 13
Source File: LocalAppEngineServerBehaviour.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override public void setupLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy, IProgressMonitor monitor) throws CoreException { super.setupLaunchConfiguration(workingCopy, monitor); // it seems surprising that the Server class doesn't already do this Collection<IProject> projects = new ArrayList<>(); for (IModule module : getServer().getModules()) { IProject project = module.getProject(); if (project != null) { projects.add(project); } } workingCopy.setMappedResources(projects.toArray(new IResource[projects.size()])); }
Example 14
Source File: RunProgramTab.java From wildwebdeveloper with Eclipse Public License 2.0 | 5 votes |
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { String programPath = this.programPathText.getText(); configuration.setAttribute(NodeRunDAPDebugDelegate.PROGRAM, programPath); configuration.setAttribute(NodeRunDAPDebugDelegate.ARGUMENTS, this.argumentsText.getText()); configuration.setAttribute(DebugPlugin.ATTR_WORKING_DIRECTORY, this.workingDirectoryText.getText()); configuration.setMappedResources(ResourcesPlugin.getWorkspace().getRoot().findFilesForLocationURI(new File(programPath).toURI())); }
Example 15
Source File: WebAppLaunchUtil.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 4 votes |
/** * Create a launch new configuration working copy. * * @param isGwtSuperDevModeEnabled will turn on GWT super dev mode. * @return ILaunchConfigurationWorkingCopy * @throws CoreException * @throws OperationCanceledException */ public static ILaunchConfigurationWorkingCopy createLaunchConfigWorkingCopy( String launchConfigName, final IProject project, String url, boolean isExternal, boolean isGwtSuperDevModeEnabled) throws CoreException, OperationCanceledException { assert (url != null); ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(WebAppLaunchConfiguration.TYPE_ID); final ILaunchConfigurationWorkingCopy wc = type.newInstance(null, launchConfigName); setDefaults(wc, project); LaunchConfigurationUtilities.setProjectName(wc, project.getName()); if (isExternal) { WebAppLaunchConfigurationWorkingCopy.setRunServer(wc, false); } GWTLaunchConfigurationWorkingCopy.setStartupUrl(wc, url); IPath warDir = null; if (WebAppUtilities.hasManagedWarOut(project)) { warDir = WebAppUtilities.getManagedWarOut(project).getLocation(); } if (warDir != null) { // The processor will update to the proper argument style for the current // project nature(s) WarArgumentProcessor warArgProcessor = new WarArgumentProcessor(); warArgProcessor.setWarDirFromLaunchConfigCreation(warDir.toOSString()); LaunchConfigurationProcessorUtilities.updateViaProcessor(warArgProcessor, wc); } // Link the launch configuration to the project. This will cause the // launch config to be deleted automatically if the project is deleted. wc.setMappedResources(new IResource[] {project}); // GWT SDM GWTLaunchConfigurationWorkingCopy.setSuperDevModeEnabled(wc, isGwtSuperDevModeEnabled); SuperDevModeArgumentProcessor sdmArgsProcessor = new SuperDevModeArgumentProcessor(); LaunchConfigurationProcessorUtilities.updateViaProcessor(sdmArgsProcessor, wc); return wc; }
Example 16
Source File: MainModuleBlock.java From Pydev with Eclipse Public License 1.0 | 4 votes |
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { String value = fMainModuleText.getText().trim(); setAttribute(configuration, Constants.ATTR_LOCATION, value); configuration.setMappedResources(getMainModuleResources()); }
Example 17
Source File: LaunchConfigurationCreator.java From Pydev with Eclipse Public License 1.0 | 4 votes |
/** * @param resource only used if captureOutput is true! * @param location only used if captureOutput is false! * @param captureOutput determines if the output should be captured or not (if captured a console will be * shown to it by default) */ private static ILaunchConfigurationWorkingCopy createDefaultLaunchConfiguration(FileOrResource[] resource, String launchConfigurationType, String location, IInterpreterManager pythonInterpreterManager, String projName, String vmargs, String programArguments, boolean captureOutput) throws CoreException { ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(launchConfigurationType); if (type == null) { throw new CoreException(PydevDebugPlugin.makeStatus(IStatus.ERROR, "Python launch configuration not found", null)); } IStringVariableManager varManager = VariablesPlugin.getDefault().getStringVariableManager(); String name; String baseDirectory; String moduleFile; int resourceType; if (captureOutput) { StringBuffer buffer = new StringBuffer(projName); buffer.append(" "); StringBuffer resourceNames = new StringBuffer(); for (FileOrResource r : resource) { if (resourceNames.length() > 0) { resourceNames.append(" - "); } if (r.resource != null) { resourceNames.append(r.resource.getName()); } else { resourceNames.append(r.file.getName()); } } buffer.append(resourceNames); name = buffer.toString().trim(); if (resource[0].resource != null) { // Build the working directory to a path relative to the workspace_loc baseDirectory = resource[0].resource.getFullPath().removeLastSegments(1).makeRelative().toString(); baseDirectory = varManager.generateVariableExpression("workspace_loc", baseDirectory); // Build the location to a path relative to the workspace_loc moduleFile = makeFileRelativeToWorkspace(resource, varManager); resourceType = resource[0].resource.getType(); } else { baseDirectory = FileUtils.getFileAbsolutePath(resource[0].file.getParentFile()); // Build the location to a path relative to the workspace_loc moduleFile = FileUtils.getFileAbsolutePath(resource[0].file); resourceType = IResource.FILE; } } else { captureOutput = true; name = location; baseDirectory = new File(location).getParent(); moduleFile = location; resourceType = IResource.FILE; } name = manager.generateLaunchConfigurationName(name); ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, name); // Python Main Tab Arguments workingCopy.setAttribute(Constants.ATTR_PROJECT, projName); workingCopy.setAttribute(Constants.ATTR_RESOURCE_TYPE, resourceType); workingCopy.setAttribute(Constants.ATTR_INTERPRETER, Constants.ATTR_INTERPRETER_DEFAULT); workingCopy.setAttribute(Constants.ATTR_LOCATION, moduleFile); workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY, baseDirectory); workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, programArguments); workingCopy.setAttribute(Constants.ATTR_VM_ARGUMENTS, vmargs); workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, captureOutput); workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, captureOutput); if (resource[0].resource != null) { workingCopy.setMappedResources(FileOrResource.createIResourceArray(resource)); } return workingCopy; }