Search in sources :

Example 1 with FileImporterBuilder

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;
}
Also used : FileImporterBuilder(org.gephi.io.importer.spi.FileImporterBuilder) FileImporter(org.gephi.io.importer.spi.FileImporter) FileObject(org.openide.filesystems.FileObject)

Example 2 with FileImporterBuilder

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);
}
Also used : FileImporterBuilder(org.gephi.io.importer.spi.FileImporterBuilder) FileType(org.gephi.io.importer.api.FileType) ArrayList(java.util.ArrayList) DialogFileFilter(org.gephi.ui.utils.DialogFileFilter) FileFilter(javax.swing.filechooser.FileFilter) DialogFileFilter(org.gephi.ui.utils.DialogFileFilter)

Example 3 with FileImporterBuilder

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;
}
Also used : FileImporterBuilder(org.gephi.io.importer.spi.FileImporterBuilder) FileImporter(org.gephi.io.importer.spi.FileImporter)

Example 4 with FileImporterBuilder

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;
}
Also used : FileImporterBuilder(org.gephi.io.importer.spi.FileImporterBuilder) Container(org.gephi.io.importer.api.Container) FileObject(org.openide.filesystems.FileObject)

Aggregations

FileImporterBuilder (org.gephi.io.importer.spi.FileImporterBuilder)4 FileImporter (org.gephi.io.importer.spi.FileImporter)2 FileObject (org.openide.filesystems.FileObject)2 ArrayList (java.util.ArrayList)1 FileFilter (javax.swing.filechooser.FileFilter)1 Container (org.gephi.io.importer.api.Container)1 FileType (org.gephi.io.importer.api.FileType)1 DialogFileFilter (org.gephi.ui.utils.DialogFileFilter)1