Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / table / TableFileFilter.java @ 21743

History | View | Annotate | Download (2.39 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 org.gvsig.data.DataManager;
26
import org.gvsig.data.DataStoreParameters;
27
import org.gvsig.data.InitializeException;
28
import org.gvsig.data.datastores.vectorial.file.FileStoreParameters;
29
import org.gvsig.data.vectorial.FeatureStore;
30
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
31

    
32
/**
33
 * Clase para definir que ficheros aceptara el filtro de tablas, es necesario
34
 * para el JFileChooser
35
 *
36
 * @version 05/09/2007
37
 * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
38
 */
39
public class TableFileFilter extends FileFilter {
40
    protected FeatureStore featureStore = null;
41

    
42
    public TableFileFilter(String name) throws InitializeException {
43
        DataManager dm=DataManager.getManager();
44
        DataStoreParameters params=dm.createDataStoreParameters(name);
45
        featureStore = (FeatureStore)dm.createDataStore(params);//LayerFactory.getDM().getDriver(driverName);
46
    }
47

    
48
    /**
49
     * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
50
     */
51
    public boolean accept(File f) {
52
        if (f.isDirectory())
53
            return true;
54

    
55
        if (featureStore.getParameters() instanceof FileStoreParameters){
56
                return ((FileStoreParameters) featureStore.getParameters()).fileAccept(f);
57
        }
58
        throw new RuntimeException("Tipo no reconocido");
59
    }
60

    
61
    /**
62
     * @see javax.swing.filechooser.FileFilter#getDescription()
63
     */
64
    public String getDescription() {
65
        return featureStore.getName();
66
    }
67
}