Revision 24929

View differences:

branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/project/document/table/FeatureTableDocumentFactory.java
14 14
import org.gvsig.fmap.dal.DataStoreParameters;
15 15
import org.gvsig.fmap.dal.exception.DataException;
16 16
import org.gvsig.fmap.dal.exception.ReadException;
17
import org.gvsig.fmap.dal.explorer.filesystem.FilesystemStoreParameters;
18 17
import org.gvsig.fmap.dal.feature.FeatureStore;
19
import org.gvsig.fmap.dal.store.dbf.DBFStoreParameters;
18
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters;
20 19
import org.gvsig.fmap.data.feature.db.DBStoreParameters;
21 20
import org.gvsig.project.document.table.gui.FeatureTableDocumentPanel;
22 21

  
......
33 32
import com.iver.cit.gvsig.project.documents.contextMenu.actions.PasteDocumentContextMenuAction;
34 33
import com.iver.cit.gvsig.project.documents.table.TableFileOpen;
35 34
import com.iver.cit.gvsig.project.documents.table.gui.DataBaseOpenDialog;
36
import com.iver.cit.gvsig.project.documents.table.gui.Table;
37 35
import com.iver.utiles.XMLEntity;
38 36
import com.iver.utiles.extensionPoints.ExtensionPoints;
39 37
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/project/document/table/FeatureTableDocument.java
36 36
import com.iver.cit.gvsig.project.documents.ProjectDocument;
37 37
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
38 38
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
39
import com.iver.cit.gvsig.project.documents.table.LinkSelectionObserver;
39 40
import com.iver.utiles.XMLEntity;
40 41
import com.iver.utiles.XMLException;
41 42

  
......
50 51

  
51 52
    private FeatureStore store;
52 53

  
54
    private String linkTable;
55

  
56
	private String field1;
57

  
58
	private String field2;
59

  
60
	private LinkSelectionObserver linkSelectionObserver;
61

  
62

  
63

  
53 64
    public FeatureTableDocument(FeatureStore store) {
54 65
        this(store, null);
55 66
    }
......
117 128

  
118 129
	}
119 130

  
131
	/**
132
	 * Devuelve el identificador de la tabla que contiene el link.
133
	 *
134
	 * @return identificador ?nico de la tabla.
135
	 */
136
	public String getLinkTable() {
137
		return linkTable;
138
	}
139

  
140
	/**
141
	 * Devuelve el nombre del campo de la tabla a enlazar.
142
	 *
143
	 * @return Nombre del campo de la tabla a enlazar.
144
	 */
145
	public String getField1() {
146
		return field1;
147
	}
148

  
149
	/**
150
	 * Devuelve el nombre del campo de la tabla enlazada.
151
	 *
152
	 * @return Nombre del campo de la tabla enlazada.
153
	 */
154
	public String getField2() {
155
		return field2;
156
	}
157

  
158
	/**
159
	 * Inserta el identificador de la tabla, el campo de la primera tabla y el
160
	 * campo de la segunda tabla.
161
	 *
162
	 * @param lt
163
	 *            identificado de la tabla.
164
	 * @param f1
165
	 *            nombre del campo de la primera tabla.
166
	 * @param f2
167
	 *            nombre del campo de la segunda tabla.
168
	 */
169
	public void setLinkTable(String lt, String f1, String f2) {
170
		linkTable = lt;
171
		field1 = f1;
172
		field2 = f2;
173
	}
174

  
175
	/**
176
	 * Borra el identificador de la tabla y elimina del array de listener los
177
	 * listener que sean del tipo: LinkSelectionObserver
178
	 */
179
	public void removeLinkTable() {
180
		linkTable = null;
181
//		try {
182
			getStore().deleteObserver(linkSelectionObserver);//removeLinksSelectionListener();
183
//		} catch (ReadException e) {
184
//			e.printStackTrace();
185
//		}
186
	}
187
	public void addLinkSelectionObserver(LinkSelectionObserver lso) {
188
		linkSelectionObserver=lso;
189

  
190
	}
191

  
192

  
193

  
120 194
}
branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/Project.java
56 56

  
57 57
import org.cresques.cts.IProjection;
58 58
import org.gvsig.fmap.crs.CRSFactory;
59
import org.gvsig.fmap.dal.exception.ReadException;
59 60
import org.gvsig.fmap.mapcontext.MapContext;
60 61
import org.gvsig.fmap.mapcontext.layers.FLayer;
61 62
import org.gvsig.fmap.mapcontext.layers.FLayers;
62 63
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
64
import org.gvsig.project.document.table.FeatureTableDocument;
65
import org.gvsig.project.document.table.FeatureTableDocumentFactory;
63 66
import org.gvsig.tools.exception.DriverException;
64 67

  
65 68
import com.iver.andami.PluginServices;
......
80 83
import com.iver.cit.gvsig.project.documents.layout.ProjectMapFactory;
81 84
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
82 85
import com.iver.cit.gvsig.project.documents.table.LinkSelectionObserver;
83
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
84
import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory;
85 86
import com.iver.cit.gvsig.project.documents.view.ProjectView;
86 87
import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory;
87 88
import com.iver.utiles.IPersistence;
......
257 258
	 *
258 259
	 * @return ProjectTable de la tabla asociada.
259 260
	 */
