From 1ab8209ad38dd5822f982f2aab4ad2c9fb3ef4dc Mon Sep 17 00:00:00 2001 From: Jussi Koskela Date: Wed, 9 Aug 2017 13:00:35 +0300 Subject: [PATCH] ModelImportWizard.doImport does not import the model to specified target When triggered from the UI the target should always be the project resource. Otherwise any target resource should be accepted. DefaultPasteImportAdvisor must be used instead of the ModelImportAdvisor, since ModelImportAdvisor always replaces the target with the project resource (to support copy-pasting of models in UI). refs #7418 Change-Id: I1b7eaef30ab32154319822c0615b9ab96a3f70b6 --- .../ui/sharedontology/wizard/ModelImportWizard.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelImportWizard.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelImportWizard.java index 9f9dc489e..4b7039258 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelImportWizard.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelImportWizard.java @@ -40,11 +40,11 @@ import org.simantics.databoard.container.FormatHandler; import org.simantics.databoard.util.URIStringUtils; import org.simantics.db.Resource; import org.simantics.db.Session; +import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor; import org.simantics.db.layer0.migration.MigratedImportResult; import org.simantics.db.layer0.migration.MigrationState; import org.simantics.db.layer0.migration.MigrationStateKeys; import org.simantics.db.layer0.migration.MigrationUtils; -import org.simantics.db.layer0.migration.ModelImportAdvisor; import org.simantics.db.management.ISessionContext; import org.simantics.graph.db.ImportResult; import org.simantics.graph.db.MissingDependencyException; @@ -54,7 +54,6 @@ import org.simantics.modeling.ui.utils.NoProjectPage; import org.simantics.project.IProject; import org.simantics.project.ProjectKeys; import org.simantics.ui.SimanticsUI; -import org.simantics.ui.utils.ResourceAdaptionUtils; import org.simantics.utils.strings.EString; import org.simantics.utils.ui.ErrorLogger; import org.simantics.utils.ui.ExceptionUtils; @@ -137,7 +136,7 @@ public class ModelImportWizard extends Wizard implements IImportWizard { @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { - Resource target = ResourceAdaptionUtils.toSingleResource(importModel.selection); + Resource target = Simantics.getProjectResource(); importModel.sessionContext.getSession().markUndoPoint(); result[0] = doImport(monitor, importModel.importLocation, importModel.sessionContext.getSession(), target); } catch (Exception e) { @@ -201,7 +200,7 @@ public class ModelImportWizard extends Wizard implements IImportWizard { state.setProperty(MigrationStateKeys.SESSION, session); state.setProperty(MigrationStateKeys.PROGRESS_MONITOR, monitor); - MigrationUtils.importMigrated(monitor, session, modelFile, state, new ModelImportAdvisor(Simantics.getProjectResource()), Simantics.getProjectResource()); + MigrationUtils.importMigrated(monitor, session, modelFile, state, new DefaultPasteImportAdvisor(target), target); Collection resultRoots = state.getProperty(MigrationStateKeys.CURRENT_ROOT_RESOURCES); ImportResult result = state.getProperty(MigrationStateKeys.IMPORT_RESULT); -- 2.47.1