Search in sources :

Example 6 with ExternalProjectsStateProvider

use of com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider in project intellij-community by JetBrains.

the class ExternalSystemTaskActivator method moveTasks.

public void moveTasks(@NotNull Collection<TaskActivationEntry> entries, int increment) {
    LOG.assertTrue(increment == -1 || increment == 1);
    final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
    for (TaskActivationEntry activationEntry : entries) {
        final TaskActivationState taskActivationState = stateProvider.getTasksActivation(activationEntry.systemId, activationEntry.projectPath);
        final List<String> tasks = taskActivationState.getTasks(activationEntry.phase);
        final int i1 = tasks.indexOf(activationEntry.taskName);
        final int i2 = i1 + increment;
        if (i1 != -1 && tasks.size() > i2 && i2 >= 0) {
            Collections.swap(tasks, i1, i2);
        }
    }
}
Also used : ExternalProjectsStateProvider(com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider)

Example 7 with ExternalProjectsStateProvider

use of com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider in project intellij-community by JetBrains.

the class ExternalSystemTaskActivator method moveProjects.

public void moveProjects(@NotNull ProjectSystemId systemId, @NotNull List<String> projectsPathsToMove, @Nullable Collection<String> pathsGroup, int increment) {
    LOG.assertTrue(increment == -1 || increment == 1);
    final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
    final Map<String, TaskActivationState> activationMap = stateProvider.getProjectsTasksActivationMap(systemId);
    final List<String> currentPaths = ContainerUtil.newArrayList(activationMap.keySet());
    if (pathsGroup != null) {
        currentPaths.retainAll(pathsGroup);
    }
    for (String path : projectsPathsToMove) {
        final int i1 = currentPaths.indexOf(path);
        final int i2 = i1 + increment;
        if (i1 != -1 && currentPaths.size() > i2 && i2 >= 0) {
            Collections.swap(currentPaths, i1, i2);
        }
    }
    Map<String, TaskActivationState> rearrangedMap = ContainerUtil.newLinkedHashMap();
    for (String path : currentPaths) {
        rearrangedMap.put(path, activationMap.get(path));
        activationMap.remove(path);
    }
    activationMap.putAll(rearrangedMap);
}
Also used : ExternalProjectsStateProvider(com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider)

Aggregations

ExternalProjectsStateProvider (com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider)7 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)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 AbstractExternalSystemTaskConfigurationType (com.intellij.openapi.externalSystem.service.execution.AbstractExternalSystemTaskConfigurationType)1 ExternalSystemRunConfiguration (com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration)1 Pair (com.intellij.openapi.util.Pair)1 FactoryMap (com.intellij.util.containers.FactoryMap)1