001/*
002 * Copyright 2010-2015 Institut Pasteur.
003 * 
004 * This file is part of Icy.
005 * 
006 * Icy is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 * 
011 * Icy is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
014 * GNU General Public License for more details.
015 * 
016 * You should have received a copy of the GNU General Public License
017 * along with Icy. If not, see <http://www.gnu.org/licenses/>.
018 */
019package icy.file;
020
021import icy.common.exception.UnsupportedFormatException;
022import icy.gui.frame.progress.FileFrame;
023
024import java.io.IOException;
025import java.util.List;
026
027import javax.swing.filechooser.FileFilter;
028
029/**
030 * File importer interface.<br>
031 * The importer is directly integrated in the classic <b>Open</b> command menu and can open any file
032 * type except image (use the {@link SequenceFileImporter} interface for image file).<br>
033 * It is from his responsibility to make the opened file available in the application.
034 * 
035 * @author Stephane
036 */
037public interface FileImporter
038{
039    /**
040     * Return <code>true</code> if the specified file can be opened by the importer.
041     */
042    public boolean acceptFile(String path);
043
044    /**
045     * Return the supported FileFilter for this importer.
046     */
047    public List<FileFilter> getFileFilters();
048
049    /**
050     * Load the specified file and returns true if the operation succeed.<br>
051     * The method is free to handle the way it makes the opened file available in the application.
052     * 
053     * @param path
054     *        File to load.
055     * @param loadingFrame
056     *        Frame where to display the loading progression (can be <code>null</code> if no
057     *        progression wanted)
058     * @return <code>true</code> if the operation succeed
059     */
060    public boolean load(String path, FileFrame loadingFrame) throws UnsupportedFormatException, IOException;
061}