use of com.intellij.openapi.externalSystem.model.project.ProjectData 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.project.ProjectData 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);
}
}
}
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project intellij-community by JetBrains.
the class ExternalProjectsDataStorage method update.
synchronized void update(@NotNull ExternalProjectInfo externalProjectInfo) {
restoreInclusionSettings(externalProjectInfo.getExternalProjectStructure());
final ProjectSystemId projectSystemId = externalProjectInfo.getProjectSystemId();
final String projectPath = externalProjectInfo.getExternalProjectPath();
DataNode<ProjectData> externalProjectStructure = externalProjectInfo.getExternalProjectStructure();
long lastSuccessfulImportTimestamp = externalProjectInfo.getLastSuccessfulImportTimestamp();
long lastImportTimestamp = externalProjectInfo.getLastImportTimestamp();
final Pair<ProjectSystemId, File> key = Pair.create(projectSystemId, new File(projectPath));
final InternalExternalProjectInfo old = myExternalRootProjects.get(key);
if (old != null) {
lastImportTimestamp = externalProjectInfo.getLastImportTimestamp();
if (lastSuccessfulImportTimestamp == -1) {
lastSuccessfulImportTimestamp = old.getLastSuccessfulImportTimestamp();
}
if (externalProjectInfo.getExternalProjectStructure() == null) {
externalProjectStructure = old.getExternalProjectStructure();
} else {
externalProjectStructure = externalProjectInfo.getExternalProjectStructure().graphCopy();
}
} else {
externalProjectStructure = externalProjectStructure != null ? externalProjectStructure.graphCopy() : null;
}
InternalExternalProjectInfo merged = new InternalExternalProjectInfo(projectSystemId, projectPath, externalProjectStructure);
merged.setLastImportTimestamp(lastImportTimestamp);
merged.setLastSuccessfulImportTimestamp(lastSuccessfulImportTimestamp);
myExternalRootProjects.put(key, merged);
changed.set(true);
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project intellij-community by JetBrains.
the class ExternalProjectsManager method updateExternalProjectData.
public void updateExternalProjectData(ExternalProjectInfo externalProject) {
// update external projects data
ExternalProjectsDataStorage.getInstance(myProject).update(externalProject);
// update shortcuts manager
if (externalProject.getExternalProjectStructure() != null) {
final ProjectData projectData = externalProject.getExternalProjectStructure().getData();
ExternalSystemUtil.scheduleExternalViewStructureUpdate(myProject, projectData.getOwner());
Collection<DataNode<TaskData>> taskData = ExternalSystemApiUtil.findAllRecursively(externalProject.getExternalProjectStructure(), TASK);
myShortcutsManager.scheduleKeymapUpdate(taskData);
myShortcutsManager.scheduleRunConfigurationKeymapUpdate(projectData.getOwner());
}
}
use of com.intellij.openapi.externalSystem.model.project.ProjectData in project intellij-community by JetBrains.
the class AbstractModuleDataService method setModuleOptions.
protected void setModuleOptions(Module module, DataNode<E> moduleDataNode) {
ModuleData moduleData = moduleDataNode.getData();
module.putUserData(MODULE_DATA_KEY, moduleData);
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY, moduleData.getOwner().toString());
module.setOption(ExternalSystemConstants.LINKED_PROJECT_ID_KEY, moduleData.getId());
module.setOption(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY, moduleData.getLinkedExternalProjectPath());
final ProjectData projectData = moduleDataNode.getData(ProjectKeys.PROJECT);
module.setOption(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY, projectData != null ? projectData.getLinkedExternalProjectPath() : "");
if (moduleData.getGroup() != null) {
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_GROUP_KEY, moduleData.getGroup());
}
if (moduleData.getVersion() != null) {
module.setOption(ExternalSystemConstants.EXTERNAL_SYSTEM_MODULE_VERSION_KEY, moduleData.getVersion());
}
// clear maven option
module.clearOption("org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule");
}
Aggregations