]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.fileimport/src/org/simantics/fileimport/IGenericFileImport.java
Updated file importer interface and fixed Spreadsheet import
[simantics/platform.git] / bundles / org.simantics.fileimport / src / org / simantics / fileimport / IGenericFileImport.java
index cba016f42a727fa1f0387952210ad7297fb7945a..16df3ab457dd84b4b5217518b2b83c907a61f000 100644 (file)
@@ -4,6 +4,8 @@ import java.nio.file.Path;
 import java.util.Map;
 import java.util.Optional;
 
+import org.simantics.db.Resource;
+
 /**
  * Base interface for performing file imports. 
  * 
@@ -16,14 +18,17 @@ import java.util.Optional;
 public interface IGenericFileImport {
 
     /**
-     * Performs the import for the given file
+     * Performs the import for the given file, using the default parent defined in the file-specific import implementation
+     * Calls perform(parent, file) with the defaultParent it finds
      * 
      * @param file Path to file to import
      * @return Optional string which will be the identifier of the imported file which can later be used for removing the imported entity
      * @throws Exception
      */
-    Optional<String> perform(Path file) throws Exception;
-
+    Optional<String> performWithDefaultParent(Path file) throws Exception;
+    
+    Optional<Resource> perform(Resource parent, Path file) throws Exception;
+    
     /**
      * Remove the entity
      * 
@@ -38,4 +43,11 @@ public interface IGenericFileImport {
      */
     Map<String, String> allowedExtensionsWithFilters();
 
+    /**
+     * Choose the default parent resource in the specific implementations of the importer
+     * Can be null, in which case the default parent must always be provided from a selection UI or explicitly defined
+     * @return
+     */
+    public abstract Resource defaultParentResource();
+    
 }