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

The following examples show how to use org.eclipse.debug.core.ILaunchConfigurationWorkingCopy#rename() . 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: SARLAgentMainLaunchConfigurationTab.java    From sarl with Apache License 2.0 6 votes vote down vote up
/**
 * Reset the given configuration with the agent name attributes associated
 * to the given element.
 *
 * @param javaElement the element from which information may be retrieved.
 * @param config the config to set with the agent name.
 */
protected void initializeAgentName(IJavaElement javaElement, ILaunchConfigurationWorkingCopy config) {
	String name = extractNameFromJavaElement(javaElement);

	// Set the attribute
	this.configurator.setAgent(config, name);

	// Rename the launch configuration
	if (name.length() > 0) {
		final int index = name.lastIndexOf('.');
		if (index > 0) {
			name = name.substring(index + 1);
		}
		name = getLaunchConfigurationDialog().generateName(name);
		config.rename(name);
	}
}
 
Example 2
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 3
Source File: LaunchConfigRule.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
public String renameLaunchConfig( ILaunchConfiguration launchConfig ) throws CoreException {
  String newName = launchConfig.getName() + "-renamed";
  if( launchManager.isExistingLaunchConfigurationName( newName ) ) {
    newName = launchManager.generateLaunchConfigurationName( newName );
  }
  ILaunchConfigurationWorkingCopy workingCopy = launchConfig.getWorkingCopy();
  workingCopy.rename( newName );
  workingCopy.doSave();
  return newName;
}
 
Example 4
Source File: GWTJUnitLaunchShortcut.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(
    IJavaElement element) throws CoreException {
  ILaunchConfigurationWorkingCopy wc = super.createLaunchConfiguration(element);

  wc.rename(getDecoratedName(wc.getName()));

  GWTJUnitLaunchUtils.setDefaults(wc);
  return wc;
}
 
Example 5
Source File: ProjectLaunchSettings.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
@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 6
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 7
Source File: LaunchConfigComparatorPDETest.java    From eclipse-extras with Eclipse Public License 1.0 4 votes vote down vote up
private void renameLaunchConfig2( String name ) throws CoreException {
  ILaunchConfigurationWorkingCopy workingCopy = launchConfig2.getWorkingCopy();
  workingCopy.rename( name );
  launchConfig2 = workingCopy.doSave();
}
 
Example 8
Source File: RunEditorAsCustomUnitTestAction.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public ILaunchConfigurationWorkingCopy createDefaultLaunchConfigurationWithoutSaving(
        FileOrResource[] resource) throws CoreException {
    ILaunchConfigurationWorkingCopy workingCopy = super.createDefaultLaunchConfigurationWithoutSaving(
            resource);
    if (arguments.trim().length() > 0) {
        // first remember the arguments to be used internally and for matching
        workingCopy.setAttribute(Constants.ATTR_UNITTEST_TESTS, arguments);
        // then determine the tests to be displayed to user
        String[] argumentsSplit = arguments.split(",");
        FastStringBuffer argsWithTests = new FastStringBuffer(workingCopy.getName(),
                arguments.length() + 10);
        argsWithTests.append(" ( ");
        for (int i = 0; i < argumentsSplit.length; i++) {
            if (i != 0) {
                argsWithTests.append(", ");
            }
            // Note that there are no fixed limits below, but in the worst case it should be close to 150 chars -- i.e.: (100 + 35 + len(" and xxx more") 13 + 2)
            String str = argumentsSplit[i];
            if (str.length() > 35) {
                argsWithTests.append(str.substring(0, 30));
                argsWithTests.append(" ... ");
            } else {
                argsWithTests.append(str);
            }
            if (argsWithTests.length() > 100) {
                argsWithTests.append(" and " + (argumentsSplit.length - (i + 1)) + " more");
                break;
            }
        }
        argsWithTests.append(" )");

        // then rename it to include the tests in the name
        // but first make sure the name is unique, as otherwise
        // configurations could get overwritten

        ILaunchManager manager = org.eclipse.debug.core.DebugPlugin.getDefault().getLaunchManager();
        workingCopy.rename(manager.generateLaunchConfigurationName(argsWithTests.toString()));
        return workingCopy;
    }
    return workingCopy;
}