org.eclipse.debug.core.ILaunchConfigurationType Java Examples

The following examples show how to use org.eclipse.debug.core.ILaunchConfigurationType. 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: LaunchHandler.java    From corrosion with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Looks up an existing cargo test launch configuration with the arguments
 * specified in {@code command} for the given {@code project}. If no such launch
 * configuration exists, creates a new one. The launch configuration is then
 * run.
 *
 * @param command rls.run command with all information needed to run cargo test
 * @param project the context project for which the launch configuration is
 *                looked up / created
 */
private static void createAndStartCargoTest(RLSRunCommand command, IProject project) {
	CargoArgs args = CargoArgs.fromAllArguments(command.args);
	Map<String, String> envMap = command.env;

	ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType type = manager
			.getLaunchConfigurationType(CargoTestDelegate.CARGO_TEST_LAUNCH_CONFIG_TYPE_ID);
	try {
		// check if launch config already exists
		ILaunchConfiguration[] launchConfigurations = manager.getLaunchConfigurations(type);

		Set<Entry<String, String>> envMapEntries = envMap.entrySet();
		// prefer running existing launch configuration with same parameters
		ILaunchConfiguration launchConfig = Arrays.stream(launchConfigurations)
				.filter((l) -> matchesTestLaunchConfig(l, project, args, envMapEntries)).findAny()
				.orElseGet(() -> createCargoLaunchConfig(manager, type, project, args, envMap));

		if (launchConfig != null) {
			DebugUITools.launch(launchConfig, ILaunchManager.RUN_MODE);
		}
	} catch (CoreException e) {
		CorrosionPlugin.logError(e);
	}
}
 
Example #2
Source File: WebAppLaunchUtil.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public static ILaunchConfiguration findConfigurationByName(String name) {
  try {
    String configTypeStr = WebAppLaunchConfiguration.TYPE_ID;
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType typeid = launchManager.getLaunchConfigurationType(configTypeStr);
    ILaunchConfiguration[] configs = launchManager.getLaunchConfigurations(typeid);

    for (ILaunchConfiguration config : configs) {
      if (config.getName().equals(name)) {
        return config;
      }
    }
  } catch (CoreException e) {
    CorePluginLog.logError(e);
  }
  return null;
}
 
Example #3
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 #4
Source File: AbstractSarlLaunchShortcut.java    From sarl with Apache License 2.0 6 votes vote down vote up
/** Collect the listing of {@link ILaunchConfiguration}s that apply to the given element.
 *
 * @param projectName the name of the project.
 * @param fullyQualifiedName the element.
 * @return the list of {@link ILaunchConfiguration}s or an empty list, never {@code null}
 * @throws CoreException if something is going wrong.
 */
protected List<ILaunchConfiguration> getCandidates(String projectName,
		String fullyQualifiedName) throws CoreException {
	final ILaunchConfigurationType ctype = getLaunchManager().getLaunchConfigurationType(getConfigurationType());
	List<ILaunchConfiguration> candidateConfigs = Collections.emptyList();
	final ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(ctype);
	candidateConfigs = new ArrayList<>(configs.length);
	for (int i = 0; i < configs.length; i++) {
		final ILaunchConfiguration config = configs[i];
		if (Objects.equals(
				getElementQualifiedName(config),
				fullyQualifiedName)
				&& Objects.equals(
						config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""), //$NON-NLS-1$
						projectName)) {
			candidateConfigs.add(config);
		}
	}
	return candidateConfigs;
}
 
