Java Code Examples for org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#doSave()

The following examples show how to use org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#doSave() . 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: GhidraLaunchTabGroup.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/**
 * Gets the {@link CommonTab} to use, with the new launch configuration added to the favorites.
 * 
 * @return The {@link CommonTab} to use, with the new launch configuration added to the 
 *   favorites.
 */
private CommonTab getCommonTab() {
	return new CommonTab() {
		@Override
		public void initializeFrom(ILaunchConfiguration config) {
			try {
				ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
				GhidraLaunchUtils.setFavorites(wc);
				super.initializeFrom(wc.doSave());
			}
			catch (CoreException e) {
				EclipseMessageUtils.error("Failed to initialize the common tab.", e);
			}
		}
	};
}
 
Example 2
Source File: CordovaCLI.java    From thym with Eclipse Public License 1.0 6 votes vote down vote up
protected ILaunchConfiguration getLaunchConfiguration(String label){
	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType type = manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE);
	try {
		ILaunchConfiguration cfg = type.newInstance(null, "cordova");
		ILaunchConfigurationWorkingCopy wc = cfg.getWorkingCopy();
		wc.setAttribute(IProcess.ATTR_PROCESS_LABEL, label);
		if(additionalEnvProps != null && !additionalEnvProps.isEmpty()){
			wc.setAttribute(ILaunchManager.ATTR_ENVIRONMENT_VARIABLES,additionalEnvProps);
		}
		cfg = wc.doSave();
		return cfg;
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 3
Source File: NodeJSDebugLauncher.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
private IStatus launchInternalDebugSession(CodewindEclipseApplication app, PortForwardInfo pfInfo, IProgressMonitor monitor) {
	try {
		ILaunchConfigurationWorkingCopy workingCopy = getLaunchConfigType().get().newInstance((IContainer) null, app.name);
		workingCopy.setAttribute(ADDRESS_ATTR, app.getDebugConnectHost());
		workingCopy.setAttribute(PORT_ATTR, app.getDebugConnectPort());
		workingCopy.setAttribute(LOCAL_ROOT_ATTR, app.fullLocalPath.toOSString());
		workingCopy.setAttribute(REMOTE_ROOT_ATTR, app.getContainerAppRoot() == null ? "/app" : app.getContainerAppRoot());
		CodewindLaunchConfigDelegate.setConfigAttributes(workingCopy, app);
		ILaunchConfiguration launchConfig = workingCopy.doSave();
		ILaunch launch = launchConfig.launch(ILaunchManager.DEBUG_MODE, monitor);
		if (pfInfo != null && pfInfo.process != null) {
			Map<String, String> attributes = new HashMap<String, String>();
			attributes.put(IProcess.ATTR_PROCESS_TYPE, "codewind.utility");
			String title = NLS.bind(Messages.PortForwardTitle, pfInfo.localPort + ":" + app.getContainerDebugPort());
			launch.addProcess(new RuntimeProcess(launch, pfInfo.process, title, attributes));
			RemoteLaunchConfigDelegate.addDebugEventListener(launch);
		}
		app.setLaunch(launch);
	} catch (CoreException e) {
		return e.getStatus();
	}
	return Status.OK_STATUS;
}
 
Example 4
Source File: LaunchConfigurationUpdater.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Updates the launch configuration by delegating to each
 * {@link ILaunchConfigurationProcessor}.
 * <p>
 * This method saves the launch configuration's working copy.
 *
 * @throws CoreException
 */
public void update() throws CoreException {
  ILaunchConfigurationWorkingCopy launchConfigWc = launchConfig.getWorkingCopy();

  for (ILaunchConfigurationProcessor processor : PROCESSORS) {
    try {
      processor.update(launchConfigWc, javaProject, programArgs, vmArgs);
    } catch (Throwable e) {
      GdtPlugin.getLogger().logError(e, "Launch configuration processor failed to run");
    }
  }

  launchConfigWc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS,
      LaunchConfigurationProcessorUtilities.createArgsString(programArgs));
  launchConfigWc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
      LaunchConfigurationProcessorUtilities.createArgsString(vmArgs));

  launchConfigWc.doSave();
}
 
Example 5
Source File: AppEngineLaunchShortcut.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * The only thing different is that we have to override the creation of the default launch configuration.
 */
