Revision 21743 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/TableFileFilter.java

View differences:

TableFileFilter.java
22 22

  
23 23
import javax.swing.filechooser.FileFilter;
24 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;
25 30
import org.gvsig.fmap.mapcontext.layers.LayerFactory;
26 31

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

  
40
	public TableFileFilter(String driverName) throws DriverLoadException {
41
		driver = LayerFactory.getDM().getDriver(driverName);
42
	}
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
    }
43 47

  
44
	/**
45
	 * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
46
	 */
47
	public boolean accept(File f) {
48
		if (f.isDirectory())
49
			return true;
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;
50 54

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

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

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

Also available in: Unified diff