Example #5
Source File: OtherUtil.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
public static ILaunch startDiagnostics(String connectionName, String conid, boolean includeEclipseWorkspace, boolean includeProjectInfo, IProgressMonitor monitor) throws IOException, CoreException {
	List<String> options = new ArrayList<String>();
	options.add(CLIUtil.CON_ID_OPTION);
	options.add(conid);
	if (includeEclipseWorkspace) {
		options.add(ECLIPSE_WORKSPACE_OPTION);
		options.add(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
	}
	if (includeProjectInfo) {
		options.add(PROJECTS_OPTION);
	}
	List<String> command = CLIUtil.getCWCTLCommandList(null, DIAGNOSTICS_COLLECT_CMD, options.toArray(new String[options.size()]), null);
	
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(UtilityLaunchConfigDelegate.LAUNCH_CONFIG_ID);
	ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance((IContainer) null, connectionName);
	workingCopy.setAttribute(UtilityLaunchConfigDelegate.TITLE_ATTR, Messages.UtilGenDiagnosticsTitle);
	workingCopy.setAttribute(UtilityLaunchConfigDelegate.COMMAND_ATTR, command);
	ILaunchConfiguration launchConfig = workingCopy.doSave();
	return launchConfig.launch(ILaunchManager.RUN_MODE, monitor);
}
 
Example #6
Source File: AbstractRunnerLaunchShortcut.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Launch a file, using the file information, which means using default launch configurations.
 */
protected void launchFile(IFile originalFileToRun, String mode) {
	final String runnerId = getRunnerId();
	final String path = originalFileToRun.getFullPath().toOSString();
	final URI moduleToRun = URI.createPlatformResourceURI(path, true);

	final String implementationId = chooseImplHelper.chooseImplementationIfRequired(runnerId, moduleToRun);
	if (implementationId == ChooseImplementationHelper.CANCEL)
		return;

	RunConfiguration runConfig = runnerFrontEnd.createConfiguration(runnerId,
			implementationId != null ? new N4JSProjectName(implementationId) : null,
			moduleToRun);

	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(getLaunchConfigTypeID());
	DebugUITools.launch(runConfigConverter.toLaunchConfiguration(type, runConfig), mode);
	// execution dispatched to proper delegate LaunchConfigurationDelegate
}
 
Example #7
Source File: RunnerUiUtils.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Read the N4JS runner ID from the given Eclipse launch configuration. Will throw exceptions if 'failFast' is
 * <code>true</code>, otherwise will return <code>null</code> in case of error.
 */
public static String getRunnerId(ILaunchConfiguration launchConfig, boolean failFast) {
	try {
		// 1) simple case: runnerId already defined in launchConfig
		final String id = launchConfig.getAttribute(RunConfiguration.RUNNER_ID, (String) null);
		if (id != null)
			return id;
		// 2) tricky case: not set yet, so have to go via the ILaunchConfigurationType or the launchConfig
		final ILaunchConfigurationType launchConfigType = launchConfig.getType();
		return getRunnerId(launchConfigType, failFast);
	} catch (CoreException e) {
		if (failFast)
			throw new WrappedException(e);
		return null;
	}
}
 
Example #8
Source File: TestabilityLaunchConfigurationHelper.java    From testability-explorer with Apache License 2.0 6 votes vote down vote up
public ILaunchConfiguration getLaunchConfiguration(String projectName) {
  try {
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    ILaunchConfigurationType type = launchManager
        .getLaunchConfigurationType(TestabilityConstants.TESTABILITY_LAUNCH_CONFIGURATION_TYPE);
    ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(type);
    for (ILaunchConfiguration launchConfiguration : launchConfigurations) {
      String configProjectName =
          launchConfiguration.getAttribute(TestabilityConstants.CONFIGURATION_ATTR_PROJECT_NAME,
              "");
      if (configProjectName.equals(projectName)
          && isValidToRun(projectName, launchConfiguration)) {
        return launchConfiguration;
      }
    }
  } catch (CoreException e) {
    logger.logException(e);
  }
  return null;
}
 
Example #9
Source File: RustLaunchDelegateTools.java    From corrosion with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Finds or creates a new launch configuration that matches the given search
 * terms
 *
 * @param resource
 * @param launchConfigurationType
 * @return The matching launch configuration or a new launch configuration
 *         working copy or null if unable to make a new one
 */
public static ILaunchConfiguration getLaunchConfiguration(IResource resource, String launchConfigurationType) {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType(launchConfigurationType);
	try {
		ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(configType);
		final String projectName = resource.getProject().getName();
		String launchConfigProjectAttribute;
		if (launchConfigurationType.equals(CORROSION_DEBUG_LAUNCH_CONFIG_TYPE)) {
			launchConfigProjectAttribute = ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME;
		} else {
			launchConfigProjectAttribute = RustLaunchDelegateTools.PROJECT_ATTRIBUTE;
		}
		for (ILaunchConfiguration iLaunchConfiguration : launchConfigurations) {
			if (iLaunchConfiguration.getAttribute(launchConfigProjectAttribute, "") //$NON-NLS-1$
					.equals(projectName)) {
				return iLaunchConfiguration;
			}
		}
		String configName = launchManager.generateLaunchConfigurationName(projectName);
		return configType.newInstance(null, configName);
	} catch (CoreException e) {
		CorrosionPlugin.logError(e);
	}
	return null;
}
 
Example #10
Source File: FlexMavenPackagedProjectStagingDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
static ILaunchConfiguration createMavenPackagingLaunchConfiguration(IProject project)
    throws CoreException {
  ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
  ILaunchConfigurationType launchConfigurationType = launchManager
      .getLaunchConfigurationType(MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);

  String launchConfigName = "CT4E App Engine flexible Maven deploy artifact packaging "
      + project.getLocation().toString().replaceAll("[^a-zA-Z0-9]", "_");

  ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance(
      null /*container*/, launchConfigName);
  workingCopy.setAttribute(ILaunchManager.ATTR_PRIVATE, true);
  // IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND;
  workingCopy.setAttribute("org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND", true);
  workingCopy.setAttribute(MavenLaunchConstants.ATTR_POM_DIR, project.getLocation().toString());
  workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, "package");
  workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_SCOPE, "${project}");
  workingCopy.setAttribute(RefreshUtil.ATTR_REFRESH_RECURSIVE, true);

  IPath jreContainerPath = getJreContainerPath(project);
  workingCopy.setAttribute(
      IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, jreContainerPath.toString());

  return workingCopy;
}
 