@Override
public ILaunchConfiguration createDefaultLaunchConfiguration(FileOrResource[] resources) {

    try {
        ILaunchConfigurationWorkingCopy workingCopy = super
                .createDefaultLaunchConfigurationWithoutSaving(resources);

        String mainDir = workingCopy.getAttribute(Constants.ATTR_LOCATION, "");

        //dev_appserver.py [options] <application root>
        workingCopy.setAttribute(Constants.ATTR_LOCATION, "${GOOGLE_APP_ENGINE}/dev_appserver.py");
        workingCopy.setAttribute(Constants.ATTR_PROGRAM_ARGUMENTS, "\"" + mainDir + "\"");

        return workingCopy.doSave();
    } catch (CoreException e) {
        reportError(null, e);
        return null;
    }
}
 
Example 6
Source File: RunConfigurationConverter.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Converts a {@link RunConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in
 * case of error.
 *
 * @see RunConfiguration#readPersistentValues()
 */
public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, RunConfiguration runConfig) {
	try {
		final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager()
				.getLaunchConfigurations(type);

		for (ILaunchConfiguration config : configs) {
			if (equals(runConfig, config))
				return config;
		}

		final IContainer container = null;
		final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, runConfig.getName());

		workingCopy.setAttributes(runConfig.readPersistentValues());

		return workingCopy.doSave();
	} catch (Exception e) {
		throw new WrappedException("could not convert N4JS RunConfiguration to Eclipse ILaunchConfiguration", e);
	}
}
 
Example 7
Source File: WebAppProjectCreator.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
protected void createLaunchConfig(IProject project) throws CoreException {
  // If the default SDK is GWT 2.7 or greater, turn on GWT super dev mode by default.
  boolean turnOnGwtSuperDevMode = GwtVersionUtil.isGwtVersionGreaterOrEqualTo27(JavaCore.create(project));

  ILaunchConfigurationWorkingCopy wc = WebAppLaunchUtil.createLaunchConfigWorkingCopy(project.getName(), project,
      WebAppLaunchUtil.determineStartupURL(project, false), false, turnOnGwtSuperDevMode);
  ILaunchGroup[] groups = DebugUITools.getLaunchGroups();

  ArrayList<String> groupsNames = new ArrayList<String>();
  for (ILaunchGroup group : groups) {
    if (IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP.equals(group.getIdentifier())
        || IDebugUIConstants.ID_RUN_LAUNCH_GROUP.equals(group.getIdentifier())) {
      groupsNames.add(group.getIdentifier());
    }
  }

  wc.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, groupsNames);
  wc.doSave();
}
 
Example 8
Source File: ScriptLaunchShortcut.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param fileName
 * @return
 */
protected static ILaunchConfiguration createConfiguration( String fileName )
{
	// String fileName = input.getPath( ).toOSString( );
	// int index = fileName.indexOf( File.separator );
	String name = "New_configuration";//$NON-NLS-1$

	name = DebugPlugin.getDefault( )
			.getLaunchManager( )
			.generateUniqueLaunchConfigurationNameFrom( name );
	ILaunchConfiguration config = null;
	ILaunchConfigurationWorkingCopy wc = null;
	try
	{
		ILaunchConfigurationType configType = getConfigurationType( );
		wc = configType.newInstance( null,
				getLaunchManager( ).generateUniqueLaunchConfigurationNameFrom( name ) );
		wc.setAttribute( IReportLaunchConstants.ATTR_REPORT_FILE_NAME,
				fileName );

		config = wc.doSave( );
	}
	catch ( CoreException exception )
	{
		logger.warning( exception.getMessage( ) );
	}
	return config;
}
 
Example 9
Source File: ProjectLaunchSettings.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
public ILaunchConfiguration createNewConfiguration(ILaunchConfigurationType launchCfgType) 
		throws CoreException, CommonException {
	String suggestedName = getSuggestedConfigName();
	
	String launchName = getLaunchManager().generateLaunchConfigurationName(suggestedName);
	ILaunchConfigurationWorkingCopy wc = launchCfgType.newInstance(null, launchName);
	
	saveToConfig(wc);
	return wc.doSave();
}
 
Example 10
Source File: LaunchConfigSelectionHistoryPDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testGetHistoryItemsAfterRenamingLaunchConfig() throws CoreException {
  runLaunchConfig();
  ILaunchConfigurationWorkingCopy workingCopy = launchConfig.getWorkingCopy();
  workingCopy.rename( launchConfig.getName() + "-renamed" );
  ILaunchConfiguration renamedLaunchConfig = workingCopy.doSave();

  Object[] historyItems = history.getHistoryItems();

  assertThat( historyItems ).containsOnly( renamedLaunchConfig );
}
 
