/** * Creates an {@link ILaunchConfiguration} containing the information of this instance, only available when run * within the Eclipse IDE. If an {@link ILaunchConfiguration} with the same name has been run before, the instance * from the launch manager is used. This is usually done in the {@code ILaunchShortcut}. * * @see #fromLaunchConfiguration(ILaunchConfiguration) */ public ILaunchConfiguration toLaunchConfiguration() throws CoreException { ILaunchConfiguration[] configs = DebugPlugin.getDefault().getLaunchManager() .getLaunchConfigurations(configurationType); boolean configurationHasChanged = false; for (ILaunchConfiguration config : configs) { if (configName.equals(config.getName())) { configurationHasChanged = hasConfigurationChanged(config); if (!configurationHasChanged) { return config; } } } IContainer container = null; ILaunchConfigurationWorkingCopy workingCopy = configurationType.newInstance(container, configName); workingCopy.setAttribute(XT_FILE_TO_RUN, xtFileToRun); workingCopy.setAttribute(WORKING_DIRECTORY, workingDirectory.getAbsolutePath()); return workingCopy.doSave(); }
/** * 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); } }
private void addJvmOptions ( final ILaunchConfigurationWorkingCopy cfg, final Profile profile, final IContainer container ) throws CoreException { final List<String> args = new LinkedList<> (); args.addAll ( profile.getJvmArguments () ); for ( final SystemProperty p : profile.getProperty () ) { addSystemProperty ( profile, args, p.getKey (), p.getValue (), p.isEval () ); } for ( final Map.Entry<String, String> entry : getInitialProperties ().entrySet () ) { addSystemProperty ( profile, args, entry.getKey (), entry.getValue (), false ); } final IFile dataJson = container.getFile ( new Path ( "data.json" ) ); //$NON-NLS-1$ if ( dataJson.exists () ) { addJvmArg ( args, "org.eclipse.scada.ca.file.provisionJsonUrl", escapeArgValue ( dataJson.getLocation ().toFile ().toURI ().toString () ) ); //$NON-NLS-1$ } cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_VM_ARGUMENTS, StringHelper.join ( args, "\n" ) ); cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, StringHelper.join ( profile.getArguments (), "\n" ) ); }
/** * 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; }
public void performApply(ILaunchConfigurationWorkingCopy configuration) { // Convert the table's items into a Map so that this can be saved in the // configuration's attributes. TableItem[] items = propertiesTable.getTable().getItems(); Map<String,String> map = new HashMap<>(items.length); for (int i = 0; i < items.length; i++) { PropertyVariable var = (PropertyVariable) items[i].getData(); map.put(var.getName(), var.getValue()); } if (map.size() == 0) { configuration.setAttribute(launchConfigurationPropertyMapAttributeName, (Map<String,String>) null); } else { configuration.setAttribute(launchConfigurationPropertyMapAttributeName, map); } }
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { super.performApply(configuration); configuration.setAttribute( "remoteWorkspace", fRemoteAppDirPathText.getText()); configuration.setAttribute( "hostName", fHostText.getText()); configuration.setAttribute( "userName", fUserNameText.getText()); configuration.setAttribute( "userPassword", fUserPasswordText.getText()); }
@Test public void testProjectWithSourceFolders() throws Exception { IPackageFragmentRoot rootSrc1 = javaProject1.createSourceFolder("src"); IPackageFragmentRoot rootSrc2 = javaProject1.createSourceFolder("test"); JavaProjectKit.waitForBuild(); ILaunchConfigurationWorkingCopy configuration = getJavaApplicationType() .newInstance(javaProject1.project, "test.launch"); configuration.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "project1"); final Collection<IPackageFragmentRoot> scope = launcher .getOverallScope(configuration); assertEquals(set(rootSrc1, rootSrc2), set(scope)); }
@Test public void testProjectWithProjectReference() throws Exception { IPackageFragmentRoot rootSrc1 = javaProject1.createSourceFolder("src"); IPackageFragmentRoot rootSrc2 = javaProject2.createSourceFolder("src"); javaProject1.addProjectReference(javaProject2); JavaProjectKit.waitForBuild(); ILaunchConfigurationWorkingCopy configuration = getJavaApplicationType() .newInstance(javaProject1.project, "test.launch"); configuration.setAttribute( IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, "project1"); final Collection<IPackageFragmentRoot> scope = launcher .getOverallScope(configuration); assertEquals(set(rootSrc1, rootSrc2), set(scope)); }
@Test public void testToLaunchConfigurationWritesArgumentsToLaunchConfiguration() { PipelineLaunchConfiguration pipelineLaunchConfig = PipelineLaunchConfiguration.createDefault(); PipelineRunner runner = PipelineRunner.DATAFLOW_PIPELINE_RUNNER; pipelineLaunchConfig.setRunner(runner); Map<String, String> argValues = ImmutableMap.of( "Spam", "foo", "Ham", "bar", "Eggs", "baz"); pipelineLaunchConfig.setArgumentValues(argValues); ILaunchConfigurationWorkingCopy workingCopy = mock(ILaunchConfigurationWorkingCopy.class); pipelineLaunchConfig.toLaunchConfiguration(workingCopy); verify(workingCopy).setAttribute( PipelineConfigurationAttr.ALL_ARGUMENT_VALUES.toString(), argValues); verify(workingCopy).setAttribute( PipelineConfigurationAttr.RUNNER_ARGUMENT.toString(), runner.getRunnerName()); }
@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; }
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { PipelineRunner runner = getSelectedRunner(); launchConfiguration.setRunner(runner); launchConfiguration.setUseDefaultLaunchOptions(defaultOptionsComponent.isUseDefaultOptions()); Map<String, String> overallArgValues = new HashMap<>(launchConfiguration.getArgumentValues()); if (!defaultOptionsComponent.isUseDefaultOptions()) { overallArgValues.putAll(defaultOptionsComponent.getValues()); } overallArgValues.putAll(getNonDefaultOptions()); launchConfiguration.setArgumentValues(overallArgValues); launchConfiguration.setUserOptionsName(userOptionsSelector.getText()); launchConfiguration.toLaunchConfiguration(configuration); }
/** * Stores the Dataflow Pipeline-specific options of this LaunchConfiguration inside the provided * {@link ILaunchConfigurationWorkingCopy}. */ public void toLaunchConfiguration(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute( PipelineConfigurationAttr.RUNNER_ARGUMENT.toString(), runner.getRunnerName()); configuration.setAttribute( PipelineConfigurationAttr.USE_DEFAULT_LAUNCH_OPTIONS.toString(), useDefaultLaunchOptions); configuration.setAttribute( PipelineConfigurationAttr.ALL_ARGUMENT_VALUES.toString(), argumentValues); configuration.setAttribute( PipelineConfigurationAttr.USER_OPTIONS_NAME.toString(), userOptionsName.orNull()); try { setEclipseProjectName(configuration); } catch (CoreException e) { DataflowCorePlugin.logWarning("CoreException while trying to retrieve" + " project name from Configuration Working Copy"); } }
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(GenerateUml2Solidity.MODEL_URI, modelText.getText()); configuration.setAttribute(CONTRACT_FILE_HEADER, fileHeaderText.getText()); configuration.setAttribute(GENERATE_MIX, btnGenerateMixConfig.getSelection()); configuration.setAttribute(GENERATE_HTML, btnGenerateMixHtml.getSelection()); configuration.setAttribute(GENERATE_CONTRACT_FILES, btnGenerateSolidityCode.getSelection()); configuration.setAttribute(GENERATION_TARGET, generationDirectoryText.getText()); configuration.setAttribute(CONTRACT_FILE_HEADER, fileHeaderText.getText()); configuration.setAttribute(ENABLE_VERSION, btnVersionAbove.getSelection()); configuration.setAttribute(VERSION_PRAGMA, versionText.getText()); configuration.setAttribute(COMPILE_CONTRACTS, btnCompile.getSelection()); configuration.setAttribute(COMPILER_PROGRAMM, compiler_text.getText()); configuration.setAttribute(COMPILER_TARGET, compiler_out_text.getText()); for (Entry<String, Button> e : compileOptions.entrySet()) { configuration.setAttribute(e.getKey(), e.getValue().getSelection()); } }
@Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { IPreferenceStore store = PreferenceConstants.getPreferenceStore(null); configuration.setAttribute(GENERATE_JAVA_INTERFACE, store.getBoolean(GENERATE_JAVA_INTERFACE)); configuration.setAttribute(GENERATE_JAVA_NONBLOCKING, store.getBoolean(GENERATE_JAVA_NONBLOCKING)); configuration.setAttribute(GENERATION_JAVA_INTERFACE_TARGET, store.getString(GENERATION_JAVA_INTERFACE_TARGET)); configuration.setAttribute(GENERATION_JAVA_INTERFACE_PACKAGE_PREFIX, store.getString(GENERATION_JAVA_INTERFACE_PACKAGE_PREFIX)); configuration.setAttribute(GENERATE_JAVA_TESTS, store.getBoolean(GENERATE_JAVA_TESTS)); configuration.setAttribute(GENERATION_JAVA_TEST_TARGET, store.getString(GENERATION_JAVA_TEST_TARGET)); String types = store.getString(GENERATION_JAVA_2_SOLIDITY_TYPES); if (types != null) { String[] split = types.split(","); for (int i = 0; i < split.length; i++) { String t = split[i]; configuration.setAttribute(GENERATION_JAVA_2_SOLIDITY_TYPE_PREFIX + t, store.getString(GENERATION_JAVA_2_SOLIDITY_TYPE_PREFIX + t)); } } }
/** * Initializes the given launch configuration with * default values for this tab. This method * is called when a new launch configuration is created * such that the configuration can be initialized with * meaningful values. This method may be called before this * tab's control is created. * * If the configuration parameter contains an attribute named * 'viewerCurrent', the tab is initialized with the default values * for the given viewer. The given viewer is expected to exist. * * @param configuration launch configuration */ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { try { String viewer = configuration.getAttribute("viewerCurrent", registry.getActiveViewer()); registry.setActiveViewer(viewer); configuration.setAttribute(ViewerAttributeRegistry.VIEWER_CURRENT, viewer); configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_COMMAND, registry.getCommand()); configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_ARGUMENTS, registry.getArguments()); configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_VIEW_COMMAND, registry.getDDEViewCommand()); configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_VIEW_SERVER, registry.getDDEViewServer()); configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_VIEW_TOPIC, registry.getDDEViewTopic()); configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_CLOSE_COMMAND, registry.getDDECloseCommand()); configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_CLOSE_SERVER, registry.getDDECloseServer()); configuration.setAttribute(viewer + ViewerAttributeRegistry.ATTRIBUTE_DDE_CLOSE_TOPIC, registry.getDDECloseTopic()); } catch (CoreException e) { TexlipsePlugin.log("Initializing launch configuration", e); } }
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { try { {// check if a new table must be created String newProject = configuration.getAttribute(CAL_PROJECT.longName(), ""); String newXdf = configuration.getAttribute(CAL_XDF.longName(), ""); String newConfig = configStamp(newProject, newXdf); config = configuration.getAttribute(LOADED_CONFIGURATION, ""); if (!newConfig.equals(config)) { config = newConfig; configuration.setAttribute(LOADED_CONFIGURATION, config); loadConnections(newProject, newXdf); loadXdfMapping(); viewer.setInput(connections); } } configuration.setAttribute(getId(), getValue()); } catch (CoreException e) { e.printStackTrace(); } }
/** * 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; }
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { super.performApply(configuration); String command = commandsCommbo.getText().trim(); if (command.length() == 0) { configuration.setAttribute(AngularCLILaunchConstants.OPERATION, (String) null); } else { configuration.setAttribute(AngularCLILaunchConstants.OPERATION, command); } String arguments = this.argumentsField.getText().trim(); if (arguments.length() == 0) { configuration.setAttribute(AngularCLILaunchConstants.OPERATION_PARAMETERS, (String) null); } else { configuration.setAttribute(AngularCLILaunchConstants.OPERATION_PARAMETERS, arguments); } }
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; }
private void startDebugConfig(final ILaunchConfigurationWorkingCopy config) throws CoreException, InterruptedException { int remainingAttempts = DEBUG_ATTACH_ATTEMPTS; // Retry until success or rethrow of exception on failure while (true) { try { WPILibJavaPlugin.logInfo("Attemping to attach debugger..."); config.launch(ILaunchManager.DEBUG_MODE, null); WPILibJavaPlugin.logInfo("Debugger attached."); break; } catch (CoreException e) { if (--remainingAttempts > 0) { String errorMsg = MessageFormat.format("Unable to attach debugger. " + "{0} attempts remain - waiting {1} second(s) before retrying...", remainingAttempts, DEBUG_ATTACH_RETRY_DELAY_SEC); WPILibJavaPlugin.logError(errorMsg, null); Thread.sleep(DEBUG_ATTACH_RETRY_DELAY_SEC * 1000); } else { throw e; } } } }
/** * (non-Javadoc) * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) **/ @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { String file = fileText.getText().trim(); if (file.length() == 0) { file = null; } configuration.setAttribute(XpectRunConfiguration.XT_FILE_TO_RUN, file); }
/** * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { // FIXME IDE-1393 move to subclass? configuration.setAttribute(RunConfiguration.RUNNER_ID, RunnerUiUtils.getRunnerId(configuration, true)); configuration.setAttribute(RunConfiguration.IMPLEMENTATION_ID, (String) null); }
/** * From the UI widgets to the configuration. * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { final String wsRelativePath = txtResource.getText(); final URI uri = wsRelativePath.trim().length() > 0 ? URI.createPlatformResourceURI(wsRelativePath, true) : null; final String uriStr = uri != null ? uri.toString() : null; configuration.setAttribute(getResourceRunConfigKey(), uriStr); final String implementationId = txtImplementationId.getText(); final String actualImplId = implementationId.trim().length() > 0 ? implementationId.trim() : null; configuration.setAttribute(RunConfiguration.IMPLEMENTATION_ID, actualImplId); }
@Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(RunConfiguration.LAUNCH_DELAY, 1000); configuration.setAttribute(RunConfiguration.LAUNCH_MODEL_ENTRY_POINT, ""); configuration.setAttribute(RunConfiguration.LAUNCH_METHOD_ENTRY_POINT, ""); configuration.setAttribute(RunConfiguration.LAUNCH_SELECTED_LANGUAGE, ""); }
@Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute( AbstractDSLLaunchConfigurationDelegate.RESOURCE_URI, this._modelLocationText.getText()); configuration.setAttribute( AbstractDSLLaunchConfigurationDelegateSiriusUI.SIRIUS_RESOURCE_URI, this._siriusRepresentationLocationText.getText()); configuration.setAttribute(RunConfiguration.LAUNCH_DELAY, Integer.parseInt(_delayText.getText())); configuration.setAttribute(RunConfiguration.LAUNCH_SELECTED_LANGUAGE, _languageCombo.getText()); configuration.setAttribute(RunConfiguration.LAUNCH_MELANGE_QUERY, _melangeQueryText.getText()); configuration.setAttribute(RunConfiguration.LAUNCH_MODEL_ENTRY_POINT, _entryPointModelElementText.getText()); configuration.setAttribute(RunConfiguration.LAUNCH_METHOD_ENTRY_POINT, _entryPointMethodText.getText()); configuration.setAttribute(RunConfiguration.LAUNCH_INITIALIZATION_METHOD, _modelInitializationMethodText.getText()); configuration.setAttribute(RunConfiguration.LAUNCH_INITIALIZATION_ARGUMENTS, _modelInitializationArgumentsText.getText()); configuration.setAttribute(RunConfiguration.LAUNCH_BREAK_START, _animationFirstBreak.getSelection()); // DebugModelID for sequential engine configuration.setAttribute(RunConfiguration.DEBUG_MODEL_ID, Activator.DEBUG_MODEL_ID); }
/** * Creates a {@link ILaunchConfiguration}. If the <code>firstInstruction</code> is <code>null</code> the * launch configuration dialog is opened. * * @param file * the selected model {@link IFile} * @param firstInstruction * the first {@link EObject instruction} or <code>null</code> for interactive selection * @param mode * the {@link ILaunchConfiguration#getModes() mode} * @return an array of possible {@link ILaunchConfiguration}, can be empty but not <code>null</code> * @throws CoreException * if {@link ILaunchConfiguration} initialization fails of models can't be loaded */ protected ILaunchConfiguration[] createLaunchConfiguration(final IResource file, EObject firstInstruction, final String mode) throws CoreException { final ILaunchConfiguration[] res; ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationType type = manager.getLaunchConfigurationType(getLaunchConfigurationTypeID()); ILaunchConfigurationWorkingCopy configuration = type.newInstance(null, file.getName()); configuration.setMappedResources(new IResource[] {file, }); configuration.setAttribute(AbstractDSLLaunchConfigurationDelegate.RESOURCE_URI, file.getFullPath() .toString()); if (firstInstruction == null) { // open configuration for further editing final ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, mode); if (group != null) { configuration.doSave(); DebugUITools.openLaunchConfigurationDialog(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), configuration, group.getIdentifier(), null); } res = new ILaunchConfiguration[] {}; } else { configuration.setAttribute(AbstractDSLLaunchConfigurationDelegate.FIRST_INSTRUCTION_URI, EcoreUtil.getURI(firstInstruction).toString()); // save and return new configuration configuration.doSave(); res = new ILaunchConfiguration[] {configuration, }; } return res; }
/** * {@inheritDoc} * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ public void performApply(final ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(AbstractDSLLaunchConfigurationDelegate.RESOURCE_URI, resourceURIText .getText()); configuration.setAttribute(AbstractDSLLaunchConfigurationDelegate.FIRST_INSTRUCTION_URI, firstInstructionURIText.getText()); }
@Override protected final ILaunchConfiguration[] createLaunchConfiguration(IResource file, EObject firstInstruction, String mode) throws CoreException { ILaunchConfiguration[] launchConfigs = super.createLaunchConfiguration(file, firstInstruction, mode); if (launchConfigs.length == 1) { // open configuration for further editing if (launchConfigs[0] instanceof ILaunchConfigurationWorkingCopy) { ILaunchConfigurationWorkingCopy configuration = (ILaunchConfigurationWorkingCopy) launchConfigs[0]; String selectedLanguage = configuration.getAttribute(RunConfiguration.LAUNCH_SELECTED_LANGUAGE, ""); if (selectedLanguage.equals("")) { // TODO try to infer possible language and other attribute // from project content and environment setDefaultsLaunchConfiguration(configuration); final ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, mode); if (group != null) { ILaunchConfiguration savedLaunchConfig = configuration.doSave(); // open configuration for user validation and inputs DebugUITools.openLaunchConfigurationDialogOnGroup(PlatformUI.getWorkbench() .getActiveWorkbenchWindow().getShell(), new StructuredSelection(savedLaunchConfig), group.getIdentifier(), null); // DebugUITools.openLaunchConfigurationDialog(PlatformUI.getWorkbench() // .getActiveWorkbenchWindow().getShell(), // savedLaunchConfig, group.getIdentifier(), null); } } } } return launchConfigs; }
protected ILaunchConfiguration createConfiguration ( final IResource resource ) throws Exception { final ResourceSet rs = new ResourceSetImpl (); final Resource r = rs.createResource ( URI.createURI ( resource.getLocationURI ().toURL ().toString () ) ); r.load ( null ); final Profile profile = (Profile)EcoreUtil.getObjectByType ( r.getContents (), ProfilePackage.Literals.PROFILE ); if ( profile == null ) { return null; } String name = profile.getName (); if ( name == null || name.isEmpty () ) { name = String.format ( "Application profile: %s", resource.getFullPath () ); //$NON-NLS-1$ } final ILaunchConfigurationWorkingCopy cfg = getConfigurationType ().newInstance ( resource.getParent (), name ); final Map<String, String> envs = new HashMap<> (); envs.put ( "SCADA_PROFILE", String.format ( "${project_loc:/%s}/%s", resource.getProject ().getName (), resource.getProjectRelativePath () ) ); //$NON-NLS-1$ //$NON-NLS-2$ cfg.setAttribute ( ATTR_ENV_VARS, envs ); cfg.setAttribute ( IPDELauncherConstants.INCLUDE_OPTIONAL, false ); cfg.setAttribute ( IPDELauncherConstants.AUTOMATIC_ADD, false ); cfg.setAttribute ( IPDELauncherConstants.AUTOMATIC_VALIDATE, true ); cfg.setAttribute ( IPDELauncherConstants.DEFAULT_AUTO_START, false ); cfg.setAttribute ( IPDELauncherConstants.CONFIG_USE_DEFAULT_AREA, false ); cfg.setAttribute ( IPDELauncherConstants.CONFIG_LOCATION, getConfigurationArea ( profile ) ); addAllBundels ( cfg, profile ); addJvmOptions ( cfg, profile, resource.getParent () ); cfg.setAttribute ( IJavaLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -consoleLog -console" ); //$NON-NLS-1$ return cfg.doSave (); }
@Override public void performApply(ILaunchConfigurationWorkingCopy config) { config.setAttribute(CONFIG_PROJECT, fProjText.getText()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText()); try { setModels(config); } catch (CoreException e) { ResourceManager.logException(e); } config.setAttribute(GW4E_LAUNCH_CONFIGURATION_BUTTON_ID_OMIT_EMPTY_EDGE_DESCRIPTION, this.fOmitEmptyEdgeElementsButton.getSelection() + ""); config.setAttribute(CONFIG_LAUNCH_STARTNODE, this.fStartNodeText.getText() + ""); config.setAttribute(CONFIG_LAUNCH_REMOVE_BLOCKED_ELEMENT_CONFIGURATION, this.fRemoveBlockedElementsButton.getSelection() + ""); }
private void setModels(ILaunchConfigurationWorkingCopy config) throws CoreException { StringBuffer sb = new StringBuffer(); // Main if (fModelText.getText() == null || fModelText.getText().trim().length() == 0) { sb.append("").append(";"); } else { sb.append((fModelText.getText().trim())).append(";"); } sb.append("1").append(";"); IStructuredSelection selection = (IStructuredSelection) comboViewer.getSelection(); if (selection == null || selection.getFirstElement() == null) { sb.append("?").append(";"); } else { sb.append(((BuildPolicy) selection.getFirstElement()).getPathGenerator()).append(";"); } // Others ModelData[] others = mpg.getModel(); for (int i = 0; i < others.length; i++) { sb.append(others[i].getFullPath()).append(";"); if (others[i].isSelected()) { sb.append("1").append(";"); } else { sb.append("0").append(";"); } sb.append(others[i].getSelectedPolicy()).append(";"); } config.setAttribute(CONFIG_GRAPH_MODEL_PATHS, sb.toString()); }
@Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { config.setAttribute(CONFIG_PROJECT, ""); config.setAttribute(CONFIG_GRAPH_MODEL_PATHS, ""); config.setAttribute(CONFIG_UNVISITED_ELEMENT, "false"); config.setAttribute(GW4E_LAUNCH_CONFIGURATION_BUTTON_ID_OMIT_EMPTY_EDGE_DESCRIPTION, "false"); config.setAttribute(CONFIG_LAUNCH_STARTNODE, ""); config.setAttribute(CONFIG_LAUNCH_REMOVE_BLOCKED_ELEMENT_CONFIGURATION, "true"); }
private void launch(Object[] elements, String mode) { try { IJavaElement[] ijes = null; List<IJavaElement> jes = new ArrayList<IJavaElement>(); for (int i = 0; i < elements.length; i++) { Object selected= elements[i]; if (selected instanceof IJavaElement) { IJavaElement element= (IJavaElement) selected; switch (element.getElementType()) { case IJavaElement.COMPILATION_UNIT: jes.add(element); break; } } } ijes = new IJavaElement[jes.size()]; jes.toArray(ijes); ILaunchConfigurationWorkingCopy wc = buildLaunchConfiguration(ijes); if (wc==null) return; ILaunchConfiguration config= findExistingORCreateLaunchConfiguration(wc, mode); DebugUITools.launch(config, mode); } catch (Exception e) { ResourceManager.logException(e); MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "GW4E Launcher", (Image)null, "Unable to launch. See error in Error view.", MessageDialog.ERROR, new String[] { "Close" }, 0); dialog.open(); } }
private ILaunchConfiguration findExistingORCreateLaunchConfiguration(ILaunchConfigurationWorkingCopy temp, String mode) throws InterruptedException, CoreException { List candidateConfigs= findExistingLaunchConfigurations(temp); int candidateCount= candidateConfigs.size(); if (candidateCount > 0) { return (ILaunchConfiguration) candidateConfigs.get(0); } return temp.doSave(); }
protected ILaunchConfigurationWorkingCopy buildLaunchConfiguration(IJavaElement[] elements) throws CoreException { IJavaElement mainElement = null; for (int i = 0; i < elements.length; i++) { IJavaElement element = elements [i]; if (JDTManager.hasStartableGraphWalkerAnnotation(element)) { mainElement = element; break; } } if (mainElement==null) { MessageDialog dialog = new MessageDialog(Display.getCurrent().getActiveShell(), "GW4E Launcher", (Image)null, MessageUtil.getString("nostartvalueinannotation"), MessageDialog.ERROR, new String[] { "Close" }, 0); dialog.open(); return null; } ILaunchConfigurationType configType= DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(GW4ELAUNCHCONFIGURATIONTYPE); ILaunchConfigurationWorkingCopy wc= configType.newInstance(null, DebugPlugin.getDefault().getLaunchManager().generateLaunchConfigurationName(mainElement.getElementName())); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, elements[0].getJavaProject().getElementName()); String mainElementName = elementToJavaClassName (mainElement); StringBuffer sb = new StringBuffer (mainElementName).append(";"); String[] classnames = elementToJavaClassName(elements); for (int i = 0; i < classnames.length; i++) { if (classnames[i].equals(mainElementName)) continue; sb.append(classnames[i]).append(";"); } wc.setAttribute(LaunchingConstant.CONFIG_TEST_CLASSES,sb.toString()); return wc; }
@Override public void performApply(ILaunchConfigurationWorkingCopy config) { config.setAttribute(CONFIG_PROJECT, fProjText.getText()); config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, fProjText.getText()); try { setModels(config); } catch (CoreException e) { ResourceManager.logException(e); } config.setAttribute(CONFIG_UNVISITED_ELEMENT, this.fPrintUnvisitedButton.getSelection() + ""); config.setAttribute(CONFIG_VERBOSE, this.fVerbosedButton.getSelection() + ""); config.setAttribute(CONFIG_LAUNCH_STARTNODE, this.fStartNodeText.getText() + ""); config.setAttribute(CONFIG_LAUNCH_REMOVE_BLOCKED_ELEMENT_CONFIGURATION, this.fRemoveBlockedElementsButton.getSelection() + ""); }