use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project intellij-community by JetBrains.
the class ExternalSystemTasksTreeModel method ensureSubProjectsStructure.
public void ensureSubProjectsStructure(@NotNull ExternalProjectPojo topLevelProject, @NotNull Collection<ExternalProjectPojo> subProjects) {
ExternalSystemNode<ExternalProjectPojo> topLevelProjectNode = ensureProjectNodeExists(topLevelProject);
Map<String, ExternalProjectPojo> /*config path*/
toAdd = ContainerUtilRt.newHashMap();
for (ExternalProjectPojo subProject : subProjects) {
toAdd.put(subProject.getPath(), subProject);
}
toAdd.remove(topLevelProject.getPath());
final TObjectIntHashMap<Object> taskWeights = new TObjectIntHashMap<>();
for (int i = 0; i < topLevelProjectNode.getChildCount(); i++) {
ExternalSystemNode<?> child = topLevelProjectNode.getChildAt(i);
Object childElement = child.getDescriptor().getElement();
if (childElement instanceof ExternalTaskExecutionInfo) {
taskWeights.put(childElement, subProjects.size() + i);
continue;
}
if (toAdd.remove(((ExternalProjectPojo) childElement).getPath()) == null) {
removeNodeFromParent(child);
//noinspection AssignmentToForLoopParameter
i--;
}
}
if (!toAdd.isEmpty()) {
for (Map.Entry<String, ExternalProjectPojo> entry : toAdd.entrySet()) {
ExternalProjectPojo element = new ExternalProjectPojo(entry.getValue().getName(), entry.getValue().getPath());
insertNodeInto(new ExternalSystemNode<>(descriptor(element, myUiAware.getProjectIcon())), topLevelProjectNode);
}
}
}
use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project intellij-community by JetBrains.
the class ExternalSystemTasksTreeModel method ensureTasks.
public void ensureTasks(@NotNull String externalProjectConfigPath, @NotNull Collection<ExternalTaskPojo> tasks) {
if (tasks.isEmpty()) {
return;
}
ExternalSystemNode<ExternalProjectPojo> moduleNode = findProjectNode(externalProjectConfigPath);
if (moduleNode == null) {
// ));
return;
}
Set<ExternalTaskExecutionInfo> toAdd = ContainerUtilRt.newHashSet();
for (ExternalTaskPojo task : tasks) {
toAdd.add(buildTaskInfo(task));
}
for (int i = 0; i < moduleNode.getChildCount(); i++) {
ExternalSystemNode<?> childNode = moduleNode.getChildAt(i);
Object element = childNode.getDescriptor().getElement();
if (element instanceof ExternalTaskExecutionInfo) {
if (!toAdd.remove(element)) {
removeNodeFromParent(childNode);
//noinspection AssignmentToForLoopParameter
i--;
}
}
}
if (!toAdd.isEmpty()) {
for (ExternalTaskExecutionInfo taskInfo : toAdd) {
insertNodeInto(new ExternalSystemNode<>(descriptor(taskInfo, taskInfo.getDescription(), myUiAware.getTaskIcon())), moduleNode);
}
}
}
use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project moe-ide-integration by multi-os-engine.
the class MOESdkPlugin method isValidMoeModule.
public static boolean isValidMoeModule(Module module, String taskName) {
if (module == null) {
return false;
}
final String moduleName = module.getName();
if (module.isDisposed()) {
LOG.info("Invalid MOE module, already disposed (" + moduleName + ")");
return false;
}
if (ModuleUtils.isMavenModule(module)) {
return ModuleUtils.isMOEMavenModule(module);
}
final Project project = module.getProject();
final String path = ModuleUtils.getModulePath(module);
final GradleLocalSettings localSettings = GradleLocalSettings.getInstance(project);
// Get available projects
Collection<ExternalProjectPojo> availableProjects = null;
for (Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : localSettings.getAvailableProjects().entrySet()) {
if (entry.getKey().getPath().equals(project.getBasePath())) {
availableProjects = entry.getValue();
break;
}
}
if (availableProjects == null) {
LOG.info("Not found available projects: " + moduleName);
return false;
}
// Match IDEA module to Gradle project/subproject
for (ExternalProjectPojo availableProject : availableProjects) {
if (availableProject.getPath().equals(path)) {
if (!availableProject.getName().equals(moduleName) && !availableProject.getName().endsWith(":" + moduleName)) {
LOG.info("Could not associate IDEA module with Gradle project: " + moduleName);
return false;
}
break;
}
}
// Check for moeLaunch task
Map<String, Collection<ExternalTaskPojo>> tasks = localSettings.getAvailableTasks();
Collection<ExternalTaskPojo> taskPojos = tasks.get(path);
if (taskPojos == null) {
LOG.info("Not found gradle task pojos: " + moduleName);
return false;
}
for (ExternalTaskPojo taskPojo : taskPojos) {
if (taskName.equals(taskPojo.getName())) {
return true;
}
}
return false;
}
use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project azure-tools-for-java by Microsoft.
the class AzureArtifactManager method getModuleFromAzureArtifact.
@Nullable
@AzureOperation(name = "common|artifact.get_module", params = { "azureArtifact.getName()" }, type = AzureOperation.Type.TASK)
public Module getModuleFromAzureArtifact(AzureArtifact azureArtifact) {
if (azureArtifact == null || azureArtifact.getReferencedObject() == null) {
return null;
}
switch(azureArtifact.getType()) {
case Gradle:
final String gradleModulePath = ((ExternalProjectPojo) azureArtifact.getReferencedObject()).getPath();
final VirtualFile gradleVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(gradleModulePath));
return ProjectFileIndex.getInstance(project).getModuleForFile(gradleVirtualFile);
case Maven:
return ProjectFileIndex.getInstance(project).getModuleForFile(((MavenProject) azureArtifact.getReferencedObject()).getFile());
default:
// IntelliJ artifact is bind to project, can not get the related module, same for File artifact
return null;
}
}
use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project intellij-community by JetBrains.
the class GradleManager method patchAvailableProjects.
private static void patchAvailableProjects(@NotNull Map<String, String> adjustedPaths, @NotNull GradleLocalSettings localSettings) {
Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> adjustedAvailableProjects = ContainerUtilRt.newHashMap();
for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : localSettings.getAvailableProjects().entrySet()) {
String newPath = adjustedPaths.get(entry.getKey().getPath());
if (newPath == null) {
adjustedAvailableProjects.put(entry.getKey(), entry.getValue());
} else {
adjustedAvailableProjects.put(new ExternalProjectPojo(entry.getKey().getName(), newPath), entry.getValue());
}
}
localSettings.setAvailableProjects(adjustedAvailableProjects);
}
Aggregations