Example 11
Source File: AbstractLaunchShortcut.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public ILaunchConfiguration createDefaultLaunchConfiguration(FileOrResource[] resource) {
    try {
        ILaunchConfigurationWorkingCopy createdConfiguration = createDefaultLaunchConfigurationWithoutSaving(resource);
        if (createdConfiguration == null) {
            return null;
        }
        return createdConfiguration.doSave();
    } catch (CoreException e) {
        reportError(null, e);
        return null;
    }
}
 
Example 12
Source File: BOSWebServerManager.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected ILaunchConfiguration configureLaunchConfiguration(ILaunchConfigurationWorkingCopy workingCopy)
        throws CoreException {
    final RepositoryAccessor repositoryAccessor = new RepositoryAccessor();
    repositoryAccessor.init();

    workingCopy.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS,
            getTomcatVMArgsBuilder(repositoryAccessor, EnginePlugin.getDefault().getPreferenceStore())
                    .getVMArgs(bundleLocation));
    workingCopy.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_FILE,
            getTomcatLogFile());
    workingCopy.setAttribute(IDebugUIConstants.ATTR_APPEND_TO_FILE, true);
    workingCopy.setAttribute(DebugPlugin.ATTR_CONSOLE_ENCODING, "UTF-8");
    return workingCopy.doSave();
}
 
Example 13
Source File: CompilerLaunchShortcut.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private ILaunchConfiguration createNewLaunchConfiguration(IResource resource)
    throws CoreException, OperationCanceledException {
  String initialName = resource.getProject().getName();

  ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
  String launchConfigName = manager.generateLaunchConfigurationName(initialName);
  IProject project = resource.getProject();

  ILaunchConfigurationWorkingCopy wc = createLaunchConfigWorkingCopy(launchConfigName, project);

  ILaunchConfiguration toReturn = wc.doSave();

  return toReturn;
}
 
Example 14
Source File: WebAppLaunchShortcut.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Turn on GWT Super Dev Mode in the case that dev mode was run first. This depends on which shortcut was used.
 *
 * @param isGwtSuperDevModeEnabled
 */
private ILaunchConfiguration turnOnOrOffSuperDevMode(ILaunchConfiguration config, boolean isGwtSuperDevModeEnabled)
    throws CoreException {
  ILaunchConfigurationWorkingCopy workingCopy = config.getWorkingCopy();

  GWTLaunchConfigurationWorkingCopy.setSuperDevModeEnabled(workingCopy, isGwtSuperDevModeEnabled);
  SuperDevModeArgumentProcessor sdmArgsProcessor = new SuperDevModeArgumentProcessor();
  LaunchConfigurationProcessorUtilities.updateViaProcessor(sdmArgsProcessor, workingCopy);
  workingCopy.doSave();

  return workingCopy;
}
 
Example 15
Source File: PythonRunner.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * The debug plugin needs to be notified about our process.
 * It'll then display the appropriate UI.
 */
private static IProcess registerWithDebugPluginForProcessType(String label, ILaunch launch, Process p,
        Map<String, String> processAttributes, PythonRunnerConfig config) {
    processAttributes.put(IProcess.ATTR_PROCESS_TYPE, config.getProcessType());
    processAttributes.put(IProcess.ATTR_PROCESS_LABEL, label);
    processAttributes.put(Constants.PYDEV_CONFIG_RUN, config.run);
    processAttributes.put(IMiscConstants.PYDEV_ADD_RELAUNCH_IPROCESS_ATTR,
            IMiscConstants.PYDEV_ADD_RELAUNCH_IPROCESS_ATTR_TRUE);
    processAttributes.put(DebugPlugin.ATTR_CAPTURE_OUTPUT, "true");

    ILaunchConfiguration launchConfiguration = launch.getLaunchConfiguration();
    boolean found = false;
    try {
        String attribute = launchConfiguration.getAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, (String) null);
        found = PyProcessFactory.PROCESS_FACTORY_ID.equals(attribute);
    } catch (CoreException e1) {
        Log.log(e1);
    }
    if (!found) {
        try {
            ILaunchConfigurationWorkingCopy workingCopy = launchConfiguration.getWorkingCopy();
            workingCopy.setAttribute(DebugPlugin.ATTR_PROCESS_FACTORY_ID, PyProcessFactory.PROCESS_FACTORY_ID);
            workingCopy.doSave();
        } catch (CoreException e) {
            Log.log(e);
        }
    }

    return DebugPlugin.newProcess(launch, p, label, processAttributes);
}
 
