Search in sources :

Example 1 with DataNode

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

the class ModulesToImportDialogSelectionTest method createModule.

@NotNull
private static DataNode<ModuleData> createModule(@NotNull String name) {
    String path = "~/project/" + name;
    ModuleData data = new ModuleData(name, GradleConstants.SYSTEM_ID, StdModuleTypes.JAVA.getId(), name, path, path);
    return new DataNode<>(MODULE, data, null);
}
Also used : DataNode(com.intellij.openapi.externalSystem.model.DataNode) ModuleData(com.intellij.openapi.externalSystem.model.project.ModuleData) NotNull(org.jetbrains.annotations.NotNull)

Example 2 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 3 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 4 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 5 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)

Aggregations

DataNode (com.intellij.openapi.externalSystem.model.DataNode)52 ModuleData (com.intellij.openapi.externalSystem.model.project.ModuleData)22 ProjectData (com.intellij.openapi.externalSystem.model.project.ProjectData)14 NotNull (org.jetbrains.annotations.NotNull)13 Module (com.intellij.openapi.module.Module)11 File (java.io.File)9 Project (com.intellij.openapi.project.Project)7 Nullable (org.jetbrains.annotations.Nullable)7 GradleModuleModel (com.android.tools.idea.gradle.project.model.GradleModuleModel)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 ExternalProjectRefreshCallback (com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback)3 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