]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
ModelImportWizard.doImport does not import the model to specified target 21/821/2
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 9 Aug 2017 10:00:35 +0000 (13:00 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 10 Aug 2017 14:15:59 +0000 (17:15 +0300)
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

bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/ModelImportWizard.java

index 9f9dc489e42af88a111b2705fa723bfcc70e6578..4b7039258153da98ab29fc54bfc4108e9564b129 100644 (file)
@@ -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<Resource> resultRoots = state.getProperty(MigrationStateKeys.CURRENT_ROOT_RESOURCES);
                 ImportResult result = state.getProperty(MigrationStateKeys.IMPORT_RESULT);