]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.fileimport/src/org/simantics/fileimport/FileReferenceFileImport.java
Add Future to SCL API
[simantics/platform.git] / bundles / org.simantics.fileimport / src / org / simantics / fileimport / FileReferenceFileImport.java
1 package org.simantics.fileimport;
2
3 import java.nio.file.Path;
4 import java.util.Collections;
5 import java.util.Map;
6 import java.util.Optional;
7
8 import org.simantics.Simantics;
9 import org.simantics.db.Resource;
10 import org.simantics.graphfile.util.GraphFileUtil;
11
12 public class FileReferenceFileImport extends SimanticsResourceFileImport {
13
14     private static final Map<String, String> ALLOWED_EXTENSIONS = Collections.singletonMap("*", "All files");
15     
16     @Override
17     public Optional<Resource> perform(Resource parent, Path file) throws Exception {
18         return Optional.of(GraphFileUtil.createFileReference(parent, file));
19     }
20
21     @Override
22     public Map<String, String> allowedExtensionsWithFilters() {
23         return ALLOWED_EXTENSIONS;
24     }
25
26     @Override
27     public Resource defaultParentResource() {
28         return Simantics.getProjectResource();
29     }
30 }