use of com.intellij.openapi.externalSystem.model.task.TaskData in project intellij-community by JetBrains.
the class ExternalProjectsDataStorage method convert.
private static DataNode<ProjectData> convert(@NotNull ProjectSystemId systemId, @NotNull ExternalProjectPojo rootProject, @NotNull Collection<ExternalProjectPojo> childProjects, @NotNull Map<String, Collection<ExternalTaskPojo>> availableTasks) {
ProjectData projectData = new ProjectData(systemId, rootProject.getName(), rootProject.getPath(), rootProject.getPath());
DataNode<ProjectData> projectDataNode = new DataNode<>(PROJECT, projectData, null);
for (ExternalProjectPojo childProject : childProjects) {
String moduleConfigPath = childProject.getPath();
ModuleData moduleData = new ModuleData(childProject.getName(), systemId, ModuleTypeId.JAVA_MODULE, childProject.getName(), moduleConfigPath, moduleConfigPath);
final DataNode<ModuleData> moduleDataNode = projectDataNode.createChild(MODULE, moduleData);
final Collection<ExternalTaskPojo> moduleTasks = availableTasks.get(moduleConfigPath);
if (moduleTasks != null) {
for (ExternalTaskPojo moduleTask : moduleTasks) {
TaskData taskData = new TaskData(systemId, moduleTask.getName(), moduleConfigPath, moduleTask.getDescription());
moduleDataNode.createChild(TASK, taskData);
}
}
}
return projectDataNode;
}
use of com.intellij.openapi.externalSystem.model.task.TaskData in project intellij-community by JetBrains.
the class ExternalSystemKeymapExtension method createGroup.
public KeymapGroup createGroup(Condition<AnAction> condition, final Project project) {
KeymapGroup result = KeymapGroupFactory.getInstance().createGroup(ExternalSystemBundle.message("external.system.keymap.group"), ExternalSystemIcons.TaskGroup);
AnAction[] externalSystemActions = ActionsTreeUtil.getActions("ExternalSystem.Actions");
for (AnAction action : externalSystemActions) {
ActionsTreeUtil.addAction(result, action, condition);
}
if (project == null)
return result;
MultiMap<ProjectSystemId, String> projectToActionsMapping = MultiMap.create();
for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
projectToActionsMapping.putValues(manager.getSystemId(), ContainerUtil.<String>emptyList());
}
ActionManager actionManager = ActionManager.getInstance();
if (actionManager != null) {
for (String eachId : actionManager.getActionIds(getActionPrefix(project, null))) {
AnAction eachAction = actionManager.getAction(eachId);
if (!(eachAction instanceof MyExternalSystemAction))
continue;
if (condition != null && !condition.value(actionManager.getActionOrStub(eachId)))
continue;
MyExternalSystemAction taskAction = (MyExternalSystemAction) eachAction;
projectToActionsMapping.putValue(taskAction.getSystemId(), eachId);
}
}
Map<ProjectSystemId, KeymapGroup> keymapGroupMap = ContainerUtil.newHashMap();
for (ProjectSystemId systemId : projectToActionsMapping.keySet()) {
if (!keymapGroupMap.containsKey(systemId)) {
final Icon projectIcon = ExternalSystemUiUtil.getUiAware(systemId).getProjectIcon();
KeymapGroup group = KeymapGroupFactory.getInstance().createGroup(systemId.getReadableName(), projectIcon);
keymapGroupMap.put(systemId, group);
}
}
for (Map.Entry<ProjectSystemId, Collection<String>> each : projectToActionsMapping.entrySet()) {
Collection<String> tasks = each.getValue();
final ProjectSystemId systemId = each.getKey();
final KeymapGroup systemGroup = keymapGroupMap.get(systemId);
if (systemGroup == null)
continue;
for (String actionId : tasks) {
systemGroup.addActionId(actionId);
}
if (systemGroup instanceof Group) {
Icon icon = SystemInfoRt.isMac ? AllIcons.ToolbarDecorator.Mac.Add : AllIcons.ToolbarDecorator.Add;
((Group) systemGroup).addHyperlink(new Hyperlink(icon, "Choose a task to assign a shortcut") {
@Override
public void onClick(MouseEvent e) {
SelectExternalTaskDialog dialog = new SelectExternalTaskDialog(systemId, project);
if (dialog.showAndGet() && dialog.getResult() != null) {
TaskData taskData = dialog.getResult().second;
String ownerModuleName = dialog.getResult().first;
ExternalSystemTaskAction externalSystemAction = (ExternalSystemTaskAction) getOrRegisterAction(project, ownerModuleName, taskData);
ApplicationManager.getApplication().getMessageBus().syncPublisher(KeymapListener.CHANGE_TOPIC).processCurrentKeymapChanged();
Settings allSettings = Settings.KEY.getData(DataManager.getInstance().getDataContext(e.getComponent()));
KeymapPanel keymapPanel = allSettings != null ? allSettings.find(KeymapPanel.class) : null;
if (keymapPanel != null) {
// clear actions filter
keymapPanel.showOption("");
keymapPanel.selectAction(externalSystemAction.myId);
}
}
}
});
}
}
for (KeymapGroup keymapGroup : keymapGroupMap.values()) {
if (isGroupFiltered(condition, keymapGroup)) {
result.addGroup(keymapGroup);
}
}
for (ActionsProvider extension : ActionsProvider.EP_NAME.getExtensions()) {
KeymapGroup keymapGroup = extension.createGroup(condition, project);
if (isGroupFiltered(condition, keymapGroup)) {
result.addGroup(keymapGroup);
}
}
return result;
}
use of com.intellij.openapi.externalSystem.model.task.TaskData in project intellij-community by JetBrains.
the class ToolWindowTaskService method processData.
@Override
protected void processData(@NotNull Collection<DataNode<TaskData>> nodes, @NotNull Project project) {
if (nodes.isEmpty()) {
return;
}
ProjectSystemId externalSystemId = nodes.iterator().next().getData().getOwner();
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
assert manager != null;
ExternalSystemKeymapExtension.updateActions(project, nodes);
MultiMap<ExternalConfigPathAware, DataNode<TaskData>> grouped = ContainerUtil.groupBy(nodes, TASK_HOLDER_RETRIEVAL_STRATEGY);
Map<String, Collection<ExternalTaskPojo>> data = ContainerUtilRt.newHashMap();
for (Map.Entry<ExternalConfigPathAware, Collection<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);
}
use of com.intellij.openapi.externalSystem.model.task.TaskData 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;
}
use of com.intellij.openapi.externalSystem.model.task.TaskData in project intellij-community by JetBrains.
the class GradleArgumentsCompletionProvider method getVariants.
protected List<LookupElement> getVariants(@NotNull final DataNode<ProjectData> projectDataNode, @NotNull final String modulePath) {
final DataNode<ModuleData> moduleDataNode = findModuleDataNode(projectDataNode, modulePath);
if (moduleDataNode == null) {
return Collections.emptyList();
}
final ModuleData moduleData = moduleDataNode.getData();
final boolean isRoot = projectDataNode.getData().getLinkedExternalProjectPath().equals(moduleData.getLinkedExternalProjectPath());
final Collection<DataNode<TaskData>> tasks = ExternalSystemApiUtil.getChildren(moduleDataNode, ProjectKeys.TASK);
List<LookupElement> elements = ContainerUtil.newArrayListWithCapacity(tasks.size());
for (DataNode<TaskData> taskDataNode : tasks) {
final TaskData taskData = taskDataNode.getData();
elements.add(LookupElementBuilder.create(taskData.getName()).withIcon(ExternalSystemIcons.Task));
if (!taskData.isInherited()) {
elements.add(LookupElementBuilder.create((isRoot ? ':' : moduleData.getId() + ':') + taskData.getName()).withIcon(ExternalSystemIcons.Task));
}
}
return elements;
}
Aggregations