use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.
the class ExternalProjectDataSelectorDialog method getModifiableDataNode.
@NotNull
private static DataNode getModifiableDataNode(@NotNull DataNode node) {
DataNode modifiedDataNode = (DataNode) node.getUserData(MODIFIED_NODE_KEY);
if (modifiedDataNode == null) {
modifiedDataNode = node.nodeCopy();
node.putUserData(MODIFIED_NODE_KEY, modifiedDataNode);
}
return modifiedDataNode;
}
use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.
the class AbstractExternalProjectImportBuilder method ensureProjectIsDefined.
/**
* Asks current builder to ensure that target external project is defined.
*
* @param wizardContext current wizard context
* @throws ConfigurationException if external project is not defined and can't be constructed
*/
@SuppressWarnings("unchecked")
public void ensureProjectIsDefined(@NotNull WizardContext wizardContext) throws ConfigurationException {
final String externalSystemName = myExternalSystemId.getReadableName();
File projectFile = getProjectFile();
if (projectFile == null) {
throw new ConfigurationException(ExternalSystemBundle.message("error.project.undefined"));
}
projectFile = getExternalProjectConfigToUse(projectFile);
final Ref<ConfigurationException> error = new Ref<>();
final ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
@Override
public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
myExternalProjectNode = externalProject;
}
@Override
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
if (!StringUtil.isEmpty(errorDetails)) {
LOG.warn(errorDetails);
}
error.set(new ConfigurationException(ExternalSystemBundle.message("error.resolve.with.log_link", errorMessage, PathManager.getLogPath()), ExternalSystemBundle.message("error.resolve.generic")));
}
};
final Project project = getProject(wizardContext);
final File finalProjectFile = projectFile;
final String externalProjectPath = FileUtil.toCanonicalPath(finalProjectFile.getAbsolutePath());
final Ref<ConfigurationException> exRef = new Ref<>();
executeAndRestoreDefaultProjectSettings(project, () -> {
try {
ExternalSystemUtil.refreshProject(project, myExternalSystemId, externalProjectPath, callback, true, ProgressExecutionMode.MODAL_SYNC);
} catch (IllegalArgumentException e) {
exRef.set(new ConfigurationException(e.getMessage(), ExternalSystemBundle.message("error.cannot.parse.project", externalSystemName)));
}
});
ConfigurationException ex = exRef.get();
if (ex != null) {
throw ex;
}
if (myExternalProjectNode == null) {
ConfigurationException exception = error.get();
if (exception != null) {
throw exception;
}
} else {
applyProjectSettings(wizardContext);
}
}
use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.
the class ToolWindowModuleService method processData.
@Override
protected void processData(@NotNull final Collection<DataNode<ModuleData>> nodes, @NotNull Project project) {
if (nodes.isEmpty()) {
return;
}
ProjectSystemId externalSystemId = nodes.iterator().next().getData().getOwner();
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
assert manager != null;
final MultiMap<DataNode<ProjectData>, DataNode<ModuleData>> grouped = ExternalSystemApiUtil.groupBy(nodes, ProjectKeys.PROJECT);
Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> data = ContainerUtilRt.newHashMap();
for (Map.Entry<DataNode<ProjectData>, Collection<DataNode<ModuleData>>> entry : grouped.entrySet()) {
data.put(ExternalProjectPojo.from(entry.getKey().getData()), ContainerUtilRt.map2List(entry.getValue(), MAPPER));
}
AbstractExternalSystemLocalSettings settings = manager.getLocalSettingsProvider().fun(project);
Set<String> pathsToForget = detectRenamedProjects(data, settings.getAvailableProjects());
if (!pathsToForget.isEmpty()) {
settings.forgetExternalProjects(pathsToForget);
}
Map<ExternalProjectPojo, Collection<ExternalProjectPojo>> projects = ContainerUtilRt.newHashMap(settings.getAvailableProjects());
projects.putAll(data);
settings.setAvailableProjects(projects);
}
use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.
the class ExternalSystemImportingTestCase method ignoreData.
protected void ignoreData(BooleanFunction<DataNode<?>> booleanFunction, final boolean ignored) {
final ExternalProjectInfo externalProjectInfo = ProjectDataManager.getInstance().getExternalProjectData(myProject, getExternalSystemId(), getCurrentExternalProjectSettings().getExternalProjectPath());
assertNotNull(externalProjectInfo);
final DataNode<ProjectData> projectDataNode = externalProjectInfo.getExternalProjectStructure();
assertNotNull(projectDataNode);
final Collection<DataNode<?>> nodes = ExternalSystemApiUtil.findAllRecursively(projectDataNode, booleanFunction);
for (DataNode<?> node : nodes) {
ExternalSystemApiUtil.visit(node, dataNode -> dataNode.setIgnored(ignored));
}
ServiceManager.getService(ProjectDataManager.class).importData(projectDataNode, myProject, true);
}
use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.
the class ExternalSystemViewDefaultContributor method addModuleNodes.
private static void addModuleNodes(@NotNull ExternalProjectsView externalProjectsView, @NotNull MultiMap<Key<?>, DataNode<?>> dataNodes, @NotNull List<ExternalSystemNode<?>> result) {
final Collection<DataNode<?>> moduleDataNodes = dataNodes.get(ProjectKeys.MODULE);
if (!moduleDataNodes.isEmpty()) {
final AbstractExternalSystemSettings systemSettings = ExternalSystemApiUtil.getSettings(externalProjectsView.getProject(), externalProjectsView.getSystemId());
for (DataNode<?> dataNode : moduleDataNodes) {
final ModuleData data = (ModuleData) dataNode.getData();
final ExternalProjectSettings projectSettings = systemSettings.getLinkedProjectSettings(data.getLinkedExternalProjectPath());
DataNode<ProjectData> projectDataNode = ExternalSystemApiUtil.findParent(dataNode, PROJECT);
final boolean isRoot = projectSettings != null && data.getLinkedExternalProjectPath().equals(projectSettings.getExternalProjectPath()) && projectDataNode != null && projectDataNode.getData().getInternalName().equals(data.getInternalName());
//noinspection unchecked
final ModuleNode moduleNode = new ModuleNode(externalProjectsView, (DataNode<ModuleData>) dataNode, isRoot);
result.add(moduleNode);
}
}
}
Aggregations