use of com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration 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;
}
use of com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration 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;
}
}
}
}
}
use of com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration 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;
}
}
}
}
}
}
use of com.intellij.openapi.externalSystem.service.execution.ExternalSystemRunConfiguration 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.execution.ExternalSystemRunConfiguration in project intellij-community by JetBrains.
the class ToggleTaskActivationAction method getTasks.
@NotNull
private static List<TaskData> getTasks(AnActionEvent e) {
final List<ExternalSystemNode> selectedNodes = ExternalSystemDataKeys.SELECTED_NODES.getData(e.getDataContext());
if (selectedNodes == null)
return Collections.emptyList();
List<TaskData> tasks = new SmartList<>();
for (ExternalSystemNode node : selectedNodes) {
if (node instanceof TaskNode && !node.isIgnored()) {
tasks.add((TaskData) node.getData());
} else if (node instanceof RunConfigurationNode) {
final RunnerAndConfigurationSettings configurationSettings = ((RunConfigurationNode) node).getSettings();
final ExternalSystemRunConfiguration runConfiguration = (ExternalSystemRunConfiguration) configurationSettings.getConfiguration();
final ExternalSystemTaskExecutionSettings taskExecutionSettings = runConfiguration.getSettings();
tasks.add(new TaskData(taskExecutionSettings.getExternalSystemId(), RUN_CONFIGURATION_TASK_PREFIX + configurationSettings.getName(), taskExecutionSettings.getExternalProjectPath(), null));
} else {
return Collections.emptyList();
}
}
return tasks;
}
Aggregations