Java Code Examples for com.intellij.execution.RunManager#setSelectedConfiguration()

The following examples show how to use com.intellij.execution.RunManager#setSelectedConfiguration() . 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: BlazeRunConfigurationSyncListener.java    From intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Adds a run configuration for an android_binary target if there is not already a configuration
 * for that target.
 */
private static void maybeAddRunConfiguration(
    Project project, BlazeProjectData blazeProjectData, Label label) {
  RunManager runManager = RunManager.getInstance(project);

  for (BlazeRunConfigurationFactory configurationFactory :
      BlazeRunConfigurationFactory.EP_NAME.getExtensions()) {
    if (configurationFactory.handlesTarget(project, blazeProjectData, label)) {
      final RunnerAndConfigurationSettings settings =
          configurationFactory.createForTarget(project, runManager, label);
      runManager.addConfiguration(settings, /* isShared= */ false);
      if (runManager.getSelectedConfiguration() == null) {
        runManager.setSelectedConfiguration(settings);
      }
      break;
    }
  }
}
 
Example 2
Source File: ProjectUtils.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * adds run configuration dynamically
 * @param module
 * @param mainClass
 * @param boardName
 */
public static void addProjectConfiguration(final Module module, final String mainClass, final String boardName) {
    final Runnable r = new Runnable() {
        @Override
        public void run() {
            final RunManager runManager = RunManager.getInstance(module.getProject());
            final RunnerAndConfigurationSettings settings = runManager.
                    createRunConfiguration(module.getName(), EmbeddedLinuxJVMConfigurationType.getInstance().getFactory());
            final EmbeddedLinuxJVMRunConfiguration configuration = (EmbeddedLinuxJVMRunConfiguration) settings.getConfiguration();

            configuration.setName(EmbeddedLinuxJVMBundle.message("runner.name", boardName));
            configuration.getRunnerParameters().setRunAsRoot(true);
            configuration.getRunnerParameters().setMainclass(mainClass);

            runManager.addConfiguration(settings, false);
            runManager.setSelectedConfiguration(settings);

            final Notification notification = new Notification(
                    Notifications.GROUPDISPLAY_ID,
                    EmbeddedLinuxJVMBundle.getString("pi.connection.required"), EmbeddedLinuxJVMBundle.message("pi.connection.notsetup", boardName),
                    NotificationType.INFORMATION);
            com.intellij.notification.Notifications.Bus.notify(notification);
        }
    };
    r.run();
}
 
Example 3
Source File: TaskUtils.java    From JHelper with GNU Lesser General Public License v3.0 6 votes vote down vote up
private static void createConfigurationForTask(Project project, TaskData taskData) {
	TaskConfigurationType configurationType = new TaskConfigurationType();
	ConfigurationFactory factory = configurationType.getConfigurationFactories()[0];

	RunManager manager = RunManager.getInstance(project);
	TaskConfiguration taskConfiguration = new TaskConfiguration(
			project,
			factory
	);
	taskConfiguration.setFromTaskData(taskData);
	RunnerAndConfigurationSettings configuration = manager.createConfiguration(
			taskConfiguration,
			factory
	);
	manager.addConfiguration(configuration, true);

	manager.setSelectedConfiguration(configuration);
}
 
Example 4
Source File: HaxeModuleBuilder.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
private void createDefaultRunConfiguration(Module module, String buildHxmlPath) {
  HaxeModuleSettings settings = HaxeModuleSettings.getInstance(module);
  settings.setHaxeTarget(HaxeTarget.INTERP);
  settings.setBuildConfig(HaxeConfiguration.HXML.asBuildConfigValue());
  settings.setHxmlPath(buildHxmlPath);
  RunManager manager = RunManager.getInstance(module.getProject());
  HaxeRunConfigurationType configType = HaxeRunConfigurationType.getInstance();
  if(manager.getConfigurationsList(configType).isEmpty()) {
    ConfigurationFactory factory = configType.getConfigurationFactories()[0];
    HaxeApplicationConfiguration config = (HaxeApplicationConfiguration)factory.createTemplateConfiguration(module.getProject());
    config.setName("Execute");
    config.setModule(module);
    RunnerAndConfigurationSettings runSettings = manager.createConfiguration(config, factory);
    manager.addConfiguration(runSettings, false);
    manager.setSelectedConfiguration(runSettings);
  }
}
 
Example 5
Source File: HaxeProjectConfigurationUpdater.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
private void setupHxmlRunConfigurations(Module module) {
  RunManager manager = RunManager.getInstance(module.getProject());
  HaxeRunConfigurationType configType = HaxeRunConfigurationType.getInstance();
  ConfigurationFactory factory = configType.getConfigurationFactories()[0];

  HaxeModuleSettings settings = HaxeModuleSettings.getInstance(module);
  String hxmlPath = settings.getHxmlPath();
  if(hxmlPath != null && !hxmlPath.isEmpty()) {
    HaxeApplicationConfiguration config = (HaxeApplicationConfiguration)factory.createTemplateConfiguration(module.getProject());
    config.setName(module.getName() + " " + new File(hxmlPath).getName());
    config.setModule(module);
    RunnerAndConfigurationSettings runSettings = manager.createConfiguration(config, factory);
    manager.addConfiguration(runSettings, false);
    manager.setSelectedConfiguration(runSettings);
  }
}
 
Example 6
Source File: FlutterModuleUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Ensures a Flutter run configuration is selected in the run pull down.
 */
public static void ensureRunConfigSelected(@NotNull Project project) {
  if (project.isDisposed()) return;
  final FlutterRunConfigurationType configType = FlutterRunConfigurationType.getInstance();

  final RunManager runManager = RunManager.getInstance(project);
  if (!runManager.getConfigurationsList(configType).isEmpty()) {
    if (runManager.getSelectedConfiguration() == null) {
      final List<RunnerAndConfigurationSettings> flutterConfigs = runManager.getConfigurationSettingsList(configType);
      if (!flutterConfigs.isEmpty()) {
        runManager.setSelectedConfiguration(flutterConfigs.get(0));
      }
    }
  }
}
 
Example 7
Source File: FlutterModuleUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Ensures a Flutter run configuration is selected in the run pull down.
 */
public static void ensureRunConfigSelected(@NotNull Project project) {
  if (project.isDisposed()) return;
  final FlutterRunConfigurationType configType = FlutterRunConfigurationType.getInstance();

  final RunManager runManager = RunManager.getInstance(project);
  if (!runManager.getConfigurationsList(configType).isEmpty()) {
    if (runManager.getSelectedConfiguration() == null) {
      final List<RunnerAndConfigurationSettings> flutterConfigs = runManager.getConfigurationSettingsList(configType);
      if (!flutterConfigs.isEmpty()) {
        runManager.setSelectedConfiguration(flutterConfigs.get(0));
      }
    }
  }
}