import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
import org.eclipse.ui.IImportWizard;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.simantics.databoard.container.DataContainer;
import org.simantics.databoard.container.DataContainers;
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.migration.MigratedImportResult;
import org.simantics.db.layer0.migration.MigrationUtils;
import org.simantics.db.layer0.util.DraftStatusBean;
import org.simantics.db.management.ISessionContext;
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;
+import org.simantics.utils.ui.dialogs.InfoDialog;
/**
* @author Tuukka Lehtonen
}
try {
+ MigratedImportResult[] result = { null };
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
Resource target = ResourceAdaptionUtils.toSingleResource(importModel.selection);
importModel.sessionContext.getSession().markUndoPoint();
- doImport(monitor, importModel.importLocation, importModel.sessionContext.getSession(), target);
+ result[0] = doImport(monitor, importModel.importLocation, importModel.sessionContext.getSession(), target);
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
}
}
});
+
+ if (result[0].hasMissingExternals()) {
+ InfoDialog.open(getShell(), "Missing Externals Created",
+ "The system was unable to find some of the external entities referenced by the imported material. Place-holders have been created for the missing entities.\nThe missing entities are:\n"
+ + URIStringUtils.unescape(EString.implode(result[0].tgResult.missingExternals)),
+ SWT.SHEET);
+ }
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
WizardPage cp = (WizardPage) getContainer().getCurrentPage();
return true;
}
- public static void doImport(IProgressMonitor monitor, File modelFile, Session session, Resource target)
+ public static MigratedImportResult doImport(IProgressMonitor monitor, File modelFile, Session session, Resource target)
throws Exception
{
SubMonitor mon = SubMonitor.convert(monitor);
mon.beginTask("Loading shared library from disk", 1000);
- FormatHandler<Object> handler1 = new FormatHandler<Object>() {
+ FormatHandler<MigratedImportResult> handler1 = new FormatHandler<MigratedImportResult>() {
@Override
public Binding getBinding() {
return TransferableGraph1.BINDING;
}
@Override
- public Object process(DataContainer container) throws Exception {
+ public MigratedImportResult process(DataContainer container) throws Exception {
mon.worked(100);
mon.setTaskName("Importing shared library into database");
Variant draftStatus = container.metadata.get(DraftStatusBean.EXTENSION_KEY);
TransferableGraph1 tg = (TransferableGraph1) container.content.getValue();
- MigrationUtils.importSharedOntology(mon.newChild(850, SubMonitor.SUPPRESS_NONE), session, tg, draftStatus == null);
- return null;
+ return MigrationUtils.importSharedOntology(mon.newChild(850, SubMonitor.SUPPRESS_NONE), session, tg, draftStatus == null);
}
};
- Map<String, FormatHandler<Object>> handlers = new HashMap<>();
+ Map<String, FormatHandler<MigratedImportResult>> handlers = new HashMap<>();
handlers.put(Constants.SHARED_LIBRARY_FORMAT_V1, handler1);
- DataContainers.readFile(modelFile, handlers);
+ MigratedImportResult result = DataContainers.readFile(modelFile, handlers);
mon.setTaskName("Postprocessing");
mon.subTask("");
mon.newChild(50).done();
+
+ return result;
}
}