Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / table / TableFileFilter.java @ 13716

History | View | Annotate | Download (1.99 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 */
19
package com.iver.cit.gvsig.project.documents.table;
20

    
21
import java.io.File;
22

    
23
import javax.swing.filechooser.FileFilter;
24

    
25
import com.hardcode.driverManager.Driver;
26
import com.hardcode.driverManager.DriverLoadException;
27
import com.hardcode.gdbms.engine.data.driver.FileDriver;
28
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
29
/**
30
 * Clase para definir que ficheros aceptara el filtro de tablas, es necesario
31
 * para el JFileChooser
32
 * 
33
 * @version 05/09/2007
34
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
35
 */
36
public class TableFileFilter extends FileFilter {
37
        public Driver driver = null;
38

    
39
        public TableFileFilter(String driverName) throws DriverLoadException {
40
                driver = LayerFactory.getDM().getDriver(driverName);
41
        }
42

    
43
        /**
44
         * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
45
         */
46
        public boolean accept(File f) {
47
                if (f.isDirectory())
48
                        return true;
49

    
50
                if (driver instanceof FileDriver)
51
                        return ((FileDriver) driver).fileAccepted(f);
52

    
53
                throw new RuntimeException("Tipo no reconocido");
54
        }
55

    
56
        /**
57
         * @see javax.swing.filechooser.FileFilter#getDescription()
58
         */
59
        public String getDescription() {
60
                return ((Driver) driver).getName();
61
        }
62
}