Revision 13716
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/addlayer/fileopen/FileOpenWizard.java | ||
---|---|---|
66 | 66 |
private String title = PluginServices.getText(this, PluginServices.getText(this, "Capas")); |
67 | 67 |
private CRSSelectPanel jPanelProj = null; |
68 | 68 |
private ListManagerSkin listManagerSkin = null; |
69 |
private boolean proj = false;
|
|
69 |
private boolean projection = false;
|
|
70 | 70 |
static private FileFilter lastFileFilter = null; |
71 | 71 |
|
72 | 72 |
/** |
73 | 73 |
* Lista de manejadores de ficheros (extensiones) |
74 | 74 |
*/ |
75 |
private ArrayList listFileOpen; |
|
75 |
private ArrayList listFileOpen = new ArrayList();
|
|
76 | 76 |
|
77 | 77 |
public FileOpenWizard() { |
78 | 78 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
... | ... | |
81 | 81 |
return; |
82 | 82 |
|
83 | 83 |
Iterator iterator = extensionPoint.keySet().iterator(); |
84 |
listFileOpen = new ArrayList(); |
|
85 | 84 |
while (iterator.hasNext()) { |
86 | 85 |
String key = (String) iterator.next(); |
87 | 86 |
Object obj = extensionPoint.get(key); |
... | ... | |
97 | 96 |
* @param driverClasses |
98 | 97 |
* @param proj |
99 | 98 |
*/ |
100 |
public FileOpenWizard(Class[] driverClasses, boolean proj) {
|
|
99 |
public FileOpenWizard(IFileOpen[] driverClasses, boolean proj) {
|
|
101 | 100 |
init(driverClasses, proj); |
102 | 101 |
} |
103 | 102 |
|
... | ... | |
105 | 104 |
* Creates a new FileOpenWizard object. |
106 | 105 |
* @param driverClasses |
107 | 106 |
*/ |
108 |
public FileOpenWizard(Class[] driverClasses) {
|
|
107 |
public FileOpenWizard(IFileOpen[] driverClasses) {
|
|
109 | 108 |
init(driverClasses, true); |
110 | 109 |
} |
111 | 110 |
|
... | ... | |
115 | 114 |
* @param proj |
116 | 115 |
* @param title |
117 | 116 |
*/ |
118 |
public FileOpenWizard(Class[] driverClasses, boolean proj, String title) {
|
|
117 |
public FileOpenWizard(IFileOpen[] driverClasses, boolean proj, String title) {
|
|
119 | 118 |
this.title = title; |
120 | 119 |
init(driverClasses, proj); |
121 | 120 |
} |
... | ... | |
133 | 132 |
* @param driverClasses2 |
134 | 133 |
* @param b |
135 | 134 |
*/ |
136 |
private void init(Class[] driverClasses, boolean proj) {
|
|
137 |
this.proj = proj;
|
|
135 |
private void init(IFileOpen[] driverClasses, boolean projection) {
|
|
136 |
this.projection = projection;
|
|
138 | 137 |
|
138 |
if (driverClasses != null) |
|
139 |
for (int i = 0; i < driverClasses.length; i++) |
|
140 |
listFileOpen.add(driverClasses[i]); |
|
141 |
|
|
139 | 142 |
if (lastPath == null) { |
140 | 143 |
Preferences prefs = Preferences.userRoot().node("gvsig.foldering"); |
141 | 144 |
lastPath = prefs.get("DataFolder", null); |
... | ... | |
181 | 184 |
jPanel2.setPreferredSize(new Dimension(380, 200)); |
182 | 185 |
jPanel2.setBounds(2, 2, 506, 472); |
183 | 186 |
titledBorder1.setTitle(this.title); |
184 |
if (proj) {
|
|
187 |
if (projection)
|
|
185 | 188 |
jPanel2.add(getJPanelProj(), null); |
186 |
} |
|
187 | 189 |
jPanel2.add(getListManagerSkin(), null); |
188 | 190 |
} |
189 | 191 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/DEMO/ComandosListener.java | ||
---|---|---|
79 | 79 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
80 | 80 |
import com.iver.cit.gvsig.addlayer.AddLayerDialog; |
81 | 81 |
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard; |
82 |
import com.iver.cit.gvsig.addlayer.fileopen.vectorial.VectorialFileOpen; |
|
83 | 82 |
import com.iver.cit.gvsig.fmap.MapContext; |
84 | 83 |
import com.iver.cit.gvsig.fmap.MapControl; |
85 | 84 |
import com.iver.cit.gvsig.fmap.ViewPort; |
... | ... | |
104 | 103 |
import com.iver.cit.gvsig.project.documents.table.gui.DataBaseOpenDialog; |
105 | 104 |
import com.iver.cit.gvsig.project.documents.table.gui.Table; |
106 | 105 |
import com.iver.cit.gvsig.project.documents.view.gui.FPanelLocConfig; |
107 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
|
108 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
|
109 | 106 |
import com.vividsolutions.jts.geom.LineString; |
110 | 107 |
import com.vividsolutions.jts.geom.MultiLineString; |
111 | 108 |
import com.vividsolutions.jts.geom.MultiPoint; |
... | ... | |
365 | 362 |
JDialog dlg = new JDialog(); |
366 | 363 |
dlg.setModal(true); |
367 | 364 |
|
368 |
FileOpenWizard fileDlg = new FileOpenWizard(new Class[] { |
|
369 |
VectorialFileDriver.class}); //, RasterDriver.class }); |
|
365 |
FileOpenWizard fileDlg = null; //new FileOpenWizard(new IFileOpen[] {VectorialFileDriver.class}); //, RasterDriver.class }); |
|
370 | 366 |
DataBaseOpenDialog dbop = new DataBaseOpenDialog(); |
371 | 367 |
// dbop.setClasses(new Class[]{DBDriver.class}); |
372 | 368 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/ProjectTableFactory.java | ||
---|---|---|
14 | 14 |
import com.hardcode.gdbms.engine.data.DataSourceFactory; |
15 | 15 |
import com.hardcode.gdbms.engine.data.NoSuchTableException; |
16 | 16 |
import com.hardcode.gdbms.engine.data.driver.DBDriver; |
17 |
import com.hardcode.gdbms.engine.data.driver.FileDriver; |
|
18 | 17 |
import com.iver.andami.PluginServices; |
19 | 18 |
import com.iver.andami.messages.NotificationManager; |
20 | 19 |
import com.iver.cit.gvsig.addlayer.AddLayerDialog; |
21 | 20 |
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard; |
21 |
import com.iver.cit.gvsig.addlayer.fileopen.IFileOpen; |
|
22 | 22 |
import com.iver.cit.gvsig.fmap.edition.EditableAdapter; |
23 | 23 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
24 | 24 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
... | ... | |
72 | 72 |
try { |
73 | 73 |
AddLayerDialog fopen = new AddLayerDialog(PluginServices.getText(this, |
74 | 74 |
"Nueva_tabla")); |
75 |
FileOpenWizard fod = new FileOpenWizard(new Class[] { FileDriver.class }, |
|
76 |
false, PluginServices.getText(this, "Tablas")); |
|
75 |
FileOpenWizard fod = new FileOpenWizard(new IFileOpen[] { new TableFileOpen() }, false, PluginServices.getText(this, "Tablas")); |
|
77 | 76 |
DataBaseOpenDialog dbod = new DataBaseOpenDialog(); |
78 | 77 |
dbod.setClasses(new Class[] { DBDriver.class }); |
79 |
fopen.addTab(PluginServices.getText(this, "Fichero"), fod); |
|
78 |
fopen.addWizardTab(PluginServices.getText(this, "Fichero"), fod);
|
|
80 | 79 |
fopen.addTab(PluginServices.getText(this, "base_datos"), dbod); |
81 | 80 |
PluginServices.getMDIManager().addWindow(fopen); |
82 | 81 |
|
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/TableFileOpen.java | ||
---|---|---|
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.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 |
import com.iver.cit.gvsig.addlayer.fileopen.IFileOpen; |
|
34 |
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 |
* |
|
39 |
* @version 04/09/2007 |
|
40 |
* @author BorSanZa - Borja S?nchez Zamorano (borja.sanchez@iver.es) |
|
41 |
*/ |
|
42 |
public class TableFileOpen implements IFileOpen { |
|
43 |
private ArrayList arrayFileFilter; |
|
44 |
|
|
45 |
/** |
|
46 |
* Constructor de FileOpenRaster |
|
47 |
*/ |
|
48 |
public TableFileOpen() { |
|
49 |
arrayFileFilter = new ArrayList(); |
|
50 |
|
|
51 |
TreeSet filters = new TreeSet(new Comparator() { |
|
52 |
public int compare(Object o1, Object o2) { |
|
53 |
TableFileFilter dff1 = (TableFileFilter) o1; |
|
54 |
TableFileFilter dff2 = (TableFileFilter) o2; |
|
55 |
|
|
56 |
return dff1.driver.getName().compareTo(dff2.driver.getName()); |
|
57 |
} |
|
58 |
}); |
|
59 |
|
|
60 |
Class[] driverClasses = new Class[] { FileDriver.class }; |
|
61 |
String[] driverNames = LayerFactory.getDM().getDriverNames(); |
|
62 |
TableFileFilter auxF; |
|
63 |
try { |
|
64 |
for (int i = 0; i < driverNames.length; i++) { |
|
65 |
System.err.println("DRIVER " + i + " : " + driverNames[i]); |
|
66 |
boolean is = false; |
|
67 |
for (int j = 0; j < driverClasses.length; j++) { |
|
68 |
if (LayerFactory.getDM().isA(driverNames[i], driverClasses[j])) { |
|
69 |
is = true; |
|
70 |
break; |
|
71 |
} |
|
72 |
} |
|
73 |
if (is) { |
|
74 |
auxF = new TableFileFilter(driverNames[i]); |
|
75 |
System.out.println("DRIVER " + i + " : " + driverNames[i]); |
|
76 |
filters.add(auxF); |
|
77 |
} |
|
78 |
} |
|
79 |
Iterator iterator = filters.iterator(); |
|
80 |
while (iterator.hasNext()) { |
|
81 |
TableFileFilter filter = (TableFileFilter) iterator.next(); |
|
82 |
arrayFileFilter.add(filter); |
|
83 |
} |
|
84 |
} catch (DriverLoadException exception) { |
|
85 |
NotificationManager.addError("No se pudo acceder a los drivers", exception); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
/* |
|
90 |
* (non-Javadoc) |
|
91 |
* @see org.gvsig.raster.gui.wizards.IFileOpen#pre() |
|
92 |
*/ |
|
93 |
public void pre() { |
|
94 |
} |
|
95 |
|
|
96 |
/* |
|
97 |
* (non-Javadoc) |
|
98 |
* @see org.gvsig.raster.gui.wizards.IFileOpen#post(java.io.File[]) |
|
99 |
*/ |
|
100 |
public void post(File[] file) { |
|
101 |
} |
|
102 |
|
|
103 |
/* |
|
104 |
* (non-Javadoc) |
|
105 |
* @see org.gvsig.raster.gui.wizards.IFileOpen#getFileFilter() |
|
106 |
*/ |
|
107 |
public ArrayList getFileFilter() { |
|
108 |
return arrayFileFilter; |
|
109 |
} |
|
110 |
|
|
111 |
/* |
|
112 |
* (non-Javadoc) |
|
113 |
* @see org.gvsig.raster.gui.wizards.IFileOpen#execute(java.io.File[]) |
|
114 |
*/ |
|
115 |
public Rectangle2D createLayer(File file, MapControl mapControl, String driverName, IProjection proj) { |
|
116 |
return null; |
|
117 |
} |
|
118 |
} |
|
0 | 119 |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/TableFileFilter.java | ||
---|---|---|
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 |
} |
|
0 | 63 |
Also available in: Unified diff