use of com.intellij.openapi.externalSystem.service.project.ProjectDataManager in project android by JetBrains.
the class DataNodeCaches method getCachedProjectData.
@Nullable
public DataNode<ProjectData> getCachedProjectData() {
ProjectDataManager dataManager = ProjectDataManager.getInstance();
String projectPath = getBaseDirPath(myProject).getPath();
ExternalProjectInfo projectInfo = dataManager.getExternalProjectData(myProject, GradleConstants.SYSTEM_ID, projectPath);
return projectInfo != null ? projectInfo.getExternalProjectStructure() : null;
}
use of com.intellij.openapi.externalSystem.service.project.ProjectDataManager in project android by JetBrains.
the class Projects method doSelectiveImport.
/**
* Reuse external system 'selective import' feature for importing of the project sub-set.
* And do not ignore projectNode children data, e.g. project libraries
*/
private static void doSelectiveImport(@NotNull Collection<DataNode<ModuleData>> enabledModules, @NotNull Project project) {
ProjectDataManager dataManager = ServiceManager.getService(ProjectDataManager.class);
DataNode<ProjectData> projectNode = enabledModules.isEmpty() ? null : findParent(enabledModules.iterator().next(), PROJECT);
// do not ignore projectNode child data, e.g. project libraries
if (projectNode != null) {
final Collection<DataNode<ModuleData>> allModules = findAll(projectNode, ProjectKeys.MODULE);
if (enabledModules.size() != allModules.size()) {
final Set<DataNode<ModuleData>> moduleToIgnore = ContainerUtil.newIdentityTroveSet(allModules);
moduleToIgnore.removeAll(enabledModules);
for (DataNode<ModuleData> moduleNode : moduleToIgnore) {
visit(moduleNode, node -> node.setIgnored(true));
}
}
dataManager.importData(projectNode, project, true);
} else {
dataManager.importData(enabledModules, project, true);
}
}
use of com.intellij.openapi.externalSystem.service.project.ProjectDataManager in project liferay-ide by liferay.
the class LiferayGradleProjectImportBuilder method createFinalImportCallback.
@Override
protected ExternalProjectRefreshCallback createFinalImportCallback(@NotNull Project project, @NotNull ExternalProjectSettings projectSettings) {
return new ExternalProjectRefreshCallback() {
@Override
public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
}
@Override
public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
if (externalProject == null) {
return;
}
Runnable selectDataTask = () -> {
ExternalProjectDataSelectorDialog dialog = new ExternalProjectDataSelectorDialog(project, new InternalExternalProjectInfo(GradleConstants.SYSTEM_ID, projectSettings.getExternalProjectPath(), externalProject));
if (dialog.hasMultipleDataToSelect()) {
dialog.showAndGet();
} else {
Disposer.dispose(dialog.getDisposable());
}
};
ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
Runnable importTask = () -> projectDataManager.importData(externalProject, project, false);
GradleSettings gradleProjectSettings = GradleSettings.getInstance(project);
boolean showSelectiveImportDialog = gradleProjectSettings.showSelectiveImportDialogOnInitialImport();
Application application = ApplicationManager.getApplication();
if (showSelectiveImportDialog && !application.isHeadlessEnvironment()) {
application.invokeLater(() -> {
selectDataTask.run();
application.executeOnPooledThread(importTask);
});
} else {
importTask.run();
}
}
};
}
use of com.intellij.openapi.externalSystem.service.project.ProjectDataManager in project component-runtime by Talend.
the class TalendModuleBuilder method createModule.
@Override
public Module createModule(final ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, ConfigurationException, JDOMException {
final Module module = super.createModule(moduleModel);
getApplication().invokeLater(() -> {
ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
final ProjectDownloader downloader = new ProjectDownloader(this, request);
try {
downloader.download(ProgressManager.getInstance().getProgressIndicator());
} catch (IOException e) {
getApplication().invokeLater(() -> MessagesEx.showErrorDialog(e.getMessage(), getMessage("download.project.file.error")));
}
}, getMessage("download.project.file"), true, null);
final Project moduleProject = module.getProject();
switch(jsonProject.get("buildType").getAsString()) {
case "Maven":
final VirtualFile pomFile = findFileUnderRootInModule(module, "pom.xml");
if (pomFile != null) {
final MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(moduleProject);
mavenProjectsManager.addManagedFiles(singletonList(pomFile));
}
break;
case "Gradle":
final VirtualFile gradleFile = findFileUnderRootInModule(module, "build.gradle");
if (gradleFile != null) {
final ProjectDataManager projectDataManager = getService(ProjectDataManager.class);
final GradleProjectImportBuilder importBuilder = new GradleProjectImportBuilder(projectDataManager);
final GradleProjectImportProvider importProvider = new GradleProjectImportProvider(importBuilder);
final AddModuleWizard addModuleWizard = new AddModuleWizard(moduleProject, gradleFile.getPath(), importProvider);
if (addModuleWizard.getStepCount() == 0 && addModuleWizard.showAndGet()) {
// user chose to import via the gradle import prompt
importBuilder.commit(moduleProject, null, null);
}
}
break;
default:
break;
}
}, ModalityState.current());
return module;
}
Aggregations