Search in sources :

Example 6 with ExternalProjectPojo

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);
        }
    }
}
Also used : ExternalTaskExecutionInfo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo) TObjectIntHashMap(gnu.trove.TObjectIntHashMap) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) TObjectIntHashMap(gnu.trove.TObjectIntHashMap)

Example 7 with ExternalProjectPojo

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);
        }
    }
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) ExternalTaskExecutionInfo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)

Example 8 with ExternalProjectPojo

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;
}
Also used : Project(com.intellij.openapi.project.Project) ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) GradleLocalSettings(org.jetbrains.plugins.gradle.settings.GradleLocalSettings) Collection(java.util.Collection) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)

Example 9 with ExternalProjectPojo

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;
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(com.microsoft.azure.toolkit.intellij.common.AzureArtifactType.File) File(java.io.File) AzureOperation(com.microsoft.azure.toolkit.lib.common.operation.AzureOperation) Nullable(org.jetbrains.annotations.Nullable)

Example 10 with ExternalProjectPojo

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);
}
Also used : ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)

Aggregations

ExternalProjectPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)17 AbstractExternalSystemLocalSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings)5 Collection (java.util.Collection)5 NotNull (org.jetbrains.annotations.NotNull)5 ExternalTaskExecutionInfo (com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo)4 ExternalTaskPojo (com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo)4 MultiMap (com.intellij.util.containers.MultiMap)3 Map (java.util.Map)3 ExternalSystemUiAware (com.intellij.openapi.externalSystem.ExternalSystemUiAware)2 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)2 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)2 ExternalSystemTasksTree (com.intellij.openapi.externalSystem.service.task.ui.ExternalSystemTasksTree)2 EditorTextField (com.intellij.ui.EditorTextField)2 CompletionResultSet (com.intellij.codeInsight.completion.CompletionResultSet)1 Editor (com.intellij.openapi.editor.Editor)1 DataNode (com.intellij.openapi.externalSystem.model.DataNode)1 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)1 InternalExternalProjectInfo (com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo)1 ExternalProjectBuildClasspathPojo (com.intellij.openapi.externalSystem.model.project.ExternalProjectBuildClasspathPojo)1 TaskData (com.intellij.openapi.externalSystem.model.task.TaskData)1