260
	public ProjectTable getTable(FLyrVect co) {
261
		ArrayList tables = getDocumentsByType(ProjectTableFactory.registerName);
261
	public FeatureTableDocument getTable(FLyrVect co) {
262
		ArrayList tables = getDocumentsByType(FeatureTableDocumentFactory.registerName);
262 263
		/**
263 264
		 * Como las tablas se pueden a�adir cuando se pincha en "ver tabla" de
264 265
		 * una capa, se puede intentar a�adir dos veces la misma tabla
265 266
		 */
266 267
		for (int i = 0; i < tables.size(); i++) {
267
			if (((ProjectTable) tables.get(i)).getAssociatedTable() == co) {
268
				return (ProjectTable) tables.get(i);
268
			try {
269
				if (((FeatureTableDocument) tables.get(i)).getStore().equals(co.getFeatureStore())){
270
//			if (((FeatureTableDocument) tables.get(i)).getAssociatedTable() == co) {
271
					return (FeatureTableDocument) tables.get(i);
272
				}
273
			} catch (ReadException e) {
274
				e.printStackTrace();
269 275
			}
270 276
		}
271 277

  
......
280 286
	 * @deprecated utilizar getProjectDocumentByName(...);
281 287
	 * @return ProjectTable de la tabla asociada.
282 288
	 */
283
	public ProjectTable getTable(String name) {
284
		ArrayList tables = getDocumentsByType(ProjectTableFactory.registerName);
289
	public FeatureTableDocument getTable(String name) {
290
		ArrayList tables = getDocumentsByType(FeatureTableDocumentFactory.registerName);
285 291
		/**
286 292
		 * Como las tablas se pueden a�adir cuando se pincha en "ver tabla" de
287 293
		 * una capa, se puede intentar a�adir dos veces la misma tabla
288 294
		 */
289 295
		for (int i = 0; i < tables.size(); i++) {
290
			if (((ProjectTable) tables.get(i)).getName().equals(name)) {
291
				return (ProjectTable) tables.get(i);
296
			if (((FeatureTableDocument) tables.get(i)).getName().equals(name)) {
297
				return (FeatureTableDocument) tables.get(i);
292 298
			}
293 299
		}
294 300

  
......
547 553
	 * @return
548 554
	 */
549 555
	public ArrayList getTables() {
550
		return getDocumentsByType(ProjectTableFactory.registerName);
556
		return getDocumentsByType(FeatureTableDocumentFactory.registerName);
551 557
	}
552 558

  
553 559
	/**
......
588 594
	 * @deprecated utilizar addDocument(ProjectDocument pD);
589 595
	 * @param t
590 596
	 */
591
	public void addTable(ProjectTable t) {
597
	public void addTable(FeatureTableDocument t) {
592 598
		addDocument(t);
593 599
	}
594 600

  
......
600 606
	 *            indice de la tabla
601 607
	 */
602 608
	public void delTable(int i) {
603
		ArrayList list = getDocumentsByType(ProjectTableFactory.registerName);
609
		ArrayList list = getDocumentsByType(FeatureTableDocumentFactory.registerName);
604 610
		delDocument((ProjectDocument) list.get(i));
605 611
	}
606 612

  
......
1173 1179
	 * Reestablece los link que ten�a cada tabla con las dem�s.
1174 1180
	 */
1175 1181
	public void setLinkTable() {
1176
		ArrayList tables = getDocumentsByType(ProjectTableFactory.registerName);
1182
		ArrayList tables = getDocumentsByType(FeatureTableDocumentFactory.registerName);
1177 1183

  
1178 1184
		for (int i = 0; i < tables.size(); i++) {
1179 1185
			for (int j = 0; j < tables.size(); j++) {
......
1184 1190
				 * tables.get(i)).getLinkTable());
1185 1191
				 */
1186 1192
//				try {
1187
					if ((((ProjectTable) tables.get(i)).getLinkTable() != null)
1188
							&& ((ProjectTable) tables.get(i)).getLinkTable()
1193
					if ((((FeatureTableDocument) tables.get(i)).getLinkTable() != null)
1194
							&& ((FeatureTableDocument) tables.get(i)).getLinkTable()
1189 1195
							.equals(
1190
									((ProjectTable) tables.get(j))
1191
									.getModel()
1196
									((FeatureTableDocument) tables.get(j))
1197
									.getStore()
1192 1198
									.getName())) {
1193 1199
						LinkSelectionObserver lso;
1194 1200

  
1195
						lso = new LinkSelectionObserver(((ProjectTable) tables
1196
								.get(i)).getModel(),
1197
								((ProjectTable) tables.get(j)).getModel(),
1198
								((ProjectTable) tables
1201
						lso = new LinkSelectionObserver(((FeatureTableDocument) tables
1202
								.get(i)).getStore(),
1203
								((FeatureTableDocument) tables.get(j)).getStore(),
1204
								((FeatureTableDocument) tables
1199 1205
										.get(i)).getField1(),
1200
										((ProjectTable) tables.get(i)).getField2());
1206
										((FeatureTableDocument) tables.get(i)).getField2());
1201 1207

  
1202
						(((ProjectTable) tables.get(i)).getModel()).addObserver(lso);
1203
						((ProjectTable) tables.get(i)).addLinkSelectionObserver(lso);
1208
						(((FeatureTableDocument) tables.get(i)).getStore()).addObserver(lso);
1209
						((FeatureTableDocument) tables.get(i)).addLinkSelectionObserver(lso);
1204 1210

  
1205 1211
					}
1206 1212
//				} catch (ReadException e) {
branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/ProjectFactory.java
47 47
import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory;
48 48
import com.iver.cit.gvsig.project.documents.layout.ProjectMap;
49 49
import com.iver.cit.gvsig.project.documents.layout.ProjectMapFactory;
50
import com.iver.cit.gvsig.project.documents.table.ProjectTable;
51
import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory;
52 50
import com.iver.cit.gvsig.project.documents.view.ProjectView;
53 51
import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory;
54 52
import com.iver.utiles.extensionPoints.ExtensionPoint;
......
80 78
		ExtensionPoint extPoint=((ExtensionPoint)extensionPoints.get("Documents"));
81 79
		ProjectDocumentFactory pdf=null;
82 80
		try {
83
			pdf = (ProjectDocumentFactory)extPoint.create(ProjectTableFactory.registerName);
81
			pdf = (ProjectDocumentFactory)extPoint.create(FeatureTableDocumentFactory.registerName);
84 82
		} catch (InstantiationException e) {
85 83
			e.printStackTrace();
86 84
		} catch (IllegalAccessException e) {
branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/ProjectTableFactory.java
1
package com.iver.cit.gvsig.project.documents.table;
2

  
3
import java.io.File;
4
import java.text.DateFormat;
5
import java.util.Date;
6
import java.util.Hashtable;
7
import java.util.List;
8

  
9
import javax.swing.ImageIcon;
10
import javax.swing.JPanel;
11

  
12
import org.gvsig.fmap.dal.DALLocator;
13
import org.gvsig.fmap.dal.DataManager;
14
import org.gvsig.fmap.dal.DataStoreParameters;
15
import org.gvsig.fmap.dal.exception.ReadException;
16
import org.gvsig.fmap.data.feature.db.DBParameters;
17
import org.gvsig.fmap.data.feature.db.DBStoreParameters;
18

  
19
import com.iver.andami.PluginServices;
20
import com.iver.cit.gvsig.AddLayer;
21
import com.iver.cit.gvsig.addlayer.AddLayerDialog;
22
import com.iver.cit.gvsig.addlayer.fileopen.FileOpenWizard;
23
import com.iver.cit.gvsig.project.Project;
24
import com.iver.cit.gvsig.project.ProjectFactory;
25
import com.iver.cit.gvsig.project.documents.ProjectDocument;
26
import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory;
27
import com.iver.cit.gvsig.project.documents.contextMenu.actions.CopyDocumentContextMenuAction;
28
import com.iver.cit.gvsig.project.documents.contextMenu.actions.CutDocumentContextMenuAction;
29
import com.iver.cit.gvsig.project.documents.contextMenu.actions.PasteDocumentContextMenuAction;
30
import com.iver.cit.gvsig.project.documents.table.gui.DataBaseOpenDialog;
31
import com.iver.cit.gvsig.project.documents.table.gui.Table;
32
import com.iver.utiles.XMLEntity;
33
import com.iver.utiles.extensionPoints.ExtensionPoints;
34
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
35
import com.prodevelop.cit.gvsig.vectorialdb.wizard.WizardVectorialDB;
36

  
37

  
38
/**
39
 * Factory of Table.
40
 *
41
 * @author Vicente Caballero Navarro
42
 */
43
public class ProjectTableFactory extends ProjectDocumentFactory {
44
    public static String registerName = "ProjectTable";
45

  
46
    static {
47
  		// A�adimos nuestra extension para el tratamiento de la apertura de ficheros
48
  		// dentro de gvSIG
49
  		ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
50
  		extensionPoints.add("FileTableOpenDialog", "FileOpenTable", new TableFileOpen());
51
    }
52

  
53
    /**
54
     * Returns image of button.
55
     *
56
     * @return Image button.
57
     */
58
    public ImageIcon getButtonIcon() {
59
        return PluginServices.getIconTheme().get("document-table-icon");
60
    }
61

  
62
    /**
63
     * Returns image of selected button.
64
     *
65
     * @return Image button.
66
     */
67
    public ImageIcon getSelectedButtonIcon() {
68
        return PluginServices.getIconTheme().get("document-table-icon-sel");
69
    }
70

  
71
    /**
72
     * Introduce a gui to be able from the characteristics that we want a ProjectDocument
73
     *
74
     * @param project present Project.
75
     *
76
     * @return new ProjectDocument.
77
     */
78
    public ProjectDocument createFromGUI(Project project) {
79
        try {
80
            AddLayerDialog fopen = new AddLayerDialog(PluginServices.getText(this,
81
                        "Nueva_tabla"));
82
            FileOpenWizard fod = new FileOpenWizard("FileTableOpenDialog", false);
83
            fod.setTitle(PluginServices.getText(this, "Tablas"));
84

  
85
            DataBaseOpenDialog dbod = new DataBaseOpenDialog();
86
            dbod.setClasses(new Class[] { DBParameters.class });
87
            fopen.addWizardTab(PluginServices.getText(this, "Fichero"), fod);
88
//            fopen.addTab(PluginServices.getText(this, "base_datos"), dbod);
89
            WizardVectorialDB wp=new WizardVectorialDB();
90
            wp.initWizard();
91
            fopen.addWizardTab(wp.getTabName(), wp);
92
            PluginServices.getMDIManager().addWindow(fopen);
93
            wp.setMapCtrl(null);
94
    		wp.execute();
95
    		DataManager dm = DALLocator.getDataManager();
96
            if (fopen.isAccepted()) {
97
                JPanel panel = fopen.getSelectedTab();
98

  
99
                if (panel instanceof FileOpenWizard) {
100
                    File[] files = fod.getFiles();
101
                    String[] driverNames = fod.getDriverNames();
102
                    ProjectTable projectTable=null;
103
                    for (int i = 0; i < files.length; i++) {
104
                        String name = files[i].getName();
105
                        List stores = dm.getStoreProviders();
106
                        for (int j = 0; j < stores.size(); j++) {
107
                        	DataStoreParameters dsp=dm.createDataStoreParameters(stores[j]);
108
                        	if (dsp.getDescription().equals(driverNames[i])){
109
                        		FileStoreParameters fileParameters=(FileStoreParameters)dsp;
110
                                fileParameters.setFile(files[i]);
111

  
112
                                FeatureStore fs=(FeatureStore)dm.createDataStore((DataStoreParameters)fileParameters);
113

  
114

  
115
//                                LayerFactory.getDataSourceFactory().addFileDataSource(driverNames[i],
116
//                                    name, files[i].getAbsolutePath());
117
        //
118
//                                DataSource dataSource = LayerFactory.getDataSourceFactory()
119
//                                                                    .createRandomDataSource(name,
120
//                                        DataSourceFactory.AUTOMATIC_OPENING);
121
//                                SelectableDataSource sds = new SelectableDataSource(dataSource);
122
//                                EditableAdapter auxea = new EditableAdapter();
123
//                                auxea.setOriginalDataSource(sds);
124

  
125
                                // TODO: fjp: ESTO HAY QUE REVISARLO.
126
                                // Por ahora, para obtener un driver que sirva para esta
127
                                // fuente de datos, compruebo que implementa IWriteable.
128
                                // IWriter writer = (IWriter) LayerFactory.getWM().getWriter(driverNames[i]);
129
                                //	                	Driver drv = LayerFactory.getDM().getDriver(driverNames[i]);
130
                                //	                	if (drv instanceof IWriter)
131
                                //	                	{
132
                                //	                		auxea.setWriter((IWriter) drv);
133
                                //	                	}
134
                                projectTable = ProjectFactory.createTable(name,
135
                                        fs);
136

  
137
                                projectTable.setProjectDocumentFactory(this);
138

  
139
                                Table t = new Table();
140
                                t.setModel(projectTable);
141
                                PluginServices.getMDIManager().addWindow(t);
142

  
143

  
144
                        	}
145
                        }
146
                        return projectTable;
147

  
148
                    }
149
                } else if (panel instanceof WizardVectorialDB) {
150
                    DBStoreParameters[] parameters = (DBStoreParameters[]) wp
151
							.getParameters();
152
//                    int port = -1;
153
//
154
//                    try {
155
//                        port = Integer.parseInt(dbod.getPort());
156
//                    } catch (NumberFormatException e) {
157
//                    }
158
//
159
//                    String name = dbod.getHost() + "/" + dbod.getDataBase();
160
//
161
//                    if (port != -1) {
162
//                        name = dbod.getHost() + ":" + port + "/" +
163
//                            dbod.getDataBase();
164
//                    }
165
//
166
//                    String user = dbod.getUser().trim();
167
//                    String password = dbod.getPassword();
168
//
169
//                    if (user.equals("")) {
170
//                        user = null;
171
//                        password = null;
172
//                    }
173
//
174
//                    name = name + " Table:" + dbod.getTable();
175
//
176
//                    DBParameters dbParameters=(DBParameters)dm.createDataStoreParameters(driverName);
177
//                    dbParameters.setHost(dbod.getHost());
178
//                    dbParameters.setPort(dbod.getPort());
179
//                    dbParameters.setUser(dbod.getUser());
180
//                    dbParameters.setPassw(dbod.getPassword());
181
//                    dbParameters.setDb(dbod.getDataBase());
182
//                    dbParameters.setTableName(dbod.getTable());
183

  
184
                    ProjectTable projectTable = null;
185
                    for (int i = 0; i < parameters.length; i++) {
186
                    	 FeatureStore fs=(FeatureStore)dm.createDataStore(parameters[i]);
187
                    	 projectTable = ProjectFactory.createTable(parameters[i].getHost() + "/" + parameters[i].getDb(),
188
                                 fs);
189
                         projectTable.setProjectDocumentFactory(this);
190

  
191
                         Table t = new Table();
192
                         t.setModel(projectTable);
193
                         PluginServices.getMDIManager().addWindow(t);
194
                    }
195
                    return projectTable;
196

  
197
                }
198
            }
199
        } catch (ReadException e) {
200
			e.printStackTrace();
201
		}
202

  
203
        return null;
204
    }
205

  
206
    /**
207
     * Create a new ProjectTable
208
     *
209
     * @param baseName name
210
     *
211
     * @return ProjectTable.
212
     */
213
    public static ProjectTable createTable(String name, FeatureStore fs) {
214
        ProjectTable t = new ProjectTable();
215

  
216
        if (fs != null) {
217
            t.setModel(fs);
218

  
219
            try {
220
                t.createAlias();
221
            } catch (ReadException e) {
222
				e.printStackTrace();
223
			}
224
        }
225

  
226
        t.setName(name);
227
        t.setCreationDate(DateFormat.getInstance().format(new Date()));
228
        int numTables=(ProjectDocument.NUMS.get(registerName)).intValue();
229
        ProjectDocument.NUMS.put(registerName,new Integer(numTables++));
230

  
231
        return t;
232
    }
233

  
234
    /**
235
     * Returns the name of registration in the point of extension.
236
     *
237
     * @return Name of registration
238
     */
239
    public String getRegisterName() {
240
        return registerName;
241
    }
242

  
243
    /**
244
     * Registers in the points of extension the Factory with alias.
245
     *
246
     */
247
    public static void register() {
248
        register(registerName, new ProjectTableFactory(),
249
            "com.iver.cit.gvsig.project.ProjectTable");
250

  
251
        registerAction(registerName,"copy",new CopyDocumentContextMenuAction());
252
        registerAction(registerName,"cut",new CutDocumentContextMenuAction());
253
        registerAction(registerName,"paste",new PasteDocumentContextMenuAction());
254

  
255
        PluginServices.getIconTheme().registerDefault(
256
        		"document-table-icon",
257
        		AddLayer.class.getClassLoader().getResource("images/tablas.png")
258
        	);//
259
        PluginServices.getIconTheme().registerDefault(
260
        		"document-table-icon-sel",
261
        		AddLayer.class.getClassLoader().getResource("images/tablas_sel.png")
262
        	);
263

  
264
        PluginServices.getIconTheme().registerDefault(
265
        		"edit-copy",
266
        		AddLayer.class.getClassLoader().getResource("images/editcopy.png")
267
        	);//
268
        PluginServices.getIconTheme().registerDefault(
269
        		"edit-cut",
270
        		AddLayer.class.getClassLoader().getResource("images/editcut.png")
271
        	);
272
        PluginServices.getIconTheme().registerDefault(
273
        		"edit-paste",
274
        		AddLayer.class.getClassLoader().getResource("images/editpaste.png")
275
        	);
276
        PluginServices.getIconTheme().registerDefault(
277
        		"edit-delete",
278
        		AddLayer.class.getClassLoader().getResource("images/editdelete.png")
279
        	);
280
    }
281

  
282
    /**
283
     * Returns the name of ProjectDocument.
284
     *
285
     * @return Name of ProjectDocument.
286
     */
287
    public String getNameType() {
288
        return PluginServices.getText(this, "Tabla");
289
    }
290

  
291

  
292
    /**
293
     * Create a new ProjectDocument.
294
     *
295
     * @param project Opened project.
296
     *
297
     * @return ProjectDocument.
298
     */
299
    public ProjectDocument create(Project project) {
300
        ProjectTable pt = null;
301

  
302
        pt = ProjectTableFactory.createTable("", null);
303
        pt.setProject(project,0);
304

  
305
        pt.setProjectDocumentFactory(this);
306

  
307
        return pt;
308
    }
309

  
310
    /**
311
     * Returns the priority of de ProjectDocument.
312
     *
313
     * @return Priority.
314
     */
315
    public int getPriority() {
316
        return 1;
317
    }
318

  
319
	public boolean resolveImportXMLConflicts(XMLEntity root, Project project, Hashtable conflicts) {
320
		return true;
321
	}
322
}
branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/ProjectTable.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.table;
42

  
43
import java.util.ArrayList;
44

  
45
import org.gvsig.fmap.dal.exception.DataException;
46
import org.gvsig.fmap.dal.exception.ReadException;
47
import org.gvsig.fmap.dal.feature.FeatureStore;
48
import org.gvsig.fmap.dal.feature.FeatureType;
49
import org.gvsig.fmap.mapcontext.layers.FLayer;
50
import org.gvsig.fmap.mapcontext.layers.FLayers;
51
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
52
import org.gvsig.tools.exception.DriverException;
53

  
54
import com.iver.andami.messages.NotificationManager;
55
import com.iver.andami.ui.mdiManager.IWindow;
56
import com.iver.cit.gvsig.project.Project;
57
import com.iver.cit.gvsig.project.documents.ProjectDocument;
58
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
59
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
60
import com.iver.cit.gvsig.project.documents.table.gui.TableProperties;
61
import com.iver.cit.gvsig.project.documents.table.gui.tablemodel.Column;
62
import com.iver.cit.gvsig.project.documents.table.gui.tablemodel.Columns;
63
import com.iver.utiles.XMLEntity;
64
import com.iver.utiles.XMLException;
65

  
66
/**
67
 * Tabla del proyecto
68
 *
69
 * @author Fernando Gonz?lez Cort?s
70
 */
71
public class ProjectTable extends ProjectDocument{
72
	//public static int numTables = 0;
73

  
74
	private FeatureStore esModel;
75

  
76
	private FeatureStore original;
77

  
78
	private String linkTable;
79

  
80
	private String field1;
81

  
82
	private String field2;
83

  
84
	/* No es necesaria para operar, s?lo para guardar el proyecto */
85
	private FLyrVect associatedTable;
86

  
87
	private int[] mapping;
88

  
89
	private String[] alias;
90

  
91
	private Columns columns = new Columns();
92
	private long[] orderIndexes = null;
93

  
94
	private XMLEntity backupXMLEntity= null;
95

  
96
	private LinkSelectionObserver linkSelectionObserver;
97

  
98
//	private ArrayList observers=new ArrayList();
99

  
100
	/**
101
	 * Establece a true el bit index-?simo del bitmap de campos visibles. Los
102
	 * campos cuyos bits est?n a true se considerar?n visibles y viceversa
103
	 *
104
	 * @param index
105
	 *            indice del bit que se quiere establecer a true
106
	 */
107
	public void set(int index) {
108
		// TODO implementar bien
109
		// modelo.set(index);
110

  
111
		change.firePropertyChange("visibles", true, true);
112
	}
113

  
114
	/**
115
	 * Obtiene el valor del bit index-?simo del bitmap de campos visibles
116
	 *
117
	 * @param index
118
	 *            indice del bit que se quiere obtener
119
	 *
120
	 * @return devuelve true si el campo index-?simo es visible y false en caso
121
	 *         contrario
122
	 */
123
	public boolean get(int index) {
124
		// TODO implementar bien
125
		// return modelo.get(index);
126
		return false;
127
	}
128

  
129
	/**
130
	 * Obtiene el modelo de la Tabla. Es decir, una clase con capacidad para
131
	 * leer la informaci?n de la tabla
132
	 *
133
	 * @return
134
	 */
135
	public FeatureStore getModel() {
136
		return esModel;
137
	}
138

  
139
	/**
140
	 * Establece el valor del bit index-?simo al valor 'value'
141
	 *
142
	 * @param bitIndex
143
	 *            indice del bit que se quiere tocar
144
	 * @param value
145
	 *            valor que se quiere establecer en el bit indicado
146
	 */
147
	public void set(int bitIndex, boolean value) {
148
		// TODO implementar bien
149
		// modelo.set(bitIndex, value);
150
		change.firePropertyChange("visibles", value, value);
151
	}
152

  
153

  
154

  
155
	public void createAlias() throws DataException {
156
		FeatureType sds = esModel.getDefaultFeatureType();
157
//		mapping = new int[sds.getFieldCount()+1];
158
//		alias = new String[sds.getFieldCount()+1];
159
//		for (int i = 0; i < sds.getFieldCount()+1; i++) {
160
//		if (mapping == null){
161
			int size=sds.size();
162
			mapping = new int[size];
163
			alias = new String[size];
164
		for (int i = 0; i < size; i++) {
165
			mapping[i]=i;
166
			alias[i] = sds.getAttributeDescriptor(i).getName();
167

  
168
//			if (i==0){
169
//				mapping[i]=i;
170
//				alias[i]=" ";
171
//			}else{
172
//
173
//				mapping[i] = i;
174
//				alias[i] = sds.getFieldName(i-1);
175
//			}
176
//		}
177
		}
178

  
179
		recalculateColumnsFromAliases();
180

  
181
	}
182

  
183
	public void recalculateColumnsFromAliases()
184
	{
185
		ArrayList columnsAux=new ArrayList();
186
		columnsAux.addAll(columns);
187
		columns.clear();
188
		for (int i = 0; i < alias.length; i++) {
189
			if (columnsAux.size()>i) {
190
				columns.add(columnsAux.get(i));
191
			}else {
192
				addColumn(new Column());
193
			}
194
		}
195

  
196
	}
197

  
198
	/**
199
	 * DOCUMENT ME!
200
	 *
201
	 * @param sds
202
	 *            DOCUMENT ME!
203
	 * @throws DriverLoadException
204
	 * @throws ReadDriverException
205
	 */
206
//	public void setDataSource(IEditableSource es) throws DriverLoadException, ReadDriverException {
207
//		setModel(es);
208
//
209
//		setName(esModel.getRecordset().getName());
210
//		setCreationDate(DateFormat.getInstance().format(new Date()));
211
//		change.firePropertyChange("model", esModel, esModel);
212
//	}
213

  
214
	/**
215
	 * DOCUMENT ME!
216
	 *
217
	 * @param ds
218
	 *            DOCUMENT ME!
219
	 * @throws ReadDriverException
220
	 * @throws com.hardcode.gdbms.engine.data.driver.DriverException
221
	 */
222
//	public void replaceDataSource(IEditableSource es) throws ReadException {
223
//		if (original == null) {
224
//			original = esModel;
225
//		}
226
//		setModel(es);
227
//		 es.getRecordset().setSelectionSupport((original
228
//							.getRecordset()).getSelectionSupport());
229
//
230
//			createAlias();
231
//		// FJP:
232
//		// Si la tabla proviene de un layer, cambiamos su recordset
233
//		if (associatedTable != null) {
234
//			if (associatedTable instanceof FLyrVect) {
235
//				// ((EditableAdapter)((FLyrVect)
236
//				// associatedTable).getSource()).setRecordSet((SelectableDataSource)es.getRecordset());
237
//				FLyrVect lyrVect = (FLyrVect) associatedTable;
238
//				lyrVect.setRecordset(es.getRecordset());
239
//				((FLyrVect) associatedTable).setIsJoined(true);
240
//			}
241
//		}
242
//
243
//		change.firePropertyChange("model", original, esModel);
244
//	}
245

  
246
	/**
247
	 * DOCUMENT ME!
248
	 *
249
	 * @throws com.hardcode.gdbms.engine.data.driver.DriverException
250
	 * @throws DriverLoadException
251
	 */
252
//	public void restoreDataSource()
253
//			throws ReadException,
254
//			DriverLoadException {
255
//		// FJP:
256
//		// Si la tabla proviene de un layer, cambiamos su recordset
257
//		if (associatedTable != null) {
258
//			if (associatedTable instanceof FLyrVect) {
259
//				// Miramos si la leyenda que est? usando es una
260
//				// leyenda basada en un campo de los de la uni?n.
261
//				// Si lo es, no dejamos pegarle el cambiazo al recordset
262
//				FLyrVect lyr = ((FLyrVect) associatedTable);
263
//				if (lyr.getLegend() instanceof IClassifiedVectorLegend) {
264
//					IClassifiedVectorLegend legend = (IClassifiedVectorLegend) lyr
265
//							.getLegend();
266
//					IVectorLegend aux = (IVectorLegend) legend;
267
//					int idField = original.getRecordset().getFieldIndexByName(
268
//							legend.getClassifyingFieldNames()[0]);
269
//					int idLabelField = -2;
270
//
271
//					// TODO
272
//					NotificationManager.addWarning("Piece of code remains unrefactored in methdo com.iver.cit.gvsig.project.documents.table.ProjectTable.restoreDataSource()", null);
273
//					// TODO
274
////					if (aux.getLabelField() != null) {
275
////						idLabelField = original.getRecordset()
276
////								.getFieldIndexByName(aux.getLabelField());
277
////					}
278
////					if ((idField == -1) || (idLabelField == -1)) {
279
////						// No se ha encontrado ese campo, o se est? etiquetando
280
////						// por ese campo
281
////						JOptionPane.showMessageDialog(null, PluginServices
282
////								.getText(this, "leyenda_campo_unido"));
283
////
284
////						return;
285
////					}
286
//				}
287
//
288
//				lyr.setRecordset(original.getRecordset());
289
//
290
//				lyr.setIsJoined(false);
291
//			}
292
//		}
293
//
294
//		setModel(original);
295
//		original = null;
296
//		createAlias();
297
//
298
//		change.firePropertyChange("model", original, esModel);
299
//	}
300

  
301
	/**
302
	 * DOCUMENT ME!
303
	 *
304
	 * @return DOCUMENT ME!
305
	 * @throws SaveException
306
	 *
307
	 * @throws XMLException
308
	 */
309
	public XMLEntity getXMLEntity() throws SaveException {
310
		XMLEntity xml = super.getXMLEntity();
311
//		try {
312
//			// xml.putProperty("nameClass", this.getClass().getName());
313
//			int numTables=((Integer)ProjectDocument.NUMS.get(ProjectTableFactory.registerName)).intValue();
314
//
315
//			xml.putProperty("numTables", numTables);
316
//
317
//			if (this.getModelo() == null){
318
//				if (this.backupXMLEntity == null){
319
//					return xml;
320
//				} else{
321
//					return this.backupXMLEntity;
322
//				}
323
//			}
324
//
325
//			if (getLinkTable() != null) {
326
//				xml.putProperty("linkTable", linkTable);
327
//				xml.putProperty("field1", field1);
328
//				xml.putProperty("field2", field2);
329
//			}
330
//
331
//			if (getOriginal() != null) {
332
//				xml.addChild(getOriginal().getRecordset().getXMLEntity());
333
//			}
334
//			xml.addChild(esModel.getRecordset().getXMLEntity());
335
//
336
////			Object di = LayerFactory.getDataSourceFactory().getDriverInfo(
337
////					esModel.getRecordset().getName());
338
//
339
//			if (associatedTable != null) {
340
//				xml.putProperty("layerName", ((FLayer) associatedTable)
341
//						.getName());
342
//				xml.putProperty("viewName", project
343
//						.getView((FLayer) associatedTable));
344
//			}
345
//
346
//			xml.putProperty("mapping", mapping);
347
//			xml.putProperty("aliases", alias);
348
//		} catch (Exception e) {
349
//			throw new SaveException(e, this.getClass().getName());
350
//		}
351
//
352
//		// for (int i=0;i<columns.size();i++){
353
//		// Column column=(Column)columns.get(i);
354
//		// xml.addChild(column.getXMLEntity());
355
//		// }
356
//		xml.addChild(columns.getXMLEntity());
357
//		xml.putProperty("columns", true);
358
		return xml;
359
	}
360

  
361
	private void fillAsEmpty(){
362
		this.esModel = null;
363
		mapping = new int[0];
364
		alias = new String[0];
365
		recalculateColumnsFromAliases();
366
	}
367

  
368
	/**
369
	 * DOCUMENT ME!
370
	 *
371
	 * @param xml
372
	 *            DOCUMENT ME!
373
	 * @param p
374
	 *            DOCUMENT ME!
375
	 *
376
	 * @throws XMLException
377
	 * @throws DriverException
378
	 * @throws OpenException
379
	 *
380
	 * @see com.iver.cit.gvsig.project.documents.ProjectDocument#setXMLEntity(com.iver.utiles.XMLEntity)
381
	 */
382
	public void setXMLEntity(XMLEntity xml) throws XMLException {
383
//		try {
384
//			super.setXMLEntity(xml);
385
//			backupXMLEntity = xml;
386
//
387
//			setName(xml.getStringProperty("name"));
388
//			int numTables = xml.getIntProperty("numTables");
389
//			ProjectDocument.NUMS.put(ProjectTableFactory.registerName,new Integer(numTables));
390
//
391
//			if (xml.getChildrenCount() == 0){
392
//				fillAsEmpty();
393
//				return;
394
//
395
//			}
396
//			try{
397
//				setSelectableDataSource(xml);
398
//			} catch (ReadException e){
399
//				fillAsEmpty();
400
//				throw e;
401
//			}
402
//
403
//			/*
404
//			 * if (xml.getStringProperty("type").equals("otherDriverFile")) { }
405
//			 * else if (xml.getStringProperty("type").equals("sameDriverFile")) {
406
//			 * String layerName = xml.getStringProperty("layerName");
407
//			 * ProjectView vista = project.getViewByName(xml.getStringProperty(
408
//			 * "viewName")); FLayer layer =
409
//			 * vista.getMapContext().getLayers().getLayer(layerName);
410
//			 *
411
//			 * modelo = ((AlphanumericData) layer).getRecordset();
412
//			 * associatedTable = (AlphanumericData) layer; } else if
413
//			 * (xml.getStringProperty("type").equals("db")) {
414
//			 * setSelectableDataSource(xml); }
415
//			 */
416
//			setName(xml.getStringProperty("name"));
417
//
418
//			if (xml.contains("linkTable")) {
419
//				setLinkTable(xml.getStringProperty("linkTable"), xml
420
//						.getStringProperty("field1"), xml
421
//						.getStringProperty("field2"));
422
//			}
423
//
424
//			if (xml.contains("mapping")) {
425
//				mapping = xml.getIntArrayProperty("mapping");
426
//				alias = xml.getStringArrayProperty("aliases");
427
//				// we check if all fields are real there (may be some external program has changed them.
428
//				// If we detect any change, we discard all mapping and aliases.
429
//				if (mapping.length != getModelo().getRecordset().getFieldCount())
430
//				{
431
//					createAlias();
432
////					columns.clear();
433
////					for (int i = 0; i < esModel.getRecordset().getFieldCount(); i++) {
434
////						addColumn(new Column());
435
////					}
436
//					return;
437
//
438
//				}
439
//
440
//			} else {
441
//				try {
442
//					createAlias();
443
//				} catch (ReadException e) {
444
//					throw new XMLException(e);
445
//				}
446
//			}
447
//		} catch (Exception e) {
448
//			throw new OpenException(e, this.getClass().getName());
449
//		}
450
//
451
//		// for (int i=1;i<xml.getNumChild();i++){
452
//		// columns.add(Column.createColumn(xml.getChild(i)));
453
//		// }
454
//		if (xml.contains("columns")) {
455
//			columns.clear();
456
//			columns = Columns
457
//					.createColumns(xml.getChild(xml.getChildrenCount() - 1));
458
//		}
459

  
460

  
461
	}
462

  
463
	/**
464
	 * DOCUMENT ME!
465
	 *
466
	 * @param xml
467
	 *            DOCUMENT ME!
468
	 *
469
	 * @throws XMLException
470
	 *             DOCUMENT ME!
471
	 * @throws DriverException
472
	 *             DOCUMENT ME!
473
	 */
474
	private void setSelectableDataSource(XMLEntity xml) throws ReadException {
475
//		String layerName = null;
476
//		boolean bNeedToReplace = false;
477
//		XMLEntity xmlAux = null;
478
//
479
//		try {
480
//			EditableAdapter es;
481
//
482
//			if (xml.contains("layerName")) {
483
//				layerName = xml.getStringProperty("layerName");
484
//
485
//				ProjectView vista = (ProjectView) project.getProjectDocumentByName(xml
486
//						.getStringProperty("viewName"), ProjectViewFactory.registerName);
487
//				FLayer layer = getLayer(vista.getMapContext().getLayers(),
488
//						layerName);
489
//				EditableAdapter ea = new EditableAdapter();
490
//				SelectableDataSource sds = ((FLyrVect) layer).getRecordset();
491
//				// sds.setSelectionSupport(((FLyrVect)
492
//				// layer).getSelectionSupport());
493
//				ea.setOriginalDataSource(sds);
494
//				associatedTable = (FLyrVect) layer;
495
//
496
//				es = ea;
497
//			} else {
498
//				es = new EditableAdapter();
499
//				es.setOriginalDataSource(SelectableDataSource
500
//						.createSelectableDataSource(xml.getChild(0)));
501
//			}
502
//
503
//			setDataSource(es);
504
//
505
//			if (xml.getChildrenCount() == 2 && !(xml.contains("columns"))
506
//					|| (xml.contains("columns") && (xml.getChildrenCount() == 3))) {
507
//				bNeedToReplace = true;
508
//				xmlAux = xml.getChild(1);
509
//				es = new EditableAdapter();
510
//				// es.setRecordSet(SelectableDataSource.createSelectableDataSource(xmlAux));
511
//
512
//				// replaceDataSource(SelectableDataSource.createSelectableDataSource(xml.getChild(1)));
513
//			}
514
//
515
//			if (bNeedToReplace) {
516
//				if (layerName != null) {
517
//					ProjectView vista = (ProjectView) project.getProjectDocumentByName(xml
518
//							.getStringProperty("viewName"), ProjectViewFactory.registerName);
519
//					FLayer layer = getLayer(vista.getMapContext().getLayers(),
520
//							layerName);
521
//
522
//					// modelo = ((AlphanumericData) layer).getRecordset();
523
//					associatedTable = (FLyrVect) layer;
524
//				}
525
//
526
//				EditableAdapter auxea = new EditableAdapter();
527
//				auxea.setOriginalDataSource(SelectableDataSource
528
//						.createSelectableDataSource(xmlAux));
529
//				replaceDataSource(auxea);
530
//			}
531
//		} catch (DriverLoadException e) {
532
//			throw new ReadException(getName(),e);
533
//		} catch (XMLException e) {
534
//			throw new ReadException(getName(),e);
535
//		}
536
	}
537

  
538
	private FLayer getLayer(FLayers layers, String name) {
539
		FLayer aux;
540
		for (int i = 0; i < layers.getLayersCount(); i++) {
541
			if (layers.getLayer(i) instanceof FLayers) {
542
				aux = getLayer((FLayers) layers.getLayer(i), name);
543
				if (aux != null){
544
					return aux;
545
				}
546
			} else if (layers.getLayer(i).getName().equals(name)) {
547
				return layers.getLayer(i);
548
			}
549
		}
550
		return null;
551
	}
552

  
553
	/**
554
	 * DOCUMENT ME!
555
	 *
556
	 * @return DOCUMENT ME!
557
	 */
558
	public FLyrVect getAssociatedTable() {
559
		return associatedTable;
560
	}
561

  
562
	/**
563
	 * DOCUMENT ME!
564
	 *
565
	 * @param associatedTable
566
	 *            DOCUMENT ME!
567
	 */
568
	public void setAssociatedTable(FLyrVect associatedTable) {
569
		this.associatedTable = associatedTable;
570
	}
571

  
572
	/**
573
	 * Obtiene la fuente de datos original de la tabla si se ha invocado
574
	 * replaceDataSource. Si no se invoc? este m?todo o se invoc? posteriormente
575
	 * restoreDataSource se devuelve null
576
	 *
577
	 * @return Returns the original.
578
	 */
579
	public FeatureStore getOriginal() {
580
		return original;
581
	}
582

  
583
	/**
584
	 * Devuelve el identificador de la tabla que contiene el link.
585
	 *
586
	 * @return identificador ?nico de la tabla.
587
	 */
588
	public String getLinkTable() {
589
		return linkTable;
590
	}
591

  
592
	/**
593
	 * Devuelve el nombre del campo de la tabla a enlazar.
594
	 *
595
	 * @return Nombre del campo de la tabla a enlazar.
596
	 */
597
	public String getField1() {
598
		return field1;
599
	}
600

  
601
	/**
602
	 * Devuelve el nombre del campo de la tabla enlazada.
603
	 *
604
	 * @return Nombre del campo de la tabla enlazada.
605
	 */
606
	public String getField2() {
607
		return field2;
608
	}
609

  
610
	/**
611
	 * Inserta el identificador de la tabla, el campo de la primera tabla y el
612
	 * campo de la segunda tabla.
613
	 *
614
	 * @param lt
615
	 *            identificado de la tabla.
616
	 * @param f1
617
	 *            nombre del campo de la primera tabla.
618
	 * @param f2
619
	 *            nombre del campo de la segunda tabla.
620
	 */
621
	public void setLinkTable(String lt, String f1, String f2) {
622
		linkTable = lt;
623
		field1 = f1;
624
		field2 = f2;
625
	}
626

  
627
	/**
628
	 * Borra el identificador de la tabla y elimina del array de listener los
629
	 * listener que sean del tipo: LinkSelectionObserver
630
	 */
631
	public void removeLinkTable() {
632
		linkTable = null;
633
//		try {
634
			getModel().deleteObserver(linkSelectionObserver);//removeLinksSelectionListener();
635
//		} catch (ReadException e) {
636
//			e.printStackTrace();
637
//		}
638
	}
639

  
640
	public String[] getAliases() {
641
		return alias;
642
	}
643

  
644
	public void setAliases(String[] alias) {
645
		this.alias = alias;
646
	}
647

  
648
	public int[] getMapping() {
649
		if (mapping == null) {
650
			mapping = new int[alias.length];
651
			for (int i = 0; i < mapping.length; i++) {
652
				mapping[i] = i;
653
			}
654
		}
655
		return mapping;
656
	}
657

  
658
	public void setMapping(int[] mapping) {
659
		this.mapping = mapping;
660
	}
661

  
662
	public void setModel(FeatureStore fstore) {
663
		setTheModel(fstore);
664
		//((AbstractFeatureStore)fstore).notifyResourceChange();
665
		try {
666
//			if (mapping==null) {
667
				createAlias();
668
//			}
669
		} catch (DataException e) {
670
			e.printStackTrace();
671
			NotificationManager.addError(e);
672
		}
673
//		refresh();
674
	}
675

  
676
	public Column getColumn(int i) {
677
//		if (i==0){
678
//			Column column=new Column();
679
//			column.setWidth(45);
680
//			return column;
681
//		}
682
//		i--;
683
			return (Column) columns.get(getMapping()[i]);
684
	}
685

  
686
	public void addColumn(Column column) {
687
		columns.add(column);
688
	}
689

  
690
	public int getColumnCount() {
691
		return columns.size();
692
	}
693

  
694
	public IWindow createWindow() {
695
		if (this.getModel() == null) {
696
			return null;
697
		}
698
		com.iver.cit.gvsig.project.documents.table.gui.Table table = new com.iver.cit.gvsig.project.documents.table.gui.Table();
699
		table.setModel(this);
700
		return table;
701
	}
702
	public IWindow getProperties() {
703
		return new TableProperties(this);
704
	}
705

  
706
	public void afterRemove() {
707
		// TODO Auto-generated method stub
708

  
709
	}
710

  
711
	public void afterAdd() {
712
		// TODO Auto-generated method stub
713

  
714
	}
715

  
716
	private void setTheModel(FeatureStore fs) {
717
		this.esModel = fs;
718

  
719
	}
720

  
721
	public void exportToXML(XMLEntity root, Project project)  throws SaveException {
722
		//TODO
723
//		XMLEntity tableRoot = project.getExportXMLTypeRootNode(root,ProjectTableFactory.registerName);
724
//		try {
725
//			project.exportToXMLDataSource(root,this.getModelo().getRecordset().getName());
726
//		} catch (ReadDriverException e) {
727
//			throw new SaveException();
728
//		}
729
//		tableRoot.addChild(this.getXMLEntity());
730
	}
731

  
732
	public void importFromXML(XMLEntity root, XMLEntity typeRoot,int elementIndex ,Project project, boolean removeDocumentsFromRoot) throws XMLException {
733
		//TODO
734
//		XMLEntity element = typeRoot.getChild(elementIndex);
735
//		this.setXMLEntity(element);
736
//		if (removeDocumentsFromRoot) {
737
//			typeRoot.removeChild(elementIndex);
738
//		}
739
//		project.addDocument(this);
740

  
741
	}
742

  
743
	public long[] getOrderIndexes() {
744
		return orderIndexes;
745
	}
746

  
747
	public void setOrderIndexes(long[] orderIndexes) {
748
		this.orderIndexes = orderIndexes;
749
	}
750

  
751
	public void addLinkSelectionObserver(LinkSelectionObserver lso) {
752
		linkSelectionObserver=lso;
753

  
754
	}
755

  
756
//	public void addObserver(Observer arg0) {
757
//		observers.add(arg0);
758
//	}
759
//
760
//	public void deleteObserver(Observer arg0) {
761
//		observers.remove(arg0);
762
//
763
//	}
764
//
765
//	public void deleteObservers() {
766
//		observers.clear();
767
//
768
//	}
769
//	private void refresh(){
770
//		for (int i = 0; i < observers.size(); i++) {
771
//			((Observer)observers.get(i)).update(this,null);
772
//		}
773
//	}
774

  
775
//	public int computeSignature() {
776
//		int result = 17;
777
//
778
//		Class clazz = getClass();
779
//		Field[] fields = clazz.getDeclaredFields();
780
//		for (int i = 0; i < fields.length; i++) {
781
//			try {
782
//				String type = fields[i].getType().getName();
783
//				if (type.equals("boolean")) {
784
//					result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
785
//				} else if (type.equals("java.lang.String")) {
786
//					Object v = fields[i].get(this);
787
//					if (v == null) {
788
//						result += 37;
789
//						continue;
790
//					}
791
//					char[] chars = ((String) v).toCharArray();
792
//					for (int j = 0; j < chars.length; j++) {
793
//						result += 37 + (int) chars[i];
794
//					}
795
//				} else if (type.equals("byte")) {
796
//					result += 37 + (int) fields[i].getByte(this);
797
//				} else if (type.equals("char")) {
798
//					result += 37 + (int) fields[i].getChar(this);
799
//				} else if (type.equals("short")) {
800
//					result += 37 + (int) fields[i].getShort(this);
801
//				} else if (type.equals("int")) {
802
//					result += 37 + fields[i].getInt(this);
803
//				} else if (type.equals("long")) {
804
//					long f = fields[i].getLong(this) ;
805
//					result += 37 + (f ^ (f >>> 32));
806
//				} else if (type.equals("float")) {
807
//					result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
808
//				} else if (type.equals("double")) {
809
//					long f = Double.doubleToLongBits(fields[i].getDouble(this));
810
//					result += 37 + (f ^ (f >>> 32));
811
//				} else {
812
//					Object obj = fields[i].get(this);
813
//					result += 37 + ((obj != null)? obj.hashCode() : 0);
814
//				}
815
//			} catch (Exception e) { e.printStackTrace(); }
816
//
817
//		}
818
//		return result;
819
//	}
820
}
branches/v2_0_0_prep/applications/appgvSIG/build.xml
140 140
			<fileset dir="${workspaceDir}/libFMap_mapcontrol/dist" includes="*.jar,*.zip"/>
141 141
		</copy>
142 142
		<copy todir="${lib-references}" failonerror="false">
143
			<fileset dir="${workspaceDir}/libFMap_mapcontrol/lib" includes="*.jar,*.zip"/>
144
			<fileset dir="${workspaceDir}/libFMap_mapcontrol/lib-references" includes="*.jar,*.zip"/>
143
			<fileset dir="${workspaceDir}/libFMap_controls/lib" includes="*.jar,*.zip"/>
144
			<fileset dir="${workspaceDir}/libFMap_controls/lib-references" includes="*.jar,*.zip"/>
145 145
		</copy>
146 146

  
147 147
		<copy todir="${lib}" failonerror="false">
......
162 162
		</copy>
163 163

  
164 164
		<copy todir="${lib}" failonerror="false">
165
			<fileset dir="${workspaceDir}/libFMap_data/dist" includes="*.jar,*.zip"/>
165
			<fileset dir="${workspaceDir}/libFMap_dal/dist" includes="*.jar,*.zip"/>
166 166
		</copy>
167 167
		<copy todir="${lib-references}" failonerror="false">
168
			<fileset dir="${workspaceDir}/libFMap_data/lib" includes="*.jar,*.zip"/>
169
			<fileset dir="${workspaceDir}/libFMap_data/lib-references" includes="*.jar,*.zip"/>
168
			<fileset dir="${workspaceDir}/libFMap_dal/lib" includes="*.jar,*.zip"/>
169
			<fileset dir="${workspaceDir}/libFMap_dal/lib-references" includes="*.jar,*.zip"/>
170 170
		</copy>
171 171

  
172 172
		<copy todir="${lib}" failonerror="false">
173
			<fileset dir="${workspaceDir}/libFMap_dataFile/dist" includes="*.jar,*.zip"/>
173
			<fileset dir="${workspaceDir}/libFMap_dajfile/dist" includes="*.jar,*.zip"/>
174 174
		</copy>
175 175
		<copy todir="${lib-references}" failonerror="false">
176
			<fileset dir="${workspaceDir}/libFMap_dataFile/lib" includes="*.jar,*.zip"/>
177
			<fileset dir="${workspaceDir}/libFMap_dataFile/lib-references" includes="*.jar,*.zip"/>
176
			<fileset dir="${workspaceDir}/libFMap_dalfile/lib" includes="*.jar,*.zip"/>
177
			<fileset dir="${workspaceDir}/libFMap_dalfile/lib-references" includes="*.jar,*.zip"/>
178 178
		</copy>
179 179

  
180 180
		<copy todir="${lib}" failonerror="false">
181
			<fileset dir="${workspaceDir}/libFMap_dataDB/dist" includes="*.jar,*.zip"/>
181
			<fileset dir="${workspaceDir}/libFMap_daldb/dist" includes="*.jar,*.zip"/>
182 182
		</copy>
183 183
		<copy todir="${lib-references}" failonerror="false">
184
			<fileset dir="${workspaceDir}/libFMap_dataDB/lib" includes="*.jar,*.zip"/>
185
			<fileset dir="${workspaceDir}/libFMap_dataDB/lib-references" includes="*.jar,*.zip"/>
184
			<fileset dir="${workspaceDir}/libFMap_daldb/lib" includes="*.jar,*.zip"/>
185
			<fileset dir="${workspaceDir}/libFMap_daldb/lib-references" includes="*.jar,*.zip"/>
186 186
		</copy>
187 187

  
188 188
		<copy todir="${lib}" failonerror="false">
......
198 198

  
199 199

  
200 200
		<copy todir="${lib}" failonerror="false">
201
			<fileset dir="${workspaceDir}/libFMap_spatialindex/dist" includes="*.jar,*.zip"/>
201
			<fileset dir="${workspaceDir}/libFMap_dalindex/dist" includes="*.jar,*.zip"/>
202 202
		</copy>
203 203
		<copy todir="${lib-references}" failonerror="false">
204
			<fileset dir="${workspaceDir}/libFMap_spatialindex/lib" includes="*.jar,*.zip"/>
204
			<fileset dir="${workspaceDir}/libFMap_dalindex/lib" includes="*.jar,*.zip"/>
205 205
		</copy>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff