com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl Java Examples
The following examples show how to use
com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl.
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: ProjectExecutor.java From tmc-intellij with MIT License | 6 votes |
public void executeConfiguration(Project project, ModuleBasedConfiguration appCon) { if (noProjectsAreOpen()) { logger.warn("No open projects found, can't execute the project."); return; } logger.info("Starting to build execution environment."); RunManager runManager = RunManager.getInstance(project); Executor executor = DefaultRunExecutor.getRunExecutorInstance(); RunnerAndConfigurationSettingsImpl selectedConfiguration = getApplicationRunnerAndConfigurationSettings(runManager, appCon); ProgramRunner runner = getRunner(executor, selectedConfiguration); logger.info("Creating ExecutionEnvironment."); ExecutionEnvironment environment = new ExecutionEnvironment( new DefaultRunExecutor(), runner, selectedConfiguration, project); try { logger.info("Executing project."); runner.execute(environment); } catch (ExecutionException e1) { JavaExecutionUtil.showExecutionErrorMessage(e1, "Error", project); } }
Example #2
Source File: RunConfigurationSerializerTest.java From intellij with Apache License 2.0 | 6 votes |
@Test public void normalizeTemplateRunConfig() throws Exception { Element element = JDOMUtil.load( "<configuration default=\"true\" type=\"BlazeCommandRunConfigurationType\"\n" + " factoryName=\"Bazel Command\">\n" + " <blaze-settings\n" + " handler-id=\"BlazeCommandGenericRunConfigurationHandlerProvider\">\n" + " <blaze-user-flag>--some_flag</blaze-user-flag>\n" + " </blaze-settings>\n" + "</configuration>"); RunnerAndConfigurationSettingsImpl originalConfig = new RunnerAndConfigurationSettingsImpl(runManager, null, true); originalConfig.readExternal(element, false); assertThat(originalConfig.isTemplate()).isTrue(); RunConfigurationSerializer.normalizeTemplateRunConfig(element); RunnerAndConfigurationSettingsImpl normalizedConfig = new RunnerAndConfigurationSettingsImpl(runManager, null, true); normalizedConfig.readExternal(element, false); assertThat(normalizedConfig.isTemplate()).isFalse(); assertThat(normalizedConfig.getName()) .isEqualTo(RunConfigurationSerializer.TEMPLATE_RUN_CONFIG_NAME_PREFIX + "Bazel Command"); }
Example #3
Source File: RunConfigurationSerializerTest.java From intellij with Apache License 2.0 | 6 votes |
@Test public void normalizeNormalRunConfig_doNotReplaceName() throws Exception { Element element = JDOMUtil.load( "<configuration\n" + " default=\"false\"\n" + " factoryName=\"Bazel Command\"\n" + " name=\"ExampleConfig\"\n" + " type=\"BlazeCommandRunConfigurationType\">\n" + "</configuration>"); RunConfigurationSerializer.normalizeTemplateRunConfig(element); RunnerAndConfigurationSettingsImpl normalizedConfig = new RunnerAndConfigurationSettingsImpl(runManager, null, true); normalizedConfig.readExternal(element, false); assertThat(normalizedConfig.isTemplate()).isFalse(); assertThat(normalizedConfig.getName()).isEqualTo("ExampleConfig"); }
Example #4
Source File: AbstractImportTestsAction.java From consulo with Apache License 2.0 | 6 votes |
public ExecutionTarget getTarget() { if (myTargetId != null) { if (DefaultExecutionTarget.INSTANCE.getId().equals(myTargetId)) { return DefaultExecutionTarget.INSTANCE; } final RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(RunManagerImpl.getInstanceImpl(myProject), myConfiguration, false); for (ExecutionTargetProvider provider : ExecutionTargetProvider.EXTENSION_NAME.getExtensionList()) { for (ExecutionTarget target : provider.getTargets(myProject, settings)) { if (myTargetId.equals(target.getId())) { return target; } } } return null; } return DefaultExecutionTarget.INSTANCE; }
Example #5
Source File: ProjectExecutor.java From tmc-intellij with MIT License | 5 votes |
@NotNull private RunnerAndConfigurationSettingsImpl getApplicationRunnerAndConfigurationSettings( RunManager runManager, ModuleBasedConfiguration appCon) { logger.info("Getting RunnerAndConfigurationSettings implementation."); return new RunnerAndConfigurationSettingsImpl( (RunManagerImpl) runManager, appCon, runManager.getSelectedConfiguration().isTemplate()); }
Example #6
Source File: RunConfigurationSerializer.java From intellij with Apache License 2.0 | 5 votes |
public static Element writeToXml(RunConfiguration configuration) { RunnerAndConfigurationSettings settings = RunManagerImpl.getInstanceImpl(configuration.getProject()).getSettings(configuration); Element element = new Element("configuration"); try { runWithPathVariableSet( configuration.getProject(), () -> ((RunnerAndConfigurationSettingsImpl) settings).writeExternal(element)); } catch (WriteExternalException e) { logger.warn("Error serializing run configuration to XML", e); } return element; }
Example #7
Source File: RunConfigurationSerializer.java From intellij with Apache License 2.0 | 5 votes |
/** * Deserializes the configuration represented by the given XML element, then searches for an * existing run configuration in the project with the same name and type. */ @Nullable @VisibleForTesting static RunnerAndConfigurationSettings findExisting(Project project, Element element) throws InvalidDataException { RunManagerImpl manager = RunManagerImpl.getInstanceImpl(project); RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(manager); settings.readExternal(element, /* isShared= */ false); RunConfiguration config = settings.getConfiguration(); if (config == null) { return null; } return manager.findConfigurationByTypeAndName(config.getType().getId(), config.getName()); }
Example #8
Source File: ServerConnectionManager.java From aem-ide-tooling-4-intellij with Apache License 2.0 | 5 votes |
public void connectInDebugMode(RunManagerEx runManager) { ServerConfiguration serverConfiguration = selectionHandler.getCurrentConfiguration(); // Create Remote Connection to Server using the IntelliJ Run / Debug Connection //AS TODO: It is working but the configuration is listed and made persistent. That is not too bad because //AS TODO: after changes a reconnect will update the configuration. RemoteConfigurationType remoteConfigurationType = new RemoteConfigurationType(); RunConfiguration runConfiguration = remoteConfigurationType.getFactory().createTemplateConfiguration(myProject); RemoteConfiguration remoteConfiguration = (RemoteConfiguration) runConfiguration; // Server means if you are listening. If not you are attaching. remoteConfiguration.SERVER_MODE = false; remoteConfiguration.USE_SOCKET_TRANSPORT = true; remoteConfiguration.HOST = serverConfiguration.getHost(); remoteConfiguration.PORT = serverConfiguration.getConnectionDebugPort() + ""; // Set a Name of the Configuration so that it is properly listed. remoteConfiguration.setName(serverConfiguration.getName()); RunnerAndConfigurationSettings configuration = new RunnerAndConfigurationSettingsImpl( (RunManagerImpl) runManager, runConfiguration, false ); runManager.setTemporaryConfiguration(configuration); //AS TODO: Make sure that this is the proper way to obtain the DEBUG Executor Executor executor = ExecutorRegistry.getInstance().getExecutorById(ToolWindowId.DEBUG); ExecutionUtil.runConfiguration(configuration, executor); // Update the Modules with the Remote Sling Server OsgiClient osgiClient = obtainOSGiClient(); if(osgiClient != null) { BundleStatus status = checkAndUpdateSupportBundle(false); if(status != BundleStatus.failed) { checkModules(osgiClient); } } }
Example #9
Source File: OSSPantsIntegrationTest.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
private List<BeforeRunTask<?>> getBeforeRunTask(RunConfiguration configuration) { RunManagerImpl runManager = (RunManagerImpl) RunManager.getInstance(myProject); RunnerAndConfigurationSettingsImpl configurationSettings = new RunnerAndConfigurationSettingsImpl(runManager, configuration, true); runManager.addConfiguration(configurationSettings, true); List<BeforeRunTask<?>> tasks = runManager.getBeforeRunTasks(configuration); runManager.removeConfiguration(configurationSettings); return tasks; }
Example #10
Source File: GaugeRunProcessHandler.java From Intellij-Plugin with Apache License 2.0 | 5 votes |
private static void launchDebugger(final Project project, final GaugeDebugInfo debugInfo) { Runnable runnable = () -> { final long startTime = System.currentTimeMillis(); GenericDebuggerRunner basicProgramRunner = new GenericDebuggerRunner(); RunManagerImpl manager = new RunManagerImpl(project); ConfigurationFactory configFactory = RemoteConfigurationType.getInstance().getConfigurationFactories()[0]; RemoteConfiguration remoteConfig = new RemoteConfiguration(project, configFactory); remoteConfig.PORT = debugInfo.getPort(); remoteConfig.HOST = debugInfo.getHost(); remoteConfig.USE_SOCKET_TRANSPORT = true; remoteConfig.SERVER_MODE = false; RunnerAndConfigurationSettingsImpl configuration = new RunnerAndConfigurationSettingsImpl(manager, remoteConfig, false); ExecutionEnvironment environment = new ExecutionEnvironment(new DefaultDebugExecutor(), basicProgramRunner, configuration, project); boolean debuggerConnected = false; // Trying to connect to gauge java for 25 secs. The sleep is because it may take a few seconds for gauge to launch the java process and the jvm to load after that while (!debuggerConnected && ((System.currentTimeMillis() - startTime) < 25000)) { try { Thread.sleep(5000); basicProgramRunner.execute(environment); debuggerConnected = true; } catch (Exception e) { System.err.println("Failed to connect debugger. Retrying... : " + e.getMessage()); LOG.debug(e); } } }; ApplicationManager.getApplication().invokeAndWait(runnable, ModalityState.any()); }
Example #11
Source File: ExecutorAction.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static ConfigurationFromContext createConfiguration(RunConfigurationProducer<?> producer, ConfigurationContext context) { RunConfiguration configuration = producer.createLightConfiguration(context); if (configuration == null) return null; RunnerAndConfigurationSettingsImpl settings = new RunnerAndConfigurationSettingsImpl(RunManagerImpl.getInstanceImpl(context.getProject()), configuration, false); return new ConfigurationFromContextImpl(producer, settings, context.getPsiLocation()); }
Example #12
Source File: ChooseRunConfigurationPopup.java From consulo with Apache License 2.0 | 5 votes |
@Override public int getDefaultOptionIndex() { final RunnerAndConfigurationSettings currentConfiguration = RunManager.getInstance(myProject).getSelectedConfiguration(); if (currentConfiguration == null && myDefaultConfiguration != -1) { return myDefaultConfiguration; } return currentConfiguration instanceof RunnerAndConfigurationSettingsImpl ? getValues().indexOf(ItemWrapper.wrap(myProject, currentConfiguration)) : -1; }
Example #13
Source File: ChooseRunConfigurationPopup.java From consulo with Apache License 2.0 | 5 votes |
@Override public PopupStep onChosen(final ItemWrapper wrapper, boolean finalChoice) { if (myAction.myEditConfiguration) { final Object o = wrapper.getValue(); if (o instanceof RunnerAndConfigurationSettingsImpl) { return doFinalStep(new Runnable() { @Override public void run() { myAction.editConfiguration(myProject, (RunnerAndConfigurationSettings)o); } }); } } if (finalChoice && wrapper.available(myAction.getExecutor())) { return doFinalStep(new Runnable() { @Override public void run() { if (myAction.getExecutor() == myAction.myAlternativeExecutor) { PropertiesComponent.getInstance().setValue(myAction.myAddKey, Boolean.toString(true)); } wrapper.perform(myProject, myAction.getExecutor(), DataManager.getInstance().getDataContext()); } }); } else { return wrapper.getNextStep(myProject, myAction); } }
Example #14
Source File: ProjectExecutor.java From tmc-intellij with MIT License | 4 votes |
private ProgramRunner getRunner( Executor executor, RunnerAndConfigurationSettingsImpl selectedConfiguration) { logger.info("Getting ProgramRunner."); return RunnerRegistry.getInstance() .getRunner(executor.getId(), selectedConfiguration.getConfiguration()); }
Example #15
Source File: DebugConfigurationAction.java From MavenHelper with Apache License 2.0 | 4 votes |
private RunnerAndConfigurationSettings clone(RunnerAndConfigurationSettings configSettings) { RunnerAndConfigurationSettingsImpl runnerAndConfigurationSettings = (RunnerAndConfigurationSettingsImpl) configSettings; return runnerAndConfigurationSettings.clone(); }