Search in sources :

Example 6 with FileImporter

use of org.gephi.io.importer.spi.FileImporter in project gephi by gephi.

the class DesktopImportControllerUI method importStream.

@Override
public void importStream(final InputStream stream, String importerName) {
    final FileImporter importer = controller.getFileImporter(importerName);
    if (importer == null) {
        NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE);
        DialogDisplayer.getDefault().notify(msg);
        return;
    }
    try {
        Reader reader = ImportUtils.getTextReader(stream);
        importFile(reader, importer);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) FileImporter(org.gephi.io.importer.spi.FileImporter) Reader(java.io.Reader) IOException(java.io.IOException)

Example 7 with FileImporter

use of org.gephi.io.importer.spi.FileImporter 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)

Aggregations

FileImporter (org.gephi.io.importer.spi.FileImporter)7 IOException (java.io.IOException)4 NotifyDescriptor (org.openide.NotifyDescriptor)4 FileObject (org.openide.filesystems.FileObject)4 Reader (java.io.Reader)3 File (java.io.File)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 JPanel (javax.swing.JPanel)2 ChangeEvent (javax.swing.event.ChangeEvent)2 ChangeListener (javax.swing.event.ChangeListener)2 MostRecentFiles (org.gephi.desktop.mrufiles.api.MostRecentFiles)2 Container (org.gephi.io.importer.api.Container)2 FileImporterBuilder (org.gephi.io.importer.spi.FileImporterBuilder)2 ImporterUI (org.gephi.io.importer.spi.ImporterUI)2 ValidationPanel (org.netbeans.validation.api.ui.ValidationPanel)2 DialogDescriptor (org.openide.DialogDescriptor)2 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1