-package org.simantics.sysdyn.utils.imports;\r
-\r
-import java.nio.file.Path;\r
-import java.util.Collections;\r
-import java.util.Map;\r
-import java.util.Optional;\r
-\r
-import org.eclipse.core.runtime.NullProgressMonitor;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.fileimport.SimanticsResourceFileImport;\r
-import org.simantics.scl.runtime.function.Function1;\r
-import org.simantics.utils.DataContainer;\r
-\r
-public class SysdynFileImport extends SimanticsResourceFileImport {\r
-\r
- private static final Map<String, String> EXTENSIONS_FILTERS = Collections.singletonMap("*.sysdyn",\r
- "Sysdyn model file (*.sysdyn)");\r
-\r
- @Override\r
- public Map<String, String> allowedExtensionsWithFilters() {\r
- return EXTENSIONS_FILTERS;\r
- }\r
-\r
- @Override\r
- public Optional<Resource> perform(Resource parent, Path file) throws Exception {\r
- DataContainer<Resource> result = new DataContainer<>();\r
- ImportUtils.importModelFile(file.toAbsolutePath().toString(), new NullProgressMonitor(),\r
- new Function1<Resource, WriteRequest>() {\r
-\r
- @Override\r
- public WriteRequest apply(Resource model) {\r
- result.set(model);\r
- return null;\r
- }\r
- });\r
- return Optional.ofNullable(result.get());\r
- }\r
-}\r
+package org.simantics.sysdyn.utils.imports;
+
+import java.nio.file.Path;
+import java.util.Collections;
+import java.util.Map;
+import java.util.Optional;
+
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.common.request.WriteRequest;
+import org.simantics.fileimport.SimanticsResourceFileImport;
+import org.simantics.scl.runtime.function.Function1;
+import org.simantics.utils.DataContainer;
+
+public class SysdynFileImport extends SimanticsResourceFileImport {
+
+ private static final Map<String, String> EXTENSIONS_FILTERS = Collections.singletonMap("*.sysdyn",
+ "Sysdyn model file (*.sysdyn)");
+
+ @Override
+ public Map<String, String> allowedExtensionsWithFilters() {
+ return EXTENSIONS_FILTERS;
+ }
+
+ @Override
+ public Optional<Resource> perform(Resource parent, Path file) throws Exception {
+ DataContainer<Resource> result = new DataContainer<>();
+ ImportUtils.importModelFile(file.toAbsolutePath().toString(), new NullProgressMonitor(),
+ new Function1<Resource, WriteRequest>() {
+
+ @Override
+ public WriteRequest apply(Resource model) {
+ result.set(model);
+ return null;
+ }
+ });
+ return Optional.ofNullable(result.get());
+ }
+
+ @Override
+ public Resource defaultParentResource() {
+ return Simantics.getProjectResource();
+ }
+}