Search in sources :

Example 16 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project android by JetBrains.

the class ModulesToImportDialogSelectionTest method testSaveAndLoad.

public void testSaveAndLoad() throws Exception {
    File file = FileUtil.createTempFile("selection", ".xml", true);
    List<DataNode<ModuleData>> modules = Lists.newArrayList();
    modules.add(createModule("project"));
    modules.add(createModule("app"));
    ModulesToImportDialog.Selection.save(modules, file);
    List<String> moduleNames = ModulesToImportDialog.Selection.load(file);
    assertThat(moduleNames).containsExactly("project", "app");
}
Also used : DataNode(com.intellij.openapi.externalSystem.model.DataNode) File(java.io.File)

Example 17 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project android by JetBrains.

the class GradleModuleModelDataServiceTest method testImportData.

public void testImportData() {
    String appModuleName = "app";
    Module appModule = createModule(appModuleName);
    GradleModuleModel model = new GradleModuleModel(appModuleName, Collections.emptyList(), ":app", null, null);
    DataNode<GradleModuleModel> dataNode = new DataNode<>(GRADLE_MODULE_MODEL, model, null);
    Collection<DataNode<GradleModuleModel>> dataNodes = Collections.singleton(dataNode);
    myDataService.importData(dataNodes, null, getProject(), myModelsProvider);
    verify(myModuleSetup).setUpModule(appModule, myModelsProvider, model);
}
Also used : GradleModuleModel(com.android.tools.idea.gradle.project.model.GradleModuleModel) DataNode(com.intellij.openapi.externalSystem.model.DataNode) Module(com.intellij.openapi.module.Module)

Example 18 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project android by JetBrains.

the class ModuleDisposalDataServiceTest method testImportDataWithAndroidStudioAndSuccessfulSync.

public void testImportDataWithAndroidStudioAndSuccessfulSync() {
    when(myIdeInfo.isAndroidStudio()).thenReturn(true);
    when(mySyncState.lastSyncFailedOrHasIssues()).thenReturn(false);
    IdeaModule moduleModel = mock(IdeaModule.class);
    when(moduleModel.getName()).thenReturn(getModule().getName());
    ImportedModule importedModule = new ImportedModule(moduleModel);
    // This module should be disposed.
    Module libModule = createModule("lib");
    Project project = getProject();
    IdeModifiableModelsProvider modelsProvider = new IdeModifiableModelsProviderImpl(project);
    Collection<DataNode<ImportedModule>> nodes = Collections.singleton(new DataNode<>(IMPORTED_MODULE, importedModule, null));
    myDataService.importData(nodes, null, project, modelsProvider);
    ApplicationManager.getApplication().runWriteAction(modelsProvider::dispose);
    Collection<Module> modulesToDispose = Collections.singletonList(libModule);
    verify(myModuleDisposer).disposeModulesAndMarkImlFilesForDeletion(modulesToDispose, getProject(), modelsProvider);
}
Also used : Project(com.intellij.openapi.project.Project) IdeaModule(org.gradle.tooling.model.idea.IdeaModule) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ImportedModule(com.android.tools.idea.gradle.ImportedModule) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) ImportedModule(com.android.tools.idea.gradle.ImportedModule) IdeaModule(org.gradle.tooling.model.idea.IdeaModule) Module(com.intellij.openapi.module.Module) IdeModifiableModelsProvider(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider)

Example 19 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project android by JetBrains.

the class NdkModuleModelDataServiceTest method testImportData.

public void testImportData() {
    myModelsProvider = new IdeModifiableModelsProviderImpl(getProject());
    String appModuleName = "app";
    Module appModule = createModule(appModuleName);
    NdkModuleModel model = mock(NdkModuleModel.class);
    when(model.getModuleName()).thenReturn(appModuleName);
    DataNode<NdkModuleModel> dataNode = new DataNode<>(NDK_MODEL, model, null);
    Collection<DataNode<NdkModuleModel>> dataNodes = Collections.singleton(dataNode);
    myDataService.importData(dataNodes, null, getProject(), myModelsProvider);
    verify(myModuleSetup).setUpModule(appModule, myModelsProvider, model, null, null);
}
Also used : DataNode(com.intellij.openapi.externalSystem.model.DataNode) IdeModifiableModelsProviderImpl(com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl) Module(com.intellij.openapi.module.Module) NdkModuleModel(com.android.tools.idea.gradle.project.model.NdkModuleModel)

Example 20 with DataNode

use of com.intellij.openapi.externalSystem.model.DataNode in project intellij-community by JetBrains.

the class ExternalProjectDataSelectorDialog method doOKAction.

@Override
protected void doOKAction() {
    loadingPanel.setLoadingText("Please wait...");
    loadingPanel.startLoading();
    final DataNode<ProjectData> projectStructure = myProjectInfo.getExternalProjectStructure();
    if (projectStructure != null) {
        final boolean[] isModified = { false };
        ExternalSystemApiUtil.visit(projectStructure, node -> {
            final DataNode modifiedDataNode = node.getUserData(MODIFIED_NODE_KEY);
            if (modifiedDataNode != null) {
                if (node.isIgnored() != modifiedDataNode.isIgnored()) {
                    node.setIgnored(modifiedDataNode.isIgnored());
                    isModified[0] = true;
                }
                node.removeUserData(MODIFIED_NODE_KEY);
                node.removeUserData(CONNECTED_UI_NODE_KEY);
            }
        });
        if (isModified[0]) {
            DataNode<?> notIgnoredNode = ContainerUtil.find(projectStructure.getChildren(), node -> !node.isIgnored());
            projectStructure.setIgnored(notIgnoredNode == null);
            // execute when current dialog is closed
            ExternalSystemUtil.invokeLater(myProject, ModalityState.NON_MODAL, () -> {
                final ProjectData projectData = projectStructure.getData();
                String title = ExternalSystemBundle.message("progress.refresh.text", projectData.getExternalName(), projectData.getOwner().getReadableName());
                new Task.Backgroundable(myProject, title, true, PerformInBackgroundOption.DEAF) {

                    @Override
                    public void run(@NotNull ProgressIndicator indicator) {
                        ServiceManager.getService(ProjectDataManager.class).importData(projectStructure, myProject, false);
                    }
                }.queue();
            });
        }
    }
    super.doOKAction();
}
Also used : Task(com.intellij.openapi.progress.Task) DataNode(com.intellij.openapi.externalSystem.model.DataNode) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ProjectData(com.intellij.openapi.externalSystem.model.project.ProjectData)

Aggregations

DataNode (com.intellij.openapi.externalSystem.model.DataNode)51 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)22 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)14 NotNull (org.jetbrains.annotations.NotNull)12 Module (com.intellij.openapi.module.Module)11 File (java.io.File)9 Project (com.intellij.openapi.project.Project)7 GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)6 Nullable (org.jetbrains.annotations.Nullable)6 GradleSourceSetData (org.jetbrains.plugins.gradle.model.data.GradleSourceSetData)5 ExternalProjectInfo (com.intellij.openapi.externalSystem.model.ExternalProjectInfo)4 IdeModifiableModelsProviderImpl (com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl)4 IdeaModule (org.gradle.tooling.model.idea.IdeaModule)4 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)3 Task (com.intellij.openapi.progress.Task)3 Pair (com.intellij.openapi.util.Pair)3 MultiMap (com.intellij.util.containers.MultiMap)3 AndroidModuleModel (com.android.tools.idea.gradle.project.model.AndroidModuleModel)2 NdkModuleModel (com.android.tools.idea.gradle.project.model.NdkModuleModel)2 JavaProjectData (com.intellij.externalSystem.JavaProjectData)2