]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.spreadsheet.fileimport/src/org/simantics/spreadsheet/fileimport/ExcelFileImport.java
Updated file importer interface and fixed Spreadsheet import
[simantics/platform.git] / bundles / org.simantics.spreadsheet.fileimport / src / org / simantics / spreadsheet / fileimport / ExcelFileImport.java
index 3963f6e7b1b6d0857b8d58d8e68fd67c682d4c47..d1f8924a58b5c245c6b450d4b6c33769bf81999d 100644 (file)
@@ -5,8 +5,10 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Optional;
 
+import org.simantics.Simantics;
 import org.simantics.db.Resource;
 import org.simantics.fileimport.SimanticsResourceFileImport;
+import org.simantics.spreadsheet.graph.ExcelImport;
 
 public class ExcelFileImport extends SimanticsResourceFileImport {
 
@@ -18,8 +20,13 @@ public class ExcelFileImport extends SimanticsResourceFileImport {
     }
     
     @Override
-    public Optional<Resource> perform(Resource parent, Path file) {
-        return Optional.empty();
+    public Optional<Resource> perform(Resource possibleSelection, Path file) throws Exception {
+       if(possibleSelection != null) {
+               //Make sure the selection is of valid type here
+               return Optional.ofNullable(ExcelImport.importBookR(possibleSelection, file.toFile()));
+       } else {
+               throw new NullPointerException("No selection provided - Cannot import book");
+       }
     }
 
     @Override
@@ -27,4 +34,9 @@ public class ExcelFileImport extends SimanticsResourceFileImport {
         return ALLOWED_EXTENSIONS;
     }
 
+    @Override
+    public Resource defaultParentResource() {
+        return null;
+    }
+
 }