public ILaunchConfiguration getLaunchConfiguration(String projectName) { try { ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = launchManager .getLaunchConfigurationType(JSTD_LAUNCH_CONFIGURATION_TYPE); ILaunchConfiguration[] launchConfigurations = launchManager.getLaunchConfigurations(type); for (ILaunchConfiguration launchConfiguration : launchConfigurations) { String configProjectName = launchConfiguration.getAttribute(LaunchConfigurationConstants.PROJECT_NAME, ""); if (configProjectName.equals(projectName) && isValidToRun(projectName, launchConfiguration)) { return launchConfiguration; } } } catch (CoreException e) { //logger.logException(e); } return null; }
/** * Converts a {@link TestConfiguration} to an {@link ILaunchConfiguration}. Will throw a {@link WrappedException} in * case of error. * * @see TestConfiguration#readPersistentValues() */ public ILaunchConfiguration toLaunchConfiguration(ILaunchConfigurationType type, TestConfiguration testConfig) { try { final ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(type); for (ILaunchConfiguration config : configs) { if (equals(testConfig, config)) return config; } final IContainer container = null; final ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(container, testConfig.getName()); workingCopy.setAttributes(testConfig.readPersistentValues()); return workingCopy.doSave(); } catch (Exception e) { throw new WrappedException("could not convert N4JS TestConfiguration to Eclipse ILaunchConfiguration", e); } }
/** * 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); } }
/** * 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, moduleToRun); ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = launchManager.getLaunchConfigurationType(getLaunchConfigTypeID()); DebugUITools.launch(runConfigConverter.toLaunchConfiguration(type, runConfig), mode); // execution dispatched to proper delegate LaunchConfigurationDelegate }
/** * 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; } }
/** * {@inheritDoc} * * @see org.eclipse.sirius.tools.api.ui.IExternalJavaAction#execute(java.util.Collection, java.util.Map) */ public void execute(Collection<? extends EObject> selections, Map<String, Object> parameters) { final ILaunchConfigurationType launchConfigType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(getLaunchConfigurationTypeID()); Set<String> modes = new HashSet<String>(); modes.add("debug"); try { ILaunchDelegate[] delegates = launchConfigType.getDelegates(modes); if (delegates.length != 0 && delegates[0].getDelegate() instanceof AbstractDSLLaunchConfigurationDelegateUI) { AbstractDSLLaunchConfigurationDelegateUI delegate = (AbstractDSLLaunchConfigurationDelegateUI)delegates[0] .getDelegate(); delegate.launch(delegate.getLaunchableResource(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getActivePage().getActiveEditor()), getFirstInstruction(selections), "debug"); } } catch (CoreException e) { DebugSiriusIdeUiPlugin.getPlugin().getLog().log( new Status(IStatus.ERROR, DebugSiriusIdeUiPlugin.ID, e.getLocalizedMessage(), e)); } }
public static void cleanWorkspace() throws CoreException { IProject[] projects = getRoot().getProjects(); deleteProjects(projects); IProject[] otherProjects = getRoot().getProjects(IContainer.INCLUDE_HIDDEN); deleteProjects(otherProjects); ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(GW4ELaunchShortcut.GW4ELAUNCHCONFIGURATIONTYPE); ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(configType); for (int i = 0; i < configs.length; i++) { ILaunchConfiguration config = configs[i]; config.delete(); } }
private void addLaunchCfg() { try { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager .getLaunchConfigurationType("org.eclipse.pde.ui.RuntimeWorkbench"); ILaunchConfiguration[] lcs = manager.getLaunchConfigurations(type); List<ILaunchConfiguration> configList = Arrays.asList(lcs); List<String> configs = configList.stream().map(config -> config.getName()).collect(Collectors.toList()); ComboDialog dialog = new ComboDialog(getShell(), true); dialog.setTitle("Choose launch config"); dialog.setInfoText("Choose Eclipse launch conguration to edit it's configuration settings"); dialog.setAllowedValues(configs); if (dialog.open() == OK) { String selectedName = dialog.getValue(); ILaunchConfiguration selectedConfig = configList.stream().filter(config -> selectedName.equals(config.getName())).findFirst().get(); String configLocation = getConfigLocation(selectedConfig); valueAdded(new File(configLocation, ".settings").getAbsolutePath()); buttonPressed(IDialogConstants.OK_ID); } } catch (CoreException e) { PrefEditorPlugin.log(e); } }
/** * Creates and returns a new configuration based on the specified type. * * @param additionalScope additional scope which can be given * @param type * type to create a launch configuration for * * @return launch configuration configured to launch the specified type */ protected ILaunchConfiguration createConfiguration(IResource resource, Object additionalScope) { ILaunchConfiguration config = null; ILaunchConfigurationWorkingCopy wc = null; try { String projectName = createGradleProjectName(resource); String proposal = createLaunchConfigurationNameProposal(projectName, resource, additionalScope); ILaunchConfigurationType configType = getConfigurationType(); wc = configType.newInstance(null, getLaunchManager().generateLaunchConfigurationName(proposal)); createCustomConfiguration(resource, additionalScope, wc, projectName); config = wc.doSave(); } catch (CoreException exception) { MessageDialog.openError(EclipseUtil.getActiveWorkbenchShell(), "EGradle create configuration failed", exception.getStatus().getMessage()); } return config; }
@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; }
@VisibleForTesting void checkConflictingLaunches(ILaunchConfigurationType launchConfigType, String mode, DefaultRunConfiguration 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()); DefaultRunConfiguration otherRunConfig = generateServerRunConfiguration(launch.getLaunchConfiguration(), otherServer, mode); 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)); } } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_CODE_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_NUMA_EXECUTION_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_TABU_PERFORMANCE_ESTMATION_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager .getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_DYNAMIC_EXECUTION_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
private ILaunchConfiguration[] getConfigurations(IFile file) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(LAUNCH_CONFIG_TYPE_DYNAMIC_INTERPRETER_ANALYSIS); try { // configurations that match the given resource List<ILaunchConfiguration> configs = new ArrayList<ILaunchConfiguration>(); // candidates ILaunchConfiguration[] candidates = manager.getLaunchConfigurations(type); String name = FileUtils.getRelativePath(file); for (ILaunchConfiguration config : candidates) { String fileName = config.getAttribute(CAL_XDF.longName(), ""); if (fileName.equals(name)) { configs.add(config); } } return configs.toArray(new ILaunchConfiguration[] {}); } catch (Exception e) { e.printStackTrace(); return null; } }
/** * 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; }
private static ILaunchConfiguration chooseLaunchConfiguration(String workingDir, String operation) { try { ILaunchConfigurationType ngLaunchConfigurationType = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurationType(AngularCLILaunchConstants.LAUNCH_CONFIGURATION_ID); ILaunchConfiguration[] ngConfigurations = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(ngLaunchConfigurationType); for (ILaunchConfiguration conf : ngConfigurations) { if (workingDir.equals(conf.getAttribute(AngularCLILaunchConstants.WORKING_DIR, (String) null)) && operation.equals(conf.getAttribute(AngularCLILaunchConstants.OPERATION, (String) null))) { return conf; } } } catch (CoreException e) { TypeScriptCorePlugin.logError(e, e.getMessage()); } return null; }
private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); Map<String, Argument> def = connector.getDefaultArguments(); Map<String, String> argMap = new HashMap<String, String>(def.size()); argMap.put("hostname", getHostname(activeProj)); argMap.put("port", "8348"); WPILibJavaPlugin.logInfo(argMap.toString()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap); return config; }
/** * @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; }
public static Model getBy(final IFile aFile) { Assert.isNotNull(aFile); 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 (aFile.equals(launchConfiguration.getFile())) { return launchConfiguration.getAdapter(Model.class); } } } catch (CoreException shouldNeverHappen) { shouldNeverHappen.printStackTrace(); } return null; }
protected ILaunchConfiguration createConfiguration(IType type) throws CoreException { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType configType = manager .getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_JAVA_APPLICATION); ILaunchConfigurationWorkingCopy workingCopy = configType.newInstance( null, manager.generateLaunchConfigurationName(type .getTypeQualifiedName('.'))); workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, type.getFullyQualifiedName()); workingCopy.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, type .getJavaProject().getElementName()); workingCopy.setMappedResources(new IResource[] { type .getUnderlyingResource() }); return workingCopy.doSave(); }
/** * Creates and returns a new simulation launch configuration for the * given resource. * * @param res The resource * @return The new launch configuration */ private ILaunchConfiguration newConfiguration(IResource res) { ILaunchConfigurationType type = getLaunchType(); try { ILaunchConfigurationWorkingCopy workingCopy = type.newInstance(null, getLaunchManager().generateLaunchConfigurationName( "Simulate [" + res.getProject().getName() + "] " + res.getName())); //$NON-NLS-1$ //$NON-NLS-2$ workingCopy.setAttribute(SimulationLaunchConfigurationConstants.ATTR_PROJECT_NAME, res.getProject().getName()); workingCopy.setAttribute(SimulationLaunchConfigurationConstants.ATTR_PATH, res.getProjectRelativePath().toString()); workingCopy.setMappedResources(new IResource[]{res}); return workingCopy.doSave(); } catch (CoreException e) { e.printStackTrace(); } return null; }
/** * Looks for and returns an existing {@link ILaunchConfiguration} object for a * specified project. * @param manager The {@link ILaunchManager}. * @param type The {@link ILaunchConfigurationType}. * @param projectName The name of the project * @return an existing <code>ILaunchConfiguration</code> object matching the project, or * <code>null</code>. */ public static ILaunchConfiguration findConfig(ILaunchManager manager, ILaunchConfigurationType type, String projectName) { try { ILaunchConfiguration[] configs = manager.getLaunchConfigurations(type); for (ILaunchConfiguration config : configs) { if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "") .equals(projectName)) { //$NON-NLS-1$ return config; } } } catch (CoreException e) { MessageDialog.openError(Display.getCurrent().getActiveShell(), "Launch Error", e.getStatus().getMessage()); } // didn't find anything that matches. Return null return null; }
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; }
public boolean isExistingLaunchConfigWithRunOnBuildOtherThanCurrent( String projectName, String launchConfigName) { 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, ""); boolean runOnEveryBuild = launchConfiguration.getAttribute(TestabilityConstants.CONFIGURATION_ATTR_RUN_ON_BUILD, false); String configName = launchConfiguration.getName(); boolean isProjectNameEqual = configProjectName.equals(projectName); boolean isLaunchConfigNameEqual = launchConfigName.equals(configName); if (isProjectNameEqual && runOnEveryBuild && !isLaunchConfigNameEqual) { return true; } } } catch (CoreException e) { logger.logException(e); } return false; }
/** * 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; }
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; }
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; }
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()]); }
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; }
private void runProjectOnCodenvy(IProject project, final String mode) { final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(LAUNCH_CONFIGURATION_TYPE_ID); if (launchConfigurationType != null) { try { final ILaunchConfiguration launchConfiguration = getLaunchConfiguration(launchManager, launchConfigurationType, project, mode); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(IConsoleConstants.ID_CONSOLE_VIEW); DebugUITools.launch(launchConfiguration, mode); } catch (PartInitException e) { throw new RuntimeException(e); } } }
private void buildProjectOnCodenvy(IProject project, final String mode) { final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); final ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType(LAUNCH_CONFIGURATION_TYPE_ID); if (launchConfigurationType != null) { try { final ILaunchConfiguration launchConfiguration = getLaunchConfiguration(launchManager, launchConfigurationType, project, mode); PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(IConsoleConstants.ID_CONSOLE_VIEW); DebugUITools.launch(launchConfiguration, mode); } catch (PartInitException e) { throw new RuntimeException(e); } } }
public ILaunchConfiguration createConfiguration() { try { ILaunchConfiguration _xblockexpression = null; { DebugPlugin _default = DebugPlugin.getDefault(); final ILaunchManager launchManager = _default.getLaunchManager(); final ILaunchConfigurationType configType = launchManager.getLaunchConfigurationType("org.xtext.builddsl.ui.BuildLaunchConfigurationType"); String _name = this.getName(); String _generateUniqueLaunchConfigurationNameFrom = launchManager.generateUniqueLaunchConfigurationNameFrom(_name); final ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, _generateUniqueLaunchConfigurationNameFrom); String _project = this.getProject(); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, _project); String _clazz = this.getClazz(); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, _clazz); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_STOP_IN_MAIN, false); String _task = this.getTask(); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, _task); wc.setAttribute(RefreshTab.ATTR_REFRESH_SCOPE, "${workspace}"); wc.setAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, true); _xblockexpression = wc.doSave(); } return _xblockexpression; } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }
private ILaunchConfiguration findConfig(ILaunchManager manager, ILaunchConfigurationType configType, IProject project) { try { ILaunchConfiguration[] configs = manager.getLaunchConfigurations(configType); List<ILaunchConfiguration> matchingConfigs = new ArrayList<ILaunchConfiguration>(); for (ILaunchConfiguration config : configs) { if (config.getAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "").equals(project.getName())) { matchingConfigs.add(config); } } matchingConfigs = filterConfigs(matchingConfigs); if (matchingConfigs.size() == 1) { return matchingConfigs.get(0); } if (matchingConfigs.size() > 1) { return chooseConfiguration(matchingConfigs); } } catch (CoreException e) { RoboVMPlugin.log(e); } return null; }
private void launch(IProject project, String mode) { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType configType = manager.getLaunchConfigurationType(getConfigurationTypeId()); ILaunchConfiguration config = findConfig(manager, configType, project); if (config == null) { ILaunchConfigurationWorkingCopy wc = null; try { wc = configType.newInstance(null, manager.generateLaunchConfigurationName(project.getName())); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, project.getName()); customizeConfiguration(wc); config = wc.doSave(); } catch (CoreException e) { RoboVMPlugin.log(e); } } if (config != null) { DebugUITools.launch(config, mode); } }
public ILaunchConfiguration findConfiguration(String name) { try { ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType[] types = manager.getLaunchConfigurationTypes(); for (int i = 0; i < types.length; i++) { ILaunchConfigurationType type = types[i]; ILaunchConfiguration[] configurations; configurations = manager.getLaunchConfigurations(type); for (int j = 0; j < configurations.length; j++) { ILaunchConfiguration configuration = configurations[j]; if (name.equals(configuration.getName())) { return configuration; } } } } catch (CoreException e) { e.printStackTrace(); } return null; }