use of org.gephi.io.importer.spi.FileImporterBuilder in project gephi by gephi.
the class ImportControllerImpl method getFileImporter.
@Override
public FileImporter getFileImporter(File file) {
FileObject fileObject = FileUtil.toFileObject(file);
//Unzip and return content file
fileObject = getArchivedFile(fileObject);
FileImporterBuilder builder = getMatchingImporter(fileObject);
if (fileObject != null && builder != null) {
FileImporter fi = builder.buildImporter();
return fi;
}
return null;
}
use of org.gephi.io.importer.spi.FileImporterBuilder in project gephi by gephi.
the class ProjectControllerUIImpl method openFile.
@Override
public void openFile(FileImporterBuilder[] builders) {
List<FileFilter> filters = new ArrayList<>();
DialogFileFilter graphFilter = new DialogFileFilter(NbBundle.getMessage(getClass(), "OpenFile_filechooser_graphfilter"));
List<FileType> fileTypes;
if (builders != null) {
fileTypes = new ArrayList<>();
for (FileImporterBuilder builder : builders) {
fileTypes.addAll(Arrays.asList(builder.getFileTypes()));
}
} else {
DialogFileFilter gephiFilter = new DialogFileFilter(NbBundle.getMessage(ProjectControllerUIImpl.class, "OpenProject_filechooser_filter"));
gephiFilter.addExtension(".gephi");
filters.add(gephiFilter);
graphFilter.addExtension(".gephi");
fileTypes = Arrays.asList(importControllerUI.getImportController().getFileTypes());
}
for (FileType fileType : fileTypes) {
DialogFileFilter dialogFileFilter = new DialogFileFilter(fileType.getName());
dialogFileFilter.addExtensions(fileType.getExtensions());
filters.add(dialogFileFilter);
graphFilter.addExtensions(fileType.getExtensions());
}
DialogFileFilter zipFileFilter = new DialogFileFilter(NbBundle.getMessage(getClass(), "OpenFile_filechooser_zipfilter"));
zipFileFilter.addExtensions(new String[] { ".zip", ".gz", ".bz2" });
filters.add(graphFilter);
filters.add(zipFileFilter);
openFile(filters.toArray(new FileFilter[0]), null);
}
use of org.gephi.io.importer.spi.FileImporterBuilder in project gephi by gephi.
the class ImportControllerImpl method getFileImporter.
@Override
public FileImporter getFileImporter(FileObject fileObject) {
if (fileObject != null) {
// Unzip and return content file
fileObject = ImportUtils.getArchivedFile(fileObject);
FileImporterBuilder builder = getMatchingImporter(fileObject);
if (fileObject != null && builder != null) {
FileImporter fi = builder.buildImporter();
return fi;
}
}
return null;
}
use of org.gephi.io.importer.spi.FileImporterBuilder in project gephi by gephi.
the class ImportControllerImpl method importFile.
@Override
public Container importFile(File file) throws FileNotFoundException {
FileObject fileObject = FileUtil.toFileObject(file);
if (fileObject != null) {
// Unzip and return content file
fileObject = ImportUtils.getArchivedFile(fileObject);
file = FileUtil.toFile(fileObject);
FileImporterBuilder builder = getMatchingImporter(fileObject);
if (fileObject != null && builder != null) {
Container c = importFile(fileObject.getInputStream(), builder.buildImporter(), file);
return c;
}
}
return null;
}
Aggregations