Search in sources :

Example 11 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class ExternalModuleStructureExtension method getLinkedProjects.

private static Map<String, Pair<ProjectSystemId, ExternalProjectSettings>> getLinkedProjects(Project project) {
    Map<String, Pair<ProjectSystemId, ExternalProjectSettings>> result = new HashMap<>();
    for (ExternalSystemManager<?, ?, ?, ?, ?> manager : ExternalSystemApiUtil.getAllManagers()) {
        ProjectSystemId systemId = manager.getSystemId();
        AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(project, systemId);
        Collection projectsSettings = systemSettings.getLinkedProjectsSettings();
        for (Object settings : projectsSettings) {
            if (settings instanceof ExternalProjectSettings) {
                ExternalProjectSettings projectSettings = (ExternalProjectSettings) settings;
                result.put((projectSettings).getExternalProjectPath(), Pair.create(systemId, projectSettings));
            }
        }
    }
    return result;
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) HashMap(java.util.HashMap) Collection(java.util.Collection) ProjectSystemId(com.intellij.openapi.externalSystem.model.ProjectSystemId) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) Pair(com.intellij.openapi.util.Pair)

Example 12 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings 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 13 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class ConfigureTasksActivationDialog method setUpDialog.

private void setUpDialog(@NotNull String projectPath) {
    final AbstractExternalSystemSettings externalSystemSettings = ExternalSystemApiUtil.getSettings(myProject, myProjectSystemId);
    //noinspection unchecked
    Collection<ExternalProjectSettings> projectsSettings = externalSystemSettings.getLinkedProjectsSettings();
    List<ProjectItem> projects = ContainerUtil.map(projectsSettings, settings -> new ProjectItem(uiAware.getProjectRepresentationName(settings.getExternalProjectPath(), null), settings));
    myTree = new SimpleTree();
    myRootNode = new RootNode();
    treeBuilder = createTreeBuilder(myProject, myRootNode, myTree);
    final ExternalProjectSettings currentProjectSettings = externalSystemSettings.getLinkedProjectSettings(projectPath);
    if (currentProjectSettings != null) {
        SwingHelper.updateItems(projectCombobox, projects, new ProjectItem(uiAware.getProjectRepresentationName(projectPath, null), currentProjectSettings));
    }
    projectCombobox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateTree(myRootNode);
        }
    });
}
Also used : AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ActionListener(java.awt.event.ActionListener) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) ActionEvent(java.awt.event.ActionEvent) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)

Example 14 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class ExternalSystemResolveProjectTask method doExecute.

@SuppressWarnings("unchecked")
protected void doExecute() throws Exception {
    final ExternalSystemFacadeManager manager = ServiceManager.getService(ExternalSystemFacadeManager.class);
    Project ideProject = getIdeProject();
    RemoteExternalSystemProjectResolver resolver = manager.getFacade(ideProject, myProjectPath, getExternalSystemId()).getResolver();
    ExternalSystemExecutionSettings settings = ExternalSystemApiUtil.getExecutionSettings(ideProject, myProjectPath, getExternalSystemId());
    if (StringUtil.isNotEmpty(myVmOptions)) {
        settings.withVmOptions(ParametersListUtil.parse(myVmOptions));
    }
    if (StringUtil.isNotEmpty(myArguments)) {
        settings.withArguments(ParametersListUtil.parse(myArguments));
    }
    ExternalSystemProgressNotificationManagerImpl progressNotificationManager = (ExternalSystemProgressNotificationManagerImpl) ServiceManager.getService(ExternalSystemProgressNotificationManager.class);
    ExternalSystemTaskId id = getId();
    progressNotificationManager.onStart(id, myProjectPath);
    try {
        DataNode<ProjectData> project = resolver.resolveProjectInfo(id, myProjectPath, myIsPreviewMode, settings);
        if (project != null) {
            myExternalProject.set(project);
            ExternalSystemManager<?, ?, ?, ?, ?> systemManager = ExternalSystemApiUtil.getManager(getExternalSystemId());
            assert systemManager != null;
            Set<String> externalModulePaths = ContainerUtil.newHashSet();
            Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(project, ProjectKeys.MODULE);
            for (DataNode<ModuleData> node : moduleNodes) {
                externalModulePaths.add(node.getData().getLinkedExternalProjectPath());
            }
            String projectPath = project.getData().getLinkedExternalProjectPath();
            ExternalProjectSettings linkedProjectSettings = systemManager.getSettingsProvider().fun(ideProject).getLinkedProjectSettings(projectPath);
            if (linkedProjectSettings != null) {
                linkedProjectSettings.setModules(externalModulePaths);
            }
        }
        progressNotificationManager.onSuccess(id);
    } finally {
        progressNotificationManager.onEnd(id);
    }
}
Also used : ExternalSystemTaskId(com.intellij.openapi.externalSystem.model.task.ExternalSystemTaskId) ExternalSystemProgressNotificationManagerImpl(com.intellij.openapi.externalSystem.service.remote.ExternalSystemProgressNotificationManagerImpl) ExternalSystemFacadeManager(com.intellij.openapi.externalSystem.service.ExternalSystemFacadeManager) ExternalSystemProgressNotificationManager(com.intellij.openapi.externalSystem.service.notification.ExternalSystemProgressNotificationManager) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) Project(com.intellij.openapi.project.Project) RemoteExternalSystemProjectResolver(com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolver) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ExternalSystemExecutionSettings(com.intellij.openapi.externalSystem.model.settings.ExternalSystemExecutionSettings) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 15 with ExternalProjectSettings

