Search in sources :

Example 1 with ExternalProjectPojo

use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project intellij-community by JetBrains.

the class AbstractExternalSystemLocalSettings method pruneOutdatedEntries.

private void pruneOutdatedEntries() {
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(myExternalSystemId);
    assert manager != null;
    Set<String> pathsToForget = ContainerUtilRt.newHashSet();
    for (ExternalProjectPojo pojo : myAvailableProjects.get().keySet()) {
        pathsToForget.add(pojo.getPath());
    }
    for (String path : myAvailableTasks.get().keySet()) {
        pathsToForget.add(path);
    }
    for (ExternalTaskExecutionInfo taskInfo : myRecentTasks.get()) {
        pathsToForget.add(taskInfo.getSettings().getExternalProjectPath());
    }
    AbstractExternalSystemSettings<?, ?, ?> settings = manager.getSettingsProvider().fun(myProject);
    for (ExternalProjectSettings projectSettings : settings.getLinkedProjectsSettings()) {
        pathsToForget.remove(projectSettings.getExternalProjectPath());
    }
    for (Module module : ModuleManager.getInstance(myProject).getModules()) {
        if (!ExternalSystemApiUtil.isExternalSystemAwareModule(myExternalSystemId, module))
            continue;
        pathsToForget.remove(ExternalSystemApiUtil.getExternalProjectPath(module));
    }
    if (!pathsToForget.isEmpty()) {
        forgetExternalProjects(pathsToForget);
    }
}
Also used : ExternalTaskExecutionInfo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskExecutionInfo) Module(com.intellij.openapi.module.Module) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo)

Example 2 with ExternalProjectPojo

use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project intellij-community by JetBrains.

the class ToolWindowModuleService method detectRenamedProjects.

@NotNull
private static Set<String> detectRenamedProjects(@NotNull Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> currentInfo, @NotNull Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> oldInfo) {
    Map<String, String> /* project name */
    map = ContainerUtilRt.newHashMap();
    for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : currentInfo.entrySet()) {
        map.put(entry.getKey().getPath(), entry.getKey().getName());
        for (ExternalProjectPojo pojo : entry.getValue()) {
            map.put(pojo.getPath(), pojo.getName());
        }
    }
    Set<String> result = ContainerUtilRt.newHashSet();
    for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : oldInfo.entrySet()) {
        String newName = map.get(entry.getKey().getPath());
        if (newName != null && !newName.equals(entry.getKey().getName())) {
            result.add(entry.getKey().getPath());
        }
        for (ExternalProjectPojo pojo : entry.getValue()) {
            newName = map.get(pojo.getPath());
            if (newName != null && !newName.equals(pojo.getName())) {
                result.add(pojo.getPath());
            }
        }
    }
    return result;
}
Also used : MultiMap(com.intellij.util.containers.MultiMap) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with ExternalProjectPojo

use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo 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;
}
Also used : ExternalTaskPojo(com.intellij.openapi.externalSystem.model.execution.ExternalTaskPojo) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData) TaskData(com.intellij.openapi.externalSystem.model.task.TaskData)

Example 4 with ExternalProjectPojo

use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project intellij-community by JetBrains.

the class ExternalProjectsDataStorage method mergeLocalSettings.

private void mergeLocalSettings() {
    for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
        final ProjectSystemId systemId = manager.getSystemId();
        AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(myProject);
        final Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> availableProjects = settings.getAvailableProjects();
        final Map<String, Collection<ExternalTaskPojo>> availableTasks = settings.getAvailableTasks();
        for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : availableProjects.entrySet()) {
            final ExternalProjectPojo projectPojo = entry.getKey();
            final String externalProjectPath = projectPojo.getPath();
            final Pair<ProjectSystemId, File> key = Pair.create(systemId, new File(externalProjectPath));
            InternalExternalProjectInfo externalProjectInfo = myExternalRootProjects.get(key);
            if (externalProjectInfo == null) {
                final DataNode<ProjectData> dataNode = convert(systemId, projectPojo, entry.getValue(), availableTasks);
                externalProjectInfo = new InternalExternalProjectInfo(systemId, externalProjectPath, dataNode);
                myExternalRootProjects.put(key, externalProjectInfo);
                changed.set(true);
            }
            // restore linked project sub-modules
            ExternalProjectSettings linkedProjectSettings = manager.getSettingsProvider().fun(myProject).getLinkedProjectSettings(externalProjectPath);
            if (linkedProjectSettings != null && ContainerUtil.isEmpty(linkedProjectSettings.getModules())) {
                final Set<String> modulePaths = ContainerUtil.map2Set(ExternalSystemApiUtil.findAllRecursively(externalProjectInfo.getExternalProjectStructure(), ProjectKeys.MODULE), node -> node.getData().getLinkedExternalProjectPath());
                linkedProjectSettings.setModules(modulePaths);
            }
        }
    }
}
Also used : AbstractExternalSystemLocalSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings) InternalExternalProjectInfo(com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) AbstractCollection(com.intellij.util.xmlb.annotations.AbstractCollection) Collection(java.util.Collection) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) Map(java.util.Map) MultiMap(com.intellij.util.containers.MultiMap) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 5 with ExternalProjectPojo

use of com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo in project intellij-community by JetBrains.

the class ExternalProjectPathField method collapseIfPossible.

private static void collapseIfPossible(@NotNull final Editor editor, @NotNull ProjectSystemId externalSystemId, @NotNull Project project) {
    ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
    assert manager != null;
    final AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);
    final ExternalSystemUiAware uiAware = ExternalSystemUiUtil.getUiAware(externalSystemId);
    String rawText = editor.getDocument().getText();
    for (Map.Entry<ExternalProjectPojo, Collection<ExternalProjectPojo>> entry : settings.getAvailableProjects().entrySet()) {
        if (entry.getKey().getPath().equals(rawText)) {
            collapse(editor, uiAware.getProjectRepresentationName(project, entry.getKey().getPath(), null));
            return;
        }
        for (ExternalProjectPojo pojo : entry.getValue()) {
            if (pojo.getPath().equals(rawText)) {
                collapse(editor, uiAware.getProjectRepresentationName(project, pojo.getPath(), entry.getKey().getPath()));
                return;
            }
        }
    }
}
Also used : AbstractExternalSystemLocalSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemLocalSettings) Collection(java.util.Collection) Map(java.util.Map) ExternalProjectPojo(com.intellij.openapi.externalSystem.model.project.ExternalProjectPojo) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware)

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