com.intellij.openapi.externalSystem.model.task.TaskData Java Examples

The following examples show how to use com.intellij.openapi.externalSystem.model.task.TaskData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GradleMonitor.java    From spring-javaformat with Apache License 2.0 5 votes vote down vote up
private boolean hasFormatPlugin(DataNode<?> node) {
	if (node == null) {
		return false;
	}
	Object data = node.getData();
	if (data instanceof TaskData && isFormatPlugin((TaskData) data)) {
		return true;
	}
	for (DataNode<?> child : node.getChildren()) {
		if (hasFormatPlugin(child)) {
			return true;
		}
	}
	return false;
}
 
Example #2
Source File: AndroidUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@SuppressWarnings("DuplicatedCode")
private static Map<ProjectData, MultiMap<String, String>> getTasksMap(Project project) {
  Map<ProjectData, MultiMap<String, String>> tasks = new LinkedHashMap<>();
  for (GradleProjectSettings setting : GradleSettings.getInstance(project).getLinkedProjectsSettings()) {
    final ExternalProjectInfo projectData =
      ProjectDataManager.getInstance().getExternalProjectData(project, GradleConstants.SYSTEM_ID, setting.getExternalProjectPath());
    if (projectData == null || projectData.getExternalProjectStructure() == null) continue;

    MultiMap<String, String> projectTasks = MultiMap.createOrderedSet();
    for (DataNode<ModuleData> moduleDataNode : getChildren(projectData.getExternalProjectStructure(), ProjectKeys.MODULE)) {
      String gradlePath;
      String moduleId = moduleDataNode.getData().getId();
      if (moduleId.charAt(0) != ':') {
        int colonIndex = moduleId.indexOf(':');
        gradlePath = colonIndex > 0 ? moduleId.substring(colonIndex) : ":";
      }
      else {
        gradlePath = moduleId;
      }
      for (DataNode<TaskData> node : getChildren(moduleDataNode, ProjectKeys.TASK)) {
        TaskData taskData = node.getData();
        String taskName = taskData.getName();
        if (isNotEmpty(taskName)) {
          String taskPathPrefix = ":".equals(gradlePath) || taskName.startsWith(gradlePath) ? "" : (gradlePath + ':');
          projectTasks.putValue(taskPathPrefix, taskName);
        }
      }
    }
    tasks.put(projectData.getExternalProjectStructure().getData(), projectTasks);
  }
  return tasks;
}
 
Example #3
Source File: AndroidUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
@SuppressWarnings("DuplicatedCode")
private static Map<ProjectData, MultiMap<String, String>> getTasksMap(Project project) {
  Map<ProjectData, MultiMap<String, String>> tasks = new LinkedHashMap<>();
  for (GradleProjectSettings setting : GradleSettings.getInstance(project).getLinkedProjectsSettings()) {
    final ExternalProjectInfo projectData =
      ProjectDataManager.getInstance().getExternalProjectData(project, GradleConstants.SYSTEM_ID, setting.getExternalProjectPath());
    if (projectData == null || projectData.getExternalProjectStructure() == null) continue;

    MultiMap<String, String> projectTasks = MultiMap.createOrderedSet();
    for (DataNode<ModuleData> moduleDataNode : getChildren(projectData.getExternalProjectStructure(), ProjectKeys.MODULE)) {
      String gradlePath;
      String moduleId = moduleDataNode.getData().getId();
      if (moduleId.charAt(0) != ':') {
        int colonIndex = moduleId.indexOf(':');
        gradlePath = colonIndex > 0 ? moduleId.substring(colonIndex) : ":";
      }
      else {
        gradlePath = moduleId;
      }
      for (DataNode<TaskData> node : getChildren(moduleDataNode, ProjectKeys.TASK)) {
        TaskData taskData = node.getData();
        String taskName = taskData.getName();
        if (isNotEmpty(taskName)) {
          String taskPathPrefix = ":".equals(gradlePath) || taskName.startsWith(gradlePath) ? "" : (gradlePath + ':');
          projectTasks.putValue(taskPathPrefix, taskName);
        }
      }
    }
    tasks.put(projectData.getExternalProjectStructure().getData(), projectTasks);
  }
  return tasks;
}
 
Example #4
Source File: ToolWindowTaskService.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void processData(@Nonnull Collection<DataNode<TaskData>> nodes,
                           @Nonnull Project project,
                           @Nullable final ExternalSystemTasksTreeModel model)
{
  if (nodes.isEmpty()) {
    return;
  }
  ProjectSystemId externalSystemId = nodes.iterator().next().getData().getOwner();
  ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
  assert manager != null;

  Map<ExternalConfigPathAware, List<DataNode<TaskData>>> grouped = ExternalSystemApiUtil.groupBy(nodes, TASK_HOLDER_RETRIEVAL_STRATEGY);
  Map<String, Collection<ExternalTaskPojo>> data = ContainerUtilRt.newHashMap();
  for (Map.Entry<ExternalConfigPathAware, List<DataNode<TaskData>>> entry : grouped.entrySet()) {
    data.put(entry.getKey().getLinkedExternalProjectPath(), ContainerUtilRt.map2List(entry.getValue(), MAPPER));
  }

  AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);
  Map<String, Collection<ExternalTaskPojo>> availableTasks = ContainerUtilRt.newHashMap(settings.getAvailableTasks());
  availableTasks.putAll(data);
  settings.setAvailableTasks(availableTasks);

  if (model != null) {
    ExternalSystemUiUtil.apply(settings, model);
  }
}
 
Example #5
Source File: GradleMonitor.java    From spring-javaformat with Apache License 2.0 4 votes vote down vote up
private boolean isFormatPlugin(TaskData data) {
	return FORMAT_TASK.equals(data.getType());
}
 
Example #6
Source File: ExternalTaskPojo.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static ExternalTaskPojo from(@Nonnull TaskData data) {
  return new ExternalTaskPojo(data.getName(), data.getLinkedExternalProjectPath(), data.getDescription());
}
 
Example #7
Source File: ToolWindowTaskService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public ExternalTaskPojo fun(DataNode<TaskData> node) {
  return ExternalTaskPojo.from(node.getData());
}
 
Example #8
Source File: ToolWindowTaskService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public ExternalConfigPathAware fun(DataNode<TaskData> node) {
  ModuleData moduleData = node.getData(ProjectKeys.MODULE);
  return moduleData == null ? node.getData(ProjectKeys.PROJECT) : moduleData;
}
 
Example #9
Source File: ToolWindowTaskService.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Key<TaskData> getTargetDataKey() {
  return ProjectKeys.TASK;
}