com.intellij.execution.RunManager Java Examples

The following examples show how to use com.intellij.execution.RunManager. 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: JavaStatusChecker.java    From embeddedlinux-jvmdebugger-intellij with Apache License 2.0 6 votes vote down vote up
/**
 * Stops the applications via the descriptor of configuration.  This gets called when the application finishes on the client side without maniually closing it.
 *
 * @param javaExitCode
 */
public void stopApplication(@NotNull int javaExitCode) {
    final RunManagerImpl runManager = (RunManagerImpl) RunManager.getInstance(project);
    final Collection<RunnerAndConfigurationSettings> allConfigurations = runManager.getSortedConfigurations();
    List<RunContentDescriptor> allDescriptors = ExecutionManager.getInstance(project).getContentManager().getAllDescriptors();
    boolean exitMsgDisplay = false;
    for (RunnerAndConfigurationSettings runConfiguration : allConfigurations) {
        if (runConfiguration.getConfiguration().getFactory().getType() instanceof EmbeddedLinuxJVMConfigurationType) {
            for (RunContentDescriptor descriptor : allDescriptors) {
                if (runConfiguration.getName().equals(descriptor.getDisplayName())) {
                    try {
                        if (!exitMsgDisplay) {
                            consoleView.print(EmbeddedLinuxJVMBundle.message("exit.code.message", javaExitCode), ConsoleViewContentType.SYSTEM_OUTPUT);
                            exitMsgDisplay = true;
                        }
                        descriptor.setProcessHandler(null);
                    } catch (Exception e) {

                    }
                }
            }

        }

    }
}
 
Example #2
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 #3
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 #4
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 #5
Source File: BlazeAndroidBinaryRunConfigurationHandler.java    From intellij with Apache License 2.0 6 votes vote down vote up
private int doMigrate(Project project) {
  int count = 0;
  for (RunConfiguration runConfig :
      RunManager.getInstance(project)
          .getConfigurationsList(BlazeCommandRunConfigurationType.getInstance())) {
    if (runConfig instanceof BlazeCommandRunConfiguration) {
      RunConfigurationState state =
          ((BlazeCommandRunConfiguration) runConfig).getHandler().getState();
      if (state instanceof BlazeAndroidBinaryRunConfigurationState) {
        ((BlazeAndroidBinaryRunConfigurationState) state)
            .setLaunchMethod(AndroidBinaryLaunchMethod.MOBILE_INSTALL);
        count++;
      }
    }
  }
  return count;
}
 
Example #6
Source File: RunConfigurationProducer.java    From consulo with Apache License 2.0 6 votes vote down vote up
/**
 * Searches the list of existing run configurations to find one created from this context. Returns one if found, or tries to create
 * a new configuration from this context if not found.
 *
 * @param context contains the information about a location in the source code.
 * @return a configuration (new or existing) matching the context, or null if the context is not applicable to this producer.
 */
@javax.annotation.Nullable
public ConfigurationFromContext findOrCreateConfigurationFromContext(ConfigurationContext context) {
  Location location = context.getLocation();
  if (location == null) {
    return null;
  }

  ConfigurationFromContext fromContext = createConfigurationFromContext(context);
  if (fromContext != null) {
    final PsiElement psiElement = fromContext.getSourceElement();
    final Location<PsiElement> _location = PsiLocation.fromPsiElement(psiElement, location.getModule());
    if (_location != null) {
      // replace with existing configuration if any
      final RunManager runManager = RunManager.getInstance(context.getProject());
      final RunnerAndConfigurationSettings settings = findExistingConfiguration(context);
      if (settings != null) {
        fromContext.setConfigurationSettings(settings);
      } else {
        runManager.setUniqueNameIfNeed(fromContext.getConfiguration());
      }
    }
  }

  return fromContext;
}
 
Example #7
Source File: PantsIntegrationTestCase.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
protected void assertAndRunPantsMake(JUnitConfiguration runConfiguration) {

    RunManager runManager = RunManager.getInstance(myProject);
    assertTrue(runManager instanceof RunManagerImpl);
    RunManagerImpl runManagerImpl = (RunManagerImpl) runManager;

    RunnerAndConfigurationSettings runnerAndConfigurationSettings =
      runManagerImpl.createConfiguration(runConfiguration, JUnitConfigurationType.getInstance().getConfigurationFactories()[0]);
    runManagerImpl.addConfiguration(runnerAndConfigurationSettings, false);

    // Make sure PantsMake is the one and only task before JUnit run.
    List<BeforeRunTask<?>> beforeRunTaskList = runManagerImpl.getBeforeRunTasks(runConfiguration);
    assertEquals(1, beforeRunTaskList.size());
    BeforeRunTask task = beforeRunTaskList.iterator().next();
    assertEquals(PantsMakeBeforeRun.ID, task.getProviderId());

    /*
     * Manually invoke BeforeRunTask as {@link ExecutionManager#compileAndRun} launches another task asynchronously,
     * and there is no way to catch that.
     */
    BeforeRunTaskProvider provider = BeforeRunTaskProvider.getProvider(myProject, task.getProviderId());
    assertNotNull(String.format("Cannot find BeforeRunTaskProvider for id='%s'", task.getProviderId()), provider);
    assertTrue(provider.executeTask(null, runConfiguration, null, task));
  }
 
Example #8
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 #9
Source File: ProjectExecutor.java    From tmc-intellij with MIT License 6 votes vote down vote up
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 #10
Source File: RunConfigurationNode.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void update(PresentationData presentation) {
  RunnerAndConfigurationSettings configurationSettings = getConfigurationSettings();
  boolean isStored = RunManager.getInstance(getProject()).hasSettings(configurationSettings);
  presentation.addText(configurationSettings.getName(),
                       isStored ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.GRAY_ATTRIBUTES);
  RunDashboardContributor contributor = RunDashboardContributor.getContributor(configurationSettings.getType());
  Image icon = null;
  if (contributor != null) {
    DashboardRunConfigurationStatus status = contributor.getStatus(this);
    if (DashboardRunConfigurationStatus.STARTED.equals(status)) {
      icon = getExecutorIcon();
    }
    else if (DashboardRunConfigurationStatus.FAILED.equals(status)) {
      icon = status.getIcon();
    }
  }
  if (icon == null) {
    icon = RunManagerEx.getInstanceEx(getProject()).getConfigurationIcon(configurationSettings);
  }
  presentation.setIcon(isStored ? icon : ImageEffects.grayed(icon));

  if (contributor != null) {
    contributor.updatePresentation(presentation, this);
  }
}
 
Example #11
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 #12
Source File: RunConfigurationRefactoringElementListenerProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public RefactoringElementListener getListener(final PsiElement element) {
  RefactoringElementListenerComposite composite = null;
  final RunConfiguration[] configurations = RunManager.getInstance(element.getProject()).getAllConfigurations();

  for (RunConfiguration configuration : configurations) {
    if (configuration instanceof RefactoringListenerProvider) { // todo: perhaps better way to handle listeners?
      final RefactoringElementListener listener;
      try {
        listener = ((RefactoringListenerProvider)configuration).getRefactoringElementListener(element);
      }
      catch (Exception e) {
        LOG.error(e);
        continue;
      }
      if (listener != null) {
        if (composite == null) {
          composite = new RefactoringElementListenerComposite();
        }
        composite.addListener(listener);
      }
    }
  }
  return composite;
}
 
Example #13
Source File: AbstractRunConfigurationTypeUsagesCollector.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public final Set<UsageDescriptor> getProjectUsages(@Nonnull final Project project) {
  final Set<String> runConfigurationTypes = new HashSet<String>();
  UIUtil.invokeAndWaitIfNeeded(new Runnable() {
    @Override
    public void run() {
      if (project.isDisposed()) return;
      final RunManager runManager = RunManager.getInstance(project);
      for (RunConfiguration runConfiguration : runManager.getAllConfigurationsList()) {
        if (runConfiguration != null && isApplicable(runManager, runConfiguration)) {
          final ConfigurationFactory configurationFactory = runConfiguration.getFactory();
          final ConfigurationType configurationType = configurationFactory.getType();
          final StringBuilder keyBuilder = new StringBuilder();
          keyBuilder.append(configurationType.getId());
          if (configurationType.getConfigurationFactories().length > 1) {
            keyBuilder.append(".").append(configurationFactory.getName());
          }
          runConfigurationTypes.add(keyBuilder.toString());
        }
      }
    }
  });
  return ContainerUtil.map2Set(runConfigurationTypes, runConfigurationType -> new UsageDescriptor(runConfigurationType, 1));
}
 
Example #14
Source File: TaskRunner.java    From JHelper with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Nullable
private static RunnerAndConfigurationSettings getSettingsByName(@NotNull Project project, String name) {
	for (RunnerAndConfigurationSettings configuration : RunManager.getInstance(project).getAllSettings()) {
		if (configuration.getName().equals(name)) {
			return configuration;
		}
	}
	return null;
}
 
Example #15
Source File: OSSPantsIntegrationTest.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
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 #16
Source File: PantsClasspathRunConfigurationExtension.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * The goal of this function is to find classpath for IntelliJ JUnit/Scala runner.
 * <p/>
 * This function will fail if the projects' Pants doesn't support `--export-classpath-manifest-jar-only`.
 * It also assumes that Pants has created a manifest jar that contains all the classpath links for the
 * particular test that's being run.
 */
@Override
public <T extends RunConfigurationBase> void updateJavaParameters(
  T configuration,
  @NotNull JavaParameters params,
  RunnerSettings runnerSettings
) throws ExecutionException {
  List<BeforeRunTask<?>> tasks = ((RunManagerImpl) RunManager.getInstance(configuration.getProject())).getBeforeRunTasks(configuration);
  boolean builtByPants = tasks.stream().anyMatch(s -> s.getProviderId().equals(PantsMakeBeforeRun.ID));
  // Not built by Pants means it was built by IntelliJ, in which case we don't need to change the classpath.
  if (!builtByPants) {
    return;
  }

  final Module module = findPantsModule(configuration);
  if (module == null) {
    return;
  }

  Set<String> pathsAllowed = calculatePathsAllowed(params);

  final PathsList classpath = params.getClassPath();
  List<String> classpathToKeep = classpath.getPathList().stream()
    .filter(cp -> pathsAllowed.stream().anyMatch(cp::contains)).collect(Collectors.toList());
  classpath.clear();
  classpath.addAll(classpathToKeep);

  VirtualFile manifestJar = PantsUtil.findProjectManifestJar(configuration.getProject())
    .orElseThrow(() -> new ExecutionException("manifest.jar is not found. It should be generated by `./pants export-classpath ...`"));
  classpath.add(manifestJar.getPath());

  PantsExternalMetricsListenerManager.getInstance().logTestRunner(configuration);
}
 
Example #17
Source File: DumpConfigurationTypesAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final Project project = e.getDataContext().getData(CommonDataKeys.PROJECT);
  final ConfigurationType[] factories =
    RunManager.getInstance(project).getConfigurationFactories();
  for (ConfigurationType factory : factories) {
    System.out.println(factory.getDisplayName() + " : " + factory.getId());
  }
}
 
Example #18
Source File: PantsMakeBeforeRun.java    From intellij-pants-plugin with Apache License 2.0 5 votes vote down vote up
public static void replaceDefaultMakeWithPantsMake(@NotNull RunConfiguration runConfiguration) {
  if (!PantsUtil.isScalaRelatedTestRunConfiguration(runConfiguration) &&
      !(runConfiguration instanceof CommonProgramRunConfigurationParameters)) {
    return;
  }

  RunManager runManager = RunManager.getInstance(runConfiguration.getProject());
  RunManagerImpl runManagerImpl = (RunManagerImpl) runManager;
  BeforeRunTask pantsMakeTask = new ExternalSystemBeforeRunTask(ID, PantsConstants.SYSTEM_ID);
  pantsMakeTask.setEnabled(true);
  runManagerImpl.setBeforeRunTasks(runConfiguration, Collections.singletonList(pantsMakeTask));
}
 
Example #19
Source File: MainMavenActionGroup.java    From MavenHelper with Apache License 2.0 5 votes vote down vote up
private void addRunConfigurations(List<AnAction> result, Project project, final MavenProjectInfo mavenProject) {
	final List<RunnerAndConfigurationSettings> configurationSettings = RunManager.getInstance(project).getConfigurationSettingsList(
		MavenRunConfigurationType.getInstance());

	String directory = PathUtil.getCanonicalPath(mavenProject.mavenProject.getDirectory());

	for (RunnerAndConfigurationSettings cfg : configurationSettings) {
		MavenRunConfiguration mavenRunConfiguration = (MavenRunConfiguration) cfg.getConfiguration();
		if (directory.equals(PathUtil.getCanonicalPath(mavenRunConfiguration.getRunnerParameters().getWorkingDirPath()))) {
			result.add(getRunConfigurationAction(project, cfg));
		}
	}
}
 
Example #20
Source File: RunConfigurationProducer.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * Searches the list of existing run configurations to find one created from this context. Returns one if found.
 *
 * @param context contains the information about a location in the source code.
 * @return an existing configuration matching the context, or null if no such configuration is found.
 */
@javax.annotation.Nullable
public RunnerAndConfigurationSettings findExistingConfiguration(ConfigurationContext context) {
  final RunManager runManager = RunManager.getInstance(context.getProject());
  final List<RunnerAndConfigurationSettings> configurations = runManager.getConfigurationSettingsList(myConfigurationFactory.getType());
  for (RunnerAndConfigurationSettings configurationSettings : configurations) {
    if (isConfigurationFromContext((T) configurationSettings.getConfiguration(), context)) {
      return configurationSettings;
    }
  }
  return null;
}
 
Example #21
Source File: RunConfigurationProducer.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected RunnerAndConfigurationSettings cloneTemplateConfiguration(@Nonnull final ConfigurationContext context) {
  final RunConfiguration original = context.getOriginalConfiguration(myConfigurationFactory.getType());
  if (original != null) {
    return RunManager.getInstance(context.getProject()).createConfiguration(original.clone(), myConfigurationFactory);
  }
  return RunManager.getInstance(context.getProject()).createRunConfiguration("", myConfigurationFactory);
}
 
Example #22
Source File: BaseProgramRunner.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(@Nonnull ExecutionEnvironment environment, @javax.annotation.Nullable Callback callback) throws ExecutionException {
  RunProfileState state = environment.getState();
  if (state == null) {
    return;
  }

  RunManager.getInstance(environment.getProject()).refreshUsagesList(environment.getRunProfile());
  execute(environment, callback, state);
}
 
Example #23
Source File: CreateAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static BaseCreatePolicy choosePolicy(final ConfigurationContext context) {
  final RunnerAndConfigurationSettings configuration = context.findExisting();
  if (configuration == null) return CREATE_AND_EDIT;
  final RunManager runManager = context.getRunManager();
  if (runManager.getSelectedConfiguration() != configuration) return SELECT;
  if (configuration.isTemporary()) return SAVE;
  return SELECTED_STABLE;
}
 
Example #24
Source File: TomcatRunConfigurationProducer.java    From SmartTomcat with Apache License 2.0 5 votes vote down vote up
@Override
protected boolean setupConfigurationFromContext(@NotNull TomcatRunConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) {

    boolean result = isConfigurationFromContext(configuration, context);

    if (result) {
        List<TomcatInfo> tomcatInfos = TomcatInfoConfigs.getInstance().getTomcatInfos();
        if (tomcatInfos != null && tomcatInfos.size() > 0) {
            TomcatInfo tomcatInfo = tomcatInfos.get(0);
            configuration.setTomcatInfo(tomcatInfo);
        } else  {
            throw new RuntimeException("Not found any Tomcat Server, please add Tomcat Server first.");
        }

        VirtualFile virtualFile = context.getLocation().getVirtualFile();
        Module module = context.getModule();
        configuration.setName(module.getName());
        configuration.setDocBase(virtualFile.getCanonicalPath());
        configuration.setContextPath("/" + module.getName());
        configuration.setModuleName(module.getName());

        final RunnerAndConfigurationSettings settings =
                RunManager.getInstance(context.getProject()).createConfiguration(configuration, getConfigurationFactory());
        settings.setName(module.getName() + " in SmartTomcat");
    }
    return result;
}
 
Example #25
Source File: IDEUtils.java    From JHelper with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static void chooseConfigurationAndTarget(
		Project project,
		RunnerAndConfigurationSettings runConfiguration,
		ExecutionTarget target
) {
	RunManager.getInstance(project).setSelectedConfiguration(runConfiguration);
	ExecutionTargetManager.getInstance(project).setActiveTarget(target);
}
 
Example #26
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 #27
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 #28
Source File: RunProjectAction.java    From tmc-intellij with MIT License 5 votes vote down vote up
/**
 * Main run method, readies project module for running. First it finds current module, then
 * checks, whether it has a valid runconfiguration or not. If it does not, it creates one,
 * otherwise current configuration is run as is as long as it has a main class.
 */
private void runProject(Project project) {
    logger.info("Run project action called.");
    logger.info("Getting RunManager.");
    RunManager runManager = RunManager.getInstance(project);
    Module module = getModule(project);
    String configurationType = getConfigurationType();
    logger.info("Creating RunProject object.");
    new RunProject(runManager, module, configurationType);
}
 
Example #29
Source File: ProjectExecutor.java    From tmc-intellij with MIT License 5 votes vote down vote up
@NotNull
private RunnerAndConfigurationSettingsImpl getApplicationRunnerAndConfigurationSettings(
        RunManager runManager, ModuleBasedConfiguration appCon) {
    logger.info("Getting RunnerAndConfigurationSettings implementation.");
    return new RunnerAndConfigurationSettingsImpl(
            (RunManagerImpl) runManager,
            appCon,
            runManager.getSelectedConfiguration().isTemplate());
}
 
Example #30
Source File: RunProject.java    From tmc-intellij with MIT License 5 votes vote down vote up
public RunProject(RunManager runManager, Module module, String configurationType) {
    logger.info("Creating RunConfigurationFactory.");
    factory = new RunConfigurationFactory(runManager, module, configurationType);
    if (makeSureConfigurationIsCorrectType(runManager)) {
        return;
    }
    factory.createRunner();
}