]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Fix SysdynFileImport 36/436/2
authorjsimomaa <jani.simomaa@gmail.com>
Thu, 20 Apr 2017 10:25:33 +0000 (13:25 +0300)
committerjsimomaa <jani.simomaa@gmail.com>
Thu, 20 Apr 2017 12:59:13 +0000 (15:59 +0300)
refs #7154

Change-Id: I278ade3e0f52d03892f25723e4a0e59349ff7c54

bundles/org.simantics.sysdyn/OSGI-INF/org.simantics.sysdyn.SysdynFileImport.xml
bundles/org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/SysdynFileImport.java

index a9bed5635ccf95fdd9addbfba079eef6bb95aa78..870e9036379ec3ba5ff4b34f836a0d4ad8c7f573 100644 (file)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>\r
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.simantics.sysdyn.SysdynFileImport">\r
-   <implementation class="org.simantics.sysdyn.utils.imports.SysdynFileImport"/>\r
-</scr:component>
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.simantics.sysdyn.SysdynFileImport">
+   <implementation class="org.simantics.sysdyn.utils.imports.SysdynFileImport"/>
+   <service>
+      <provide interface="org.simantics.fileimport.IGenericFileImport"/>
+   </service>
+</scr:component>
index 01699bfe77494efdcc207e6f10fc55b08f0b65cb..c07b7555dac92902e8515382a143692060a7c0c8 100644 (file)
@@ -1,39 +1,45 @@
-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();
+    }
+}