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;
}
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);
}
}
}
}
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);
}
});
}
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);
}
}
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);
}
}
Aggregations