Example #11
Source File: LocalAppEngineServerLaunchConfigurationDelegate.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
@VisibleForTesting
void checkConflictingLaunches(ILaunchConfigurationType launchConfigType, String mode,
    RunConfiguration runConfig, ILaunch[] launches) throws CoreException {

  for (ILaunch launch : launches) {
    if (launch.isTerminated()
        || launch.getLaunchConfiguration() == null
        || launch.getLaunchConfiguration().getType() != launchConfigType) {
      continue;
    }
    IServer otherServer = ServerUtil.getServer(launch.getLaunchConfiguration());
    List<Path> paths = new ArrayList<>();
    RunConfiguration otherRunConfig =
        generateServerRunConfiguration(launch.getLaunchConfiguration(), otherServer, mode, paths);
    IStatus conflicts = checkConflicts(runConfig, otherRunConfig,
        new MultiStatus(Activator.PLUGIN_ID, 0,
            Messages.getString("conflicts.with.running.server", otherServer.getName()), //$NON-NLS-1$
            null));
    if (!conflicts.isOK()) {
      throw new CoreException(StatusUtil.filter(conflicts));
    }
  }
}
 
Example #12
Source File: FatJarPackageWizardPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private LaunchConfigurationElement[] getLaunchConfigurations() {
	ArrayList<ExistingLaunchConfigurationElement> result= new ArrayList<ExistingLaunchConfigurationElement>();

	try {
		ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager();
		ILaunchConfigurationType type= manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION);
		ILaunchConfiguration[] launchconfigs= manager.getLaunchConfigurations(type);

		for (int i= 0; i < launchconfigs.length; i++) {
			ILaunchConfiguration launchconfig= launchconfigs[i];
			if (!launchconfig.getAttribute(IDebugUIConstants.ATTR_PRIVATE, false)) {
				String projectName= launchconfig.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, ""); //$NON-NLS-1$
				result.add(new ExistingLaunchConfigurationElement(launchconfig, projectName));
			}
		}
	} catch (CoreException e) {
		JavaPlugin.log(e);
	}

	return result.toArray(new LaunchConfigurationElement[result.size()]);
}
 
Example #13
Source File: BuildUtils.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 6 votes vote down vote up
/**
 * Creates an ant build configuration {@link ILaunchConfiguration}
 * 
 * @param configName
 *            name of the configuration to be created
 * @param targets
 *            ant targets to be called
 * @param buildPath
 *            path to build.xml file
 * @param projectName
 *            name of the projects
 * @return ant build configuration
 */
