use of com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider 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);
}
use of com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider in project intellij-community by JetBrains.
the class ExternalSystemTaskActivator method addTasks.
public void addTasks(@NotNull Collection<TaskActivationEntry> entries) {
if (entries.isEmpty())
return;
final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
for (TaskActivationEntry entry : entries) {
final TaskActivationState taskActivationState = stateProvider.getTasksActivation(entry.systemId, entry.projectPath);
taskActivationState.getTasks(entry.phase).add(entry.taskName);
}
fireTasksChanged();
}
use of com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider in project intellij-community by JetBrains.
the class ExternalSystemTaskActivator method isTaskOfPhase.
public boolean isTaskOfPhase(@NotNull TaskData taskData, @NotNull Phase phase) {
final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
final TaskActivationState taskActivationState = stateProvider.getTasksActivation(taskData.getOwner(), taskData.getLinkedExternalProjectPath());
if (taskActivationState == null)
return false;
return taskActivationState.getTasks(phase).contains(taskData.getName());
}
use of com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider in project intellij-community by JetBrains.
the class ExternalSystemTaskActivator method getDescription.
public String getDescription(ProjectSystemId systemId, String projectPath, String taskName) {
List<String> result = new ArrayList<>();
final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
final TaskActivationState taskActivationState = stateProvider.getTasksActivation(systemId, projectPath);
if (taskActivationState == null)
return null;
for (Phase phase : Phase.values()) {
if (taskActivationState.getTasks(phase).contains(taskName)) {
result.add(phase.toString());
}
}
return StringUtil.join(result, ", ");
}
use of com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManager.ExternalProjectsStateProvider in project intellij-community by JetBrains.
the class ExternalSystemTaskActivator method removeTasks.
public void removeTasks(@NotNull Collection<TaskActivationEntry> entries) {
if (entries.isEmpty())
return;
final ExternalProjectsStateProvider stateProvider = ExternalProjectsManager.getInstance(myProject).getStateProvider();
for (TaskActivationEntry activationEntry : entries) {
final TaskActivationState taskActivationState = stateProvider.getTasksActivation(activationEntry.systemId, activationEntry.projectPath);
taskActivationState.getTasks(activationEntry.phase).remove(activationEntry.taskName);
}
fireTasksChanged();
}
Aggregations