use of com.intellij.openapi.externalSystem.settings.ExternalProjectSettings in project intellij-community by JetBrains.

the class ContentRootDataService method importData.

private static void importData(@NotNull IdeModifiableModelsProvider modelsProvider, @NotNull final Collection<DataNode<ContentRootData>> data, @NotNull final Module module, boolean forceDirectoriesCreation) {
    final ModifiableRootModel modifiableRootModel = modelsProvider.getModifiableRootModel(module);
    final ContentEntry[] contentEntries = modifiableRootModel.getContentEntries();
    final Map<String, ContentEntry> contentEntriesMap = ContainerUtilRt.newHashMap();
    for (ContentEntry contentEntry : contentEntries) {
        contentEntriesMap.put(contentEntry.getUrl(), contentEntry);
    }
    boolean createEmptyContentRootDirectories = forceDirectoriesCreation;
    if (!forceDirectoriesCreation && !data.isEmpty()) {
        ProjectSystemId projectSystemId = data.iterator().next().getData().getOwner();
        AbstractExternalSystemSettings externalSystemSettings = ExternalSystemApiUtil.getSettings(module.getProject(), projectSystemId);
        String path = module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY);
        if (path != null) {
            ExternalProjectSettings projectSettings = externalSystemSettings.getLinkedProjectSettings(path);
            createEmptyContentRootDirectories = projectSettings != null && projectSettings.isCreateEmptyContentRootDirectories();
        }
    }
    final Set<ContentEntry> importedContentEntries = ContainerUtil.newIdentityTroveSet();
    for (final DataNode<ContentRootData> node : data) {
        final ContentRootData contentRoot = node.getData();
        final ContentEntry contentEntry = findOrCreateContentRoot(modifiableRootModel, contentRoot.getRootPath());
        if (!importedContentEntries.contains(contentEntry)) {
            // clear source folders but do not remove existing excluded folders
            contentEntry.clearSourceFolders();
            importedContentEntries.add(contentEntry);
        }
        if (LOG.isDebugEnabled()) {
            LOG.debug(String.format("Importing content root '%s' for module '%s'", contentRoot.getRootPath(), module.getName()));
        }
        for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.SOURCE)) {
            createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, false, createEmptyContentRootDirectories);
        }
        for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.TEST)) {
            createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, false, createEmptyContentRootDirectories);
        }
        for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.SOURCE_GENERATED)) {
            createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.SOURCE, true, createEmptyContentRootDirectories);
        }
        for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.TEST_GENERATED)) {
            createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaSourceRootType.TEST_SOURCE, true, createEmptyContentRootDirectories);
        }
        for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.RESOURCE)) {
            createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.RESOURCE, false, createEmptyContentRootDirectories);
        }
        for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.TEST_RESOURCE)) {
            createSourceRootIfAbsent(contentEntry, path, module.getName(), JavaResourceRootType.TEST_RESOURCE, false, createEmptyContentRootDirectories);
        }
        for (SourceRoot path : contentRoot.getPaths(ExternalSystemSourceType.EXCLUDED)) {
            createExcludedRootIfAbsent(contentEntry, path, module.getName(), module.getProject());
        }
        contentEntriesMap.remove(contentEntry.getUrl());
    }
    for (ContentEntry contentEntry : contentEntriesMap.values()) {
        modifiableRootModel.removeContentEntry(contentEntry);
    }
}
Also used : ContentRootData(com.intellij.openapi.externalSystem.model.project.ContentRootData) SourceRoot(com.intellij.openapi.externalSystem.model.project.ContentRootData.SourceRoot) ExternalProjectSettings(com.intellij.openapi.externalSystem.settings.ExternalProjectSettings) ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) AbstractExternalSystemSettings(com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings) ContentEntry(com.intellij.openapi.roots.ContentEntry)

Aggregations

ExternalProjectSettings (com.intellij.openapi.externalSystem.settings.ExternalProjectSettings)26 AbstractExternalSystemSettings (com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings)13 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)7 ExternalProjectRefreshCallback (com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback)5 ImportSpecBuilder (com.intellij.openapi.externalSystem.importing.ImportSpecBuilder)4 ProjectSystemId (com.intellij.openapi.externalSystem.model.ProjectSystemId)4 File (java.io.File)4 Collection (java.util.Collection)4 NotNull (org.jetbrains.annotations.NotNull)4 Nullable (org.jetbrains.annotations.Nullable)3 DataNode (com.intellij.openapi.externalSystem.model.DataNode)2 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)2 InternalExternalProjectInfo (com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo)2 ExternalConfigPathAware (com.intellij.openapi.externalSystem.model.project.ExternalConfigPathAware)2 ExternalSystemProcessingManager (com.intellij.openapi.externalSystem.service.internal.ExternalSystemProcessingManager)2 ProjectDataManager (com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager)2 ExternalSystemNode (com.intellij.openapi.externalSystem.view.ExternalSystemNode)2 Module (com.intellij.openapi.module.Module)2 Project (com.intellij.openapi.project.Project)2 ModulesConfigurator (com.intellij.openapi.roots.ui.configuration.ModulesConfigurator)2