Example 16
Source File: LaunchConfigurationConfigurator.java    From sarl with Apache License 2.0 5 votes vote down vote up
@Override
public ILaunchConfiguration newApplicationLaunchConfiguration(String projectName, String launchConfigurationName,
		String fullyQualifiedNameOfClass, Class<? extends IRuntimeClasspathProvider> classPathProvider) throws CoreException {
	final String name = Strings.isNullOrEmpty(launchConfigurationName)
			? simpleName(fullyQualifiedNameOfClass) : launchConfigurationName;
	final ILaunchConfigurationWorkingCopy wc = initLaunchConfiguration(getApplicationLaunchConfigurationType(), projectName,
			name, false);
	setMainJavaClass(wc, fullyQualifiedNameOfClass);
	if (classPathProvider != null) {
		wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, classPathProvider.getName());
	}
	return wc.doSave();
}
 
Example 17
Source File: LaunchShortcut.java    From dartboard with Eclipse Public License 2.0 5 votes vote down vote up
private void launchProject(IProject project, String mode) {
	if (project == null) {
		MessageDialog.openError(PlatformUIUtil.getActiveShell(), Messages.Launch_ConfigurationRequired_Title,
				Messages.Launch_ConfigurationRequired_Body);
		return;
	}

	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();

	ILaunchConfigurationType type = manager.getLaunchConfigurationType(Constants.LAUNCH_CONFIGURATION_ID);

	try {
		// Find last launch configuration for selected project.
		ILaunchConfiguration launchConfiguration = null;
		for (ILaunchConfiguration conf : manager.getLaunchConfigurations(type)) {
			if (conf.getAttribute(Constants.LAUNCH_SELECTED_PROJECT, "").equalsIgnoreCase(project.getName())) { //$NON-NLS-1$
				launchConfiguration = conf;
			}
		}

		if (launchConfiguration != null) {
			DebugUITools.launch(launchConfiguration, mode);
		} else {
			ILaunchConfigurationWorkingCopy copy = type.newInstance(null, manager.generateLaunchConfigurationName(
					LaunchConfigurationsMessages.CreateLaunchConfigurationAction_New_configuration_2));

			copy.setAttribute(Constants.LAUNCH_SELECTED_PROJECT, project.getName());
			copy.setAttribute(Constants.LAUNCH_MAIN_CLASS, project.getPersistentProperty(StagehandGenerator.QN_ENTRYPOINT));

			int result = DebugUITools.openLaunchConfigurationDialog(PlatformUIUtil.getActiveShell(), copy,
					Constants.LAUNCH_GROUP, null);

			if (result == Window.OK) {
				copy.doSave();
			}
		}
	} catch (CoreException e) {
		LOG.log(DartLog.createError("Could not save new launch configuration", e)); //$NON-NLS-1$
	}
}
 
Example 18
Source File: LaunchConfigProviderPDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
private IResource createLaunchConfigForResource() throws CoreException {
  ILaunchConfigurationWorkingCopy launchConfig = launchConfigRule.createPublicLaunchConfig();
  IFile resource = projectHelper.createFile();
  launchConfig.setMappedResources( new IResource[] { resource } );
  launchConfig.doSave();
  return resource;
}
 
Example 19
Source File: LaunchConfigComparatorPDETest.java    From eclipse-extras with Eclipse Public License 1.0 4 votes vote down vote up
private void renameLaunchConfig1( String name ) throws CoreException {
  ILaunchConfigurationWorkingCopy workingCopy = launchConfig1.getWorkingCopy();
  workingCopy.rename( name );
  launchConfig1 = workingCopy.doSave();
}
 
Example 20
Source File: LaunchConfigLabelProviderPDETest.java    From eclipse-extras with Eclipse Public License 1.0 4 votes vote down vote up
private void saveToContainer( ILaunchConfigurationWorkingCopy launchConfig ) throws CoreException {
  launchConfig.setContainer( projectHelper.getProject() );
  launchConfig.doSave();
}