use of com.intellij.openapi.externalSystem.model.project.ModuleData in project intellij-community by JetBrains.
the class DetachExternalProjectAction method perform.
@Override
public void perform(@NotNull final Project project, @NotNull ProjectSystemId projectSystemId, @NotNull ProjectData projectData, @NotNull AnActionEvent e) {
e.getPresentation().setText(ExternalSystemBundle.message("action.detach.external.project.text", projectSystemId.getReadableName()));
final ProjectNode projectNode = ExternalSystemDataKeys.SELECTED_PROJECT_NODE.getData(e.getDataContext());
assert projectNode != null;
ExternalSystemApiUtil.getLocalSettings(project, projectSystemId).forgetExternalProjects(Collections.singleton(projectData.getLinkedExternalProjectPath()));
ExternalSystemApiUtil.getSettings(project, projectSystemId).unlinkExternalProject(projectData.getLinkedExternalProjectPath());
ExternalProjectsManager.getInstance(project).forgetExternalProjectData(projectSystemId, projectData.getLinkedExternalProjectPath());
// Process orphan modules.
List<Module> orphanModules = ContainerUtilRt.newArrayList();
for (Module module : ModuleManager.getInstance(project).getModules()) {
if (!ExternalSystemApiUtil.isExternalSystemAwareModule(projectSystemId, module))
continue;
String path = ExternalSystemApiUtil.getExternalRootProjectPath(module);
if (projectData.getLinkedExternalProjectPath().equals(path)) {
orphanModules.add(module);
}
}
if (!orphanModules.isEmpty()) {
projectNode.getGroup().remove(projectNode);
ProjectDataManager.getInstance().removeData(ProjectKeys.MODULE, orphanModules, Collections.<DataNode<ModuleData>>emptyList(), projectData, project, false);
}
}
Aggregations