Search in sources :

Example 1 with Phase

use of com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator.Phase in project intellij-community by JetBrains.

the class ExternalSystemRunManagerListener method runConfigurationRemoved.

@Override
public void runConfigurationRemoved(@NotNull RunnerAndConfigurationSettings settings) {
    if (settings.getConfiguration() instanceof ExternalSystemRunConfiguration) {
        final Pair<String, RunnerAndConfigurationSettings> pair = myMap.remove(System.identityHashCode(settings));
        if (pair == null)
            return;
        final ExternalProjectsManager.ExternalProjectsStateProvider stateProvider = myManager.getStateProvider();
        final ExternalSystemTaskExecutionSettings taskExecutionSettings = ((ExternalSystemRunConfiguration) settings.getConfiguration()).getSettings();
        if (taskExecutionSettings.getExternalProjectPath() == null)
            return;
        final TaskActivationState activation = stateProvider.getTasksActivation(taskExecutionSettings.getExternalSystemId(), taskExecutionSettings.getExternalProjectPath());
        for (Phase phase : Phase.values()) {
            for (Iterator<String> iterator = activation.getTasks(phase).iterator(); iterator.hasNext(); ) {
                String task = iterator.next();
                if (pair.first.equals(task)) {
                    iterator.remove();
                    break;
                }
            }
        }
    }
}
Also used : Phase(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator.Phase) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemTaskExecutionSettings(com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)

Example 2 with Phase

use of com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator.Phase in project intellij-community by JetBrains.

the class ExternalSystemRunManagerListener method runConfigurationChanged.

@Override
public void runConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
    if (settings.getConfiguration() instanceof ExternalSystemRunConfiguration) {
        final Pair<String, RunnerAndConfigurationSettings> pair = myMap.get(System.identityHashCode(settings));
        if (pair != null) {
            final ExternalProjectsManager.ExternalProjectsStateProvider stateProvider = myManager.getStateProvider();
            final ExternalSystemTaskExecutionSettings taskExecutionSettings = ((ExternalSystemRunConfiguration) settings.getConfiguration()).getSettings();
            if (taskExecutionSettings.getExternalProjectPath() == null)
                return;
            final TaskActivationState activation = stateProvider.getTasksActivation(taskExecutionSettings.getExternalSystemId(), taskExecutionSettings.getExternalProjectPath());
            for (Phase phase : Phase.values()) {
                final List<String> modifiableActivationTasks = activation.getTasks(phase);
                for (String task : ContainerUtil.newArrayList(modifiableActivationTasks)) {
                    if (pair.first.equals(task)) {
                        modifiableActivationTasks.remove(task);
                        final String runConfigurationActivationTaskName = getRunConfigurationActivationTaskName(settings);
                        modifiableActivationTasks.add(runConfigurationActivationTaskName);
                        myMap.put(System.identityHashCode(settings), Pair.create(runConfigurationActivationTaskName, settings));
                        break;
                    }
                }
            }
        }
    }
}
Also used : Phase(com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator.Phase) ExternalSystemRunConfiguration(com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) ExternalSystemTaskExecutionSettings(com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)

Aggregations

RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)2 ExternalSystemTaskExecutionSettings (com.intellij.openapi.externalSystem.model.execution.ExternalSystemTaskExecutionSettings)2 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)2 Phase (com.intellij.openapi.externalSystem.service.project.manage.ExternalSystemTaskActivator.Phase)2