root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / table / TableFileOpen.java @ 16403
History | View | Annotate | Download (3.1 KB)
1 | 13716 | bsanchez | /* 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.awt.geom.Rectangle2D; |
||
22 | import java.io.File; |
||
23 | import java.util.ArrayList; |
||
24 | import java.util.Comparator; |
||
25 | import java.util.Iterator; |
||
26 | import java.util.TreeSet; |
||
27 | |||
28 | import org.cresques.cts.IProjection; |
||
29 | |||
30 | import com.hardcode.driverManager.DriverLoadException; |
||
31 | import com.hardcode.gdbms.engine.data.driver.FileDriver; |
||
32 | import com.iver.andami.messages.NotificationManager; |
||
33 | 16403 | jmvivo | import com.iver.cit.gvsig.addlayer.fileopen.AbstractFileOpen; |
34 | 13716 | bsanchez | import com.iver.cit.gvsig.fmap.MapControl; |
35 | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
||
36 | /**
|
||
37 | * Clase que indicar? que ficheros puede tratar al panel de apertura de ficheros
|
||
38 | 16403 | jmvivo | *
|
39 | 13716 | bsanchez | * @version 04/09/2007
|
40 | * @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es)
|
||
41 | */
|
||
42 | 16403 | jmvivo | public class TableFileOpen extends AbstractFileOpen { |
43 | |||
44 | 13716 | bsanchez | /**
|
45 | * Constructor de FileOpenRaster
|
||
46 | */
|
||
47 | public TableFileOpen() {
|
||
48 | TreeSet filters = new TreeSet(new Comparator() { |
||
49 | public int compare(Object o1, Object o2) { |
||
50 | TableFileFilter dff1 = (TableFileFilter) o1; |
||
51 | TableFileFilter dff2 = (TableFileFilter) o2; |
||
52 | |||
53 | return dff1.driver.getName().compareTo(dff2.driver.getName());
|
||
54 | } |
||
55 | }); |
||
56 | |||
57 | Class[] driverClasses = new Class[] { FileDriver.class }; |
||
58 | String[] driverNames = LayerFactory.getDM().getDriverNames(); |
||
59 | TableFileFilter auxF; |
||
60 | try {
|
||
61 | for (int i = 0; i < driverNames.length; i++) { |
||
62 | System.err.println("DRIVER " + i + " : " + driverNames[i]); |
||
63 | boolean is = false; |
||
64 | for (int j = 0; j < driverClasses.length; j++) { |
||
65 | if (LayerFactory.getDM().isA(driverNames[i], driverClasses[j])) {
|
||
66 | is = true;
|
||
67 | break;
|
||
68 | } |
||
69 | } |
||
70 | if (is) {
|
||
71 | auxF = new TableFileFilter(driverNames[i]);
|
||
72 | System.out.println("DRIVER " + i + " : " + driverNames[i]); |
||
73 | filters.add(auxF); |
||
74 | } |
||
75 | } |
||
76 | Iterator iterator = filters.iterator();
|
||
77 | while (iterator.hasNext()) {
|
||
78 | TableFileFilter filter = (TableFileFilter) iterator.next(); |
||
79 | 16403 | jmvivo | getFileFilter().add(filter); |
80 | 13716 | bsanchez | } |
81 | } catch (DriverLoadException exception) {
|
||
82 | NotificationManager.addError("No se pudo acceder a los drivers", exception);
|
||
83 | } |
||
84 | } |
||
85 | |||
86 | /*
|
||
87 | * (non-Javadoc)
|
||
88 | * @see org.gvsig.raster.gui.wizards.IFileOpen#execute(java.io.File[])
|
||
89 | */
|
||
90 | public Rectangle2D createLayer(File file, MapControl mapControl, String driverName, IProjection proj) { |
||
91 | return null; |
||
92 | } |
||
93 | } |