Search in sources :

Example 1 with AbstractExternalSystemTaskConfigurationType

use of com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType in project intellij-community by JetBrains.

the class RunConfigurationsNode method doBuildChildren.

@NotNull
@Override
protected List<? extends ExternalSystemNode> doBuildChildren() {
    List<ExternalSystemNode> runConfigurationNodes = ContainerUtil.newArrayList();
    final AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(myModuleData.getOwner());
    if (configurationType == null)
        return Collections.emptyList();
    Set<RunnerAndConfigurationSettings> settings = new THashSet<>(RunManager.getInstance(myProject).getConfigurationSettingsList(configurationType));
    String directory = PathUtil.getCanonicalPath(myModuleData.getLinkedExternalProjectPath());
    for (RunnerAndConfigurationSettings cfg : settings) {
        ExternalSystemRunConfiguration externalSystemRunConfiguration = (ExternalSystemRunConfiguration) cfg.getConfiguration();
        if (directory.equals(PathUtil.getCanonicalPath(externalSystemRunConfiguration.getSettings().getExternalProjectPath()))) {
            runConfigurationNodes.add(new RunConfigurationNode(getExternalProjectsView(), this, cfg));
        }
    }
    return runConfigurationNodes;
}
Also used : RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) AbstractExternalSystemTaskConfigurationType(com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType) THashSet(gnu.trove.THashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with AbstractExternalSystemTaskConfigurationType

use of com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType in project intellij-community by JetBrains.

the class ExternalSystemKeymapExtension method updateRunConfigurationActions.

public static void updateRunConfigurationActions(Project project, ProjectSystemId systemId) {
    final AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(systemId);
    if (configurationType == null)
        return;
    ActionManager actionManager = ActionManager.getInstance();
    for (String eachAction : actionManager.getActionIds(getActionPrefix(project, null))) {
        AnAction action = actionManager.getAction(eachAction);
        if (action instanceof ExternalSystemRunConfigurationAction) {
            actionManager.unregisterAction(eachAction);
        }
    }
    Set<RunnerAndConfigurationSettings> settings = new THashSet<>(RunManager.getInstance(project).getConfigurationSettingsList(configurationType));
    final ExternalSystemShortcutsManager shortcutsManager = ExternalProjectsManager.getInstance(project).getShortcutsManager();
    for (RunnerAndConfigurationSettings configurationSettings : settings) {
        ExternalSystemRunConfigurationAction runConfigurationAction = new ExternalSystemRunConfigurationAction(project, configurationSettings);
        String id = runConfigurationAction.getId();
        actionManager.unregisterAction(id);
        if (shortcutsManager.hasShortcuts(id)) {
            actionManager.registerAction(id, runConfigurationAction);
        }
    }
}
Also used : RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) AbstractExternalSystemTaskConfigurationType(com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType) THashSet(gnu.trove.THashSet)

Example 3 with AbstractExternalSystemTaskConfigurationType

use of com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType in project intellij-community by JetBrains.

the class ExternalSystemRunManagerListener method attach.

public void attach() {
    myMap.clear();
    for (ExternalSystemManager<?, ?, ?, ?, ?> systemManager : ExternalSystemApiUtil.getAllManagers()) {
        final AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(systemManager.getSystemId());
        if (configurationType == null)
            continue;
        final List<RunnerAndConfigurationSettings> configurationSettingsList = RunManager.getInstance(myManager.getProject()).getConfigurationSettingsList(configurationType);
        for (RunnerAndConfigurationSettings configurationSettings : configurationSettingsList) {
            add(myMap, configurationSettings);
        }
    }
    ((RunManagerEx) RunManager.getInstance(myManager.getProject())).addRunManagerListener(this);
}
Also used : RunManagerEx(com.intellij.execution.RunManagerEx) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) AbstractExternalSystemTaskConfigurationType(com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType)

Example 4 with AbstractExternalSystemTaskConfigurationType

use of com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType in project intellij-community by JetBrains.

the class ExternalSystemTaskActivator method runTasks.

