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");
}
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);
}
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);
}
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);
}
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();
}
Aggregations