private static ILaunchConfiguration createAntBuildConfig(String configName, String targets, String buildPath,
		String projectName) throws CoreException {
	ILaunchConfiguration launchCfg;
	ILaunchConfigurationType type = DebugPlugin.getDefault().getLaunchManager()
			.getLaunchConfigurationType("org.eclipse.ant.AntLaunchConfigurationType");
	ILaunchConfigurationWorkingCopy config = null;
	config = type.newInstance(null, configName);
	config.setAttribute("org.eclipse.ui.externaltools.ATTR_ANT_TARGETS", targets);
	config.setAttribute("org.eclipse.ui.externaltools.ATTR_CAPTURE_OUTPUT", true);
	config.setAttribute("org.eclipse.ui.externaltools.ATTR_LOCATION", buildPath);
	config.setAttribute("org.eclipse.ui.externaltools.ATTR_SHOW_CONSOLE", true);
	config.setAttribute("org.eclipse.ui.externaltools.ATTR_ANT_PROPERTIES", Collections.<String, String>emptyMap());
	config.setAttribute("org.eclipse.ant.ui.DEFAULT_VM_INSTALL", true);
	config.setAttribute("org.eclipse.jdt.launching.MAIN_TYPE",
			"org.eclipse.ant.internal.launching.remote.InternalAntRunner");
	config.setAttribute("org.eclipse.jdt.launching.PROJECT_ATTR", projectName);
	config.setAttribute("org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER",
			"org.eclipse.ant.ui.AntClasspathProvider");
	config.setAttribute("process_factory_id", "org.eclipse.ant.ui.remoteAntProcessFactory");
	if (configName.equals(PLATFORM_BUILD_CONFIG) || configName.equals(PLATFORM_CLEAN_BUILD_CONFIG)) {
		config.setAttribute("org.eclipse.debug.core.ATTR_REFRESH_SCOPE", "${workspace}");
	}
	launchCfg = config.doSave();
	return launchCfg;
}
 
Example #14
Source File: Model.java    From tlaplus with MIT License 6 votes vote down vote up
public Model copyIntoForeignSpec(final Spec foreignSpec, final String newModelName) {
	final IProject foreignProject = foreignSpec.getProject();
	final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	final ILaunchConfigurationType launchConfigurationType
			= launchManager.getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE);
	final String sanitizedNewName = sanitizeName(newModelName);
	final String wholeName = fullyQualifiedNameFromSpecNameAndModelName(foreignSpec.getName(), sanitizedNewName);
	
	try {
		final ILaunchConfigurationWorkingCopy copy = launchConfigurationType.newInstance(foreignProject, wholeName);
		copyAttributesFromForeignModelToWorkingCopy(this, copy);
        copy.setAttribute(IConfigurationConstants.SPEC_NAME, foreignSpec.getName());
           copy.setAttribute(IConfigurationConstants.MODEL_NAME, sanitizedNewName);
           return copy.doSave().getAdapter(Model.class);
	} catch (CoreException e) {
		TLCActivator.logError("Error cloning foreign model.", e);
		return null;
	}
}
 
Example #15
Source File: LaunchShortcut.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Resolves a type that can be launched from the given scope and launches in the
 * specified mode.
 * 
 * @param scope the XDS elements to consider for a type that can be launched
 * @param mode launch mode
 * @param emptyMessage error message when no types are resolved for launching
 */
private void searchAndLaunch(Object[] scope, String mode, String emptyMessage) {
	IProject xdsProject = selectXdsProject(scope, emptyMessage);
	if (xdsProject != null) {
		ILaunchConfigurationType launchConfigType = getConfigurationType(LAUNCH_CONFIG_TYPE_ID);
           List<ILaunchConfiguration> configs = getLaunchConfigurations(xdsProject, launchConfigType).collect(Collectors.toList());
           ILaunchConfiguration config = null;
           if (!configs.isEmpty()) {
           	config = selectConfiguration(configs);
           	if (config == null) {
           		return;
           	}
           }
           if (config == null) {
           	config = createConfiguration(xdsProject);
           }
           if (config != null) {
               DebugUITools.launch(config, mode);
           }
	}
}
 
Example #16
Source File: LaunchShortcut.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
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 #17
Source File: KubeUtil.java    From codewind-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Starts a separate port forward launch
 */
public static PortForwardInfo launchPortForward(CodewindApplication app, int localPort, int port) throws Exception {
	// Check the app (throws an exception if there is a problem)
	checkApp(app);

	// Get the command
	List<String> commandList = getPortForwardCommand(app, localPort, port);
	String title = NLS.bind(Messages.PortForwardTitle, localPort + ":" + port);

	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(UtilityLaunchConfigDelegate.LAUNCH_CONFIG_ID);
	ILaunchConfigurationWorkingCopy workingCopy = launchConfigurationType.newInstance((IContainer) null, app.name);
	workingCopy.setAttribute(CodewindLaunchConfigDelegate.CONNECTION_ID_ATTR, app.connection.getConid());
	workingCopy.setAttribute(CodewindLaunchConfigDelegate.PROJECT_ID_ATTR, app.projectID);
	workingCopy.setAttribute(UtilityLaunchConfigDelegate.TITLE_ATTR, title);
	workingCopy.setAttribute(UtilityLaunchConfigDelegate.COMMAND_ATTR, commandList);
	CodewindLaunchConfigDelegate.setConfigAttributes(workingCopy, app);
	ILaunchConfiguration launchConfig = workingCopy.doSave();
	ILaunch launch = launchConfig.launch(ILaunchManager.RUN_MODE, new NullProgressMonitor());
	return new PortForwardInfo(localPort, port, launch);
}
 
Example #18
Source File: TLCModelFactory.java    From tlaplus with MIT License 6 votes vote down vote up
/**
 * @see Model#getByName(String)
 */
public static Model getByName(final String fullQualifiedModelName) {
	Assert.isNotNull(fullQualifiedModelName);
	Assert.isLegal(fullQualifiedModelName.contains(Model.SPEC_MODEL_DELIM), "Not a full-qualified model name.");
	
       final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
       final ILaunchConfigurationType launchConfigurationType = launchManager
               .getLaunchConfigurationType(TLCModelLaunchDelegate.LAUNCH_CONFIGURATION_TYPE);

	try {
		final ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(launchConfigurationType);
		for (int i = 0; i < launchConfigurations.length; i++) {
			// Can do equals here because of full qualified name.
			final ILaunchConfiguration launchConfiguration = launchConfigurations[i];
			if (fullQualifiedModelName.equals(launchConfiguration.getName())) {
				return launchConfiguration.getAdapter(Model.class);
			}
		}
	} catch (CoreException shouldNeverHappen) {
		shouldNeverHappen.printStackTrace();
	}
	
	return null;
}
 
Example #19
Source File: StatechartLaunchShortcut.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected ILaunchConfiguration findLaunchConfiguration(ILaunchConfigurationType configType, IFile file) {
	ILaunchConfiguration[] configs;
	try {
		configs = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations(configType);
		for (ILaunchConfiguration config : configs) {
			String attribute = config.getAttribute(FILE_NAME, "");
			if (attribute.equals(file.getFullPath().toString())) {
				return config;
			}
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example #20
Source File: StatechartLaunchShortcut.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
protected ILaunchConfiguration createNewLaunchConfiguration(IFile file) {
	final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	final ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType(getConfigType());
	try {
		ILaunchConfigurationWorkingCopy newConfig = configType.newInstance(null,
				launchManager.generateLaunchConfigurationName(file.getName()));

		newConfig.setAttribute(FILE_NAME, file.getFullPath().toString());
		return newConfig.doSave();

	} catch (CoreException e) {
		e.printStackTrace();
	}
	throw new IllegalStateException();
}
 
Example #21
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 #22
Source File: TypeScriptCompilerLaunchHelper.java    From typescript.java with MIT License 5 votes vote down vote up
private static ILaunchConfigurationWorkingCopy createEmptyLaunchConfiguration(String namePrefix)
		throws CoreException {
	ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
	ILaunchConfigurationType launchConfigurationType = launchManager
			.getLaunchConfigurationType(TypeScriptCompilerLaunchConstants.LAUNCH_CONFIGURATION_ID);
	ILaunchConfigurationWorkingCopy launchConfiguration = launchConfigurationType.newInstance(null,
			launchManager.generateLaunchConfigurationName(namePrefix));
	return launchConfiguration;
}
 
Example #23
Source File: TypeScriptCompilerLaunchHelper.java    From typescript.java with MIT License 5 votes vote down vote up
public static void launch(IFile tsconfigFile, String mode) {
	ILaunchConfigurationType tscLaunchConfigurationType = DebugPlugin.getDefault().getLaunchManager()
			.getLaunchConfigurationType(TypeScriptCompilerLaunchConstants.LAUNCH_CONFIGURATION_ID);
	try {
		// Check if configuration already exists
		ILaunchConfiguration[] configurations = DebugPlugin.getDefault().getLaunchManager()
				.getLaunchConfigurations(tscLaunchConfigurationType);

		ILaunchConfiguration existingConfiguraion = chooseLaunchConfiguration(configurations, tsconfigFile);

		if (existingConfiguraion != null) {
			ILaunchConfigurationWorkingCopy wc = existingConfiguraion.getWorkingCopy();
			existingConfiguraion = wc.doSave();
			DebugUITools.launch(existingConfiguraion, mode);
			// Creating Launch Configuration from scratch
		} else {
			IProject project = tsconfigFile.getProject();
			ILaunchConfigurationWorkingCopy newConfiguration = createEmptyLaunchConfiguration(
					project.getName() + " [" + tsconfigFile.getProjectRelativePath().toString() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
			newConfiguration.setAttribute(TypeScriptCompilerLaunchConstants.BUILD_PATH, getBuildPath(tsconfigFile));
			newConfiguration.doSave();
			DebugUITools.launch(newConfiguration, mode);
		}

	} catch (CoreException e) {
		TypeScriptCorePlugin.logError(e, e.getMessage());
	}

}
 
Example #24
Source File: PythonFileRunner.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
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 #25
Source File: LaunchConfigCleanerPDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
private void prepareLaunchPreferences( boolean cleanupEnabled, ILaunchConfigurationType selectedType ) {
  launchPreferences.setCleanupGeneratedLaunchConfigs( cleanupEnabled );
  if( selectedType != null ) {
    launchPreferences.setCleanupGenerateLaunchConfigTypes( selectedType.getIdentifier() );
  } else {
    launchPreferences.setCleanupGenerateLaunchConfigTypes( "" );
  }
}
 
Example #26
Source File: CleanupPreferencePagePDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testCreateContentsWithCleanupLaunchConfigTypes() {
  ILaunchConfigurationType type = launchConfigRule.getPublicTestLaunchConfigType();
  prepareLaunchPreferences( true, type );
  preferencePage.createContents( displayHelper.createShell() );

  assertThat( getCheckedCleanupLaunchConfigTypes() ).containsOnly( type );
}
 
Example #27
Source File: CleanupPreferencePagePDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testDeselectCleanupEnabledButtonWhileLaunchConfigTypesChecked() {
  ILaunchConfigurationType type = launchConfigRule.getPublicTestLaunchConfigType();
  prepareLaunchPreferences( true, type );
  preferencePage.createContents( displayHelper.createShell() );

  preferencePage.cleanupButton.setSelection( false );
  preferencePage.cleanupButton.notifyListeners( SWT.Selection, null );

  assertThat( getCheckedCleanupLaunchConfigTypes() ).containsOnly( type );
}
 
Example #28
Source File: CleanupPreferencePagePDETest.java    From eclipse-extras with Eclipse Public License 1.0 5 votes vote down vote up
@Test
public void testPerformOk() {
  ILaunchConfigurationType type = launchConfigRule.getPublicTestLaunchConfigType();
  preferencePage.createContents( displayHelper.createShell() );
  preferencePage.cleanupButton.setSelection( true );
  preferencePage.cleanupButton.notifyListeners( SWT.Selection, null );
  preferencePage.cleanupTypesViewer.setChecked( type, true );

  preferencePage.performOk();

  assertThat( launchPreferences.isCleanupGeneratedLaunchConfigs() ).isTrue();
  assertThat( launchPreferences.getCleanupGenerateLaunchConfigTypes() ).isEqualTo( type.getIdentifier() );
}
 
Example #29
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 #30
Source File: HybridProjectLaunchShortcut.java    From thym with Eclipse Public License 1.0 5 votes vote down vote up
private ILaunchConfigurationType getLaunchConfigurationType(){
	ILaunchManager lm = DebugPlugin.getDefault().getLaunchManager();
	String launchTypeID = getLaunchConfigurationTypeID();
	Assert.isNotNull(launchTypeID);
	ILaunchConfigurationType configType = lm.getLaunchConfigurationType(launchTypeID);
	return configType;
}