public boolean runTasks(@NotNull Collection<String> modules, @NotNull Phase... phases) {
    final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
    final Queue<Pair<ProjectSystemId, ExternalSystemTaskExecutionSettings>> tasksQueue = new LinkedList<>();
    //noinspection MismatchedQueryAndUpdateOfCollection
    Map<ProjectSystemId, Map<String, RunnerAndConfigurationSettings>> lazyConfigurationsMap = new FactoryMap<ProjectSystemId, Map<String, RunnerAndConfigurationSettings>>() {

        @Nullable
        @Override
        protected Map<String, RunnerAndConfigurationSettings> create(ProjectSystemId key) {
            final AbstractExternalSystemTaskConfigurationType configurationType = ExternalSystemUtil.findConfigurationType(key);
            if (configurationType == null)
                return null;
            return ContainerUtil.map2Map(RunManager.getInstance(myProject).getConfigurationSettingsList(configurationType), configurationSettings -> Pair.create(configurationSettings.getName(), configurationSettings));
        }
    };
    for (final ExternalProjectsStateProvider.TasksActivation activation : stateProvider.getAllTasksActivation()) {
        final boolean hashPath = modules.contains(activation.projectPath);
        final Set<String> tasks = ContainerUtil.newLinkedHashSet();
        for (Phase phase : phases) {
            List<String> activationTasks = activation.state.getTasks(phase);
            if (hashPath || (phase.isSyncPhase() && !activationTasks.isEmpty() && isShareSameRootPath(modules, activation))) {
                ContainerUtil.addAll(tasks, activationTasks);
            }
        }
        if (tasks.isEmpty())
            continue;
        for (Iterator<String> iterator = tasks.iterator(); iterator.hasNext(); ) {
            String task = iterator.next();
            if (task.length() > RUN_CONFIGURATION_TASK_PREFIX.length() && task.startsWith(RUN_CONFIGURATION_TASK_PREFIX)) {
                iterator.remove();
                final String configurationName = task.substring(RUN_CONFIGURATION_TASK_PREFIX.length());
                Map<String, RunnerAndConfigurationSettings> settings = lazyConfigurationsMap.get(activation.systemId);
                if (settings == null)
                    continue;
                RunnerAndConfigurationSettings configurationSettings = settings.get(configurationName);
                if (configurationSettings == null)
                    continue;
                final RunConfiguration runConfiguration = configurationSettings.getConfiguration();
                if (configurationName.equals(configurationSettings.getName()) && runConfiguration instanceof ExternalSystemRunConfiguration) {
                    tasksQueue.add(Pair.create(activation.systemId, ((ExternalSystemRunConfiguration) runConfiguration).getSettings()));
                }
            }
        }
        if (tasks.isEmpty())
            continue;
        if (ExternalProjectsManager.getInstance(myProject).isIgnored(activation.systemId, activation.projectPath))
            continue;
        ExternalSystemTaskExecutionSettings executionSettings = new ExternalSystemTaskExecutionSettings();
        executionSettings.setExternalSystemIdString(activation.systemId.toString());
        executionSettings.setExternalProjectPath(activation.projectPath);
        executionSettings.getTaskNames().addAll(tasks);
        tasksQueue.add(Pair.create(activation.systemId, executionSettings));
    }
    return runTasksQueue(tasksQueue);
}
Also used : FactoryMap(com.intellij.util.containers.FactoryMap) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) ExternalProjectsStateProvider(com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider) RunConfiguration(com.intellij.execution.configurations.RunConfiguration) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) FactoryMap(com.intellij.util.containers.FactoryMap) AbstractExternalSystemTaskConfigurationType(com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType) Pair(com.intellij.openapi.util.Pair) ExternalSystemTaskExecutionSettings(com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)

Example 5 with AbstractExternalSystemTaskConfigurationType

use of com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType in project intellij-community by JetBrains.

the class ExternalSystemUtil method createExternalSystemRunnerAndConfigurationSettings.

@Nullable
public static RunnerAndConfigurationSettings createExternalSystemRunnerAndConfigurationSettings(@NotNull ExternalSystemTaskExecutionSettings taskSettings, @NotNull Project project, @NotNull ProjectSystemId externalSystemId) {
    AbstractExternalSystemTaskConfigurationType configurationType = findConfigurationType(externalSystemId);
    if (configurationType == null)
        return null;
    String name = AbstractExternalSystemTaskConfigurationType.generateName(project, taskSettings);
    RunnerAndConfigurationSettings settings = RunManager.getInstance(project).createRunConfiguration(name, configurationType.getFactory());
    ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration) settings.getConfiguration();
    runConfiguration.getSettings().setExternalProjectPath(taskSettings.getExternalProjectPath());
    runConfiguration.getSettings().setTaskNames(ContainerUtil.newArrayList(taskSettings.getTaskNames()));
    runConfiguration.getSettings().setTaskDescriptions(ContainerUtil.newArrayList(taskSettings.getTaskDescriptions()));
    runConfiguration.getSettings().setVmOptions(taskSettings.getVmOptions());
    runConfiguration.getSettings().setScriptParameters(taskSettings.getScriptParameters());
    runConfiguration.getSettings().setExecutionName(taskSettings.getExecutionName());
    return settings;
}
Also used : ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) AbstractExternalSystemTaskConfigurationType(com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

AbstractExternalSystemTaskConfigurationType (com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType)5 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)4 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)3 THashSet (gnu.trove.THashSet)2 RunManagerEx (com.intellij.execution.RunManagerEx)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)1 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)1 ExternalProjectsStateProvider (com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider)1 Pair (com.intellij.openapi.util.Pair)1 FactoryMap (com.intellij.util.containers.FactoryMap)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1