Search in sources :

Example 1 with ProjectDataManager

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;
}
Also used : ExternalProjectInfo(com.intellij.openapi.externalSystem.model.ExternalProjectInfo) ProjectDataManager(com.intellij.openapi.externalSystem.service.project.ProjectDataManager) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ProjectDataManager

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);
    }
}
Also used : ProjectDataManager(com.intellij.openapi.externalSystem.service.project.ProjectDataManager) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Example 3 with ProjectDataManager

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();
            }
        }
    };
}
Also used : ProjectDataManager(com.intellij.openapi.externalSystem.service.project.ProjectDataManager) GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ExternalProjectDataSelectorDialog(com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog) ExternalProjectRefreshCallback(com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback) InternalExternalProjectInfo(com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo) NotNull(org.jetbrains.annotations.NotNull) Application(com.intellij.openapi.application.Application) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with ProjectDataManager

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;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) GradleProjectImportProvider(org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportProvider) ProjectDataManager(com.intellij.openapi.externalSystem.service.project.ProjectDataManager) GradleProjectImportBuilder(org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder) MavenProjectsManager(org.jetbrains.idea.maven.project.MavenProjectsManager) AddModuleWizard(com.intellij.ide.util.newProjectWizard.AddModuleWizard) IOException(java.io.IOException) Module(com.intellij.openapi.module.Module) FileUtil.findFileUnderRootInModule(org.talend.sdk.component.intellij.util.FileUtil.findFileUnderRootInModule)

Aggregations

ProjectDataManager (com.intellij.openapi.externalSystem.service.project.ProjectDataManager)4 DataNode (com.intellij.openapi.externalSystem.model.DataNode)2 Nullable (org.jetbrains.annotations.Nullable)2 AddModuleWizard (com.intellij.ide.util.newProjectWizard.AddModuleWizard)1 Application (com.intellij.openapi.application.Application)1 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)1 InternalExternalProjectInfo (com.intellij.openapi.externalSystem.model.internal.InternalExternalProjectInfo)1 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)1 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)1 ExternalProjectRefreshCallback (com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback)1 ExternalProjectDataSelectorDialog (com.intellij.openapi.externalSystem.service.ui.ExternalProjectDataSelectorDialog)1 Module (com.intellij.openapi.module.Module)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 IOException (java.io.IOException)1 NotNull (org.jetbrains.annotations.NotNull)1 MavenProjectsManager (org.jetbrains.idea.maven.project.MavenProjectsManager)1 GradleProjectImportBuilder (org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportBuilder)1 GradleProjectImportProvider (org.jetbrains.plugins.gradle.service.project.wizard.GradleProjectImportProvider)1 GradleSettings (org.jetbrains.plugins.gradle.settings.GradleSettings)1