Statistics
| Revision:

svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / Project.java @ 7288

History | View | Annotate | Download (38.2 KB)

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;
42

    
43
import java.awt.Color;
44
import java.beans.PropertyChangeEvent;
45
import java.beans.PropertyChangeListener;
46
import java.beans.PropertyChangeSupport;
47
import java.io.Serializable;
48
import java.lang.reflect.Field;
49
import java.lang.reflect.Modifier;
50
import java.text.DateFormat;
51
import java.util.ArrayList;
52
import java.util.Date;
53
import java.util.Hashtable;
54
import java.util.Iterator;
55

    
56
import org.cresques.cts.IProjection;
57
import org.cresques.cts.ProjectionPool;
58

    
59
import com.hardcode.driverManager.DriverLoadException;
60
import com.hardcode.gdbms.engine.data.DataSource;
61
import com.hardcode.gdbms.engine.data.NoSuchTableException;
62
import com.hardcode.gdbms.engine.data.SourceInfo;
63
import com.hardcode.gdbms.engine.data.db.DBSourceInfo;
64
import com.hardcode.gdbms.engine.data.db.DBTableSourceInfo;
65
import com.hardcode.gdbms.engine.data.file.FileSourceInfo;
66
import com.hardcode.gdbms.engine.data.object.ObjectSourceInfo;
67
import com.iver.andami.PluginServices;
68
import com.iver.andami.ui.mdiManager.IWindow;
69
import com.iver.andami.ui.mdiManager.WindowInfo;
70
import com.iver.cit.gvsig.ProjectExtension;
71
import com.iver.cit.gvsig.fmap.DriverException;
72
import com.iver.cit.gvsig.fmap.MapContext;
73
import com.iver.cit.gvsig.fmap.ViewPort;
74
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
75
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
76
import com.iver.cit.gvsig.fmap.layers.CancelationException;
77
import com.iver.cit.gvsig.fmap.layers.FLayer;
78
import com.iver.cit.gvsig.fmap.layers.FLayers;
79
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
80
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
81
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
82
import com.iver.cit.gvsig.fmap.layers.XMLException;
83
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData;
84
import com.iver.cit.gvsig.fmap.operations.selection.LinkSelectionListener;
85
import com.iver.cit.gvsig.gui.project.OpenException;
86
import com.iver.cit.gvsig.gui.project.ProjectWindow;
87
import com.iver.cit.gvsig.gui.project.SaveException;
88
import com.iver.utiles.PostProcessSupport;
89
import com.iver.utiles.StringUtilities;
90
import com.iver.utiles.Utils;
91
import com.iver.utiles.XMLEntity;
92

    
93

    
94
/**
95
 * Clase que representa un proyecto de openSIG
96
 *
97
 * @author Fernando Gonz?lez Cort?s
98
 */
99
public class Project implements Serializable, PropertyChangeListener {
100
        public static String VERSION = "1.0";
101
        static private IProjection defaultProjection = ProjectionPool.get(
102
                        "EPSG:23030");
103
        private PropertyChangeSupport change;
104
        boolean modified = false;
105
        private String name;
106
        //private String path;
107
        private String creationDate;
108
        private String modificationDate;
109
        private String owner;
110
        private String comments;
111
        private Color selectionColor = new Color(255, 255, 0);
112
        private ArrayList views = new ArrayList();
113
        private ArrayList tables = new ArrayList();
114
        private ArrayList maps = new ArrayList();
115
        private ArrayList extents = new ArrayList();
116
        private int signatureAtStartup;
117
        // used to restore the position of the Project Manager window when loading a project from file
118
        private static WindowInfo seedProjectWindow = null;
119
        private IProjection projection;
120

    
121

    
122
        /**
123
         * Creates a new Project object.
124
         */
125
        public Project() {
126
                change = new PropertyChangeSupport(this);
127

    
128
                //        change.addPropertyChangeListener(this);
129
                creationDate = DateFormat.getDateInstance().format(new Date());
130
                modificationDate = creationDate;
131
//                signatureAtStartup = computeSignature();
132

    
133
                /*                LayerFactory.setDriversPath(PluginServices.getPluginServices(this)
134
                   .getPluginDirectory()
135
                   .getAbsolutePath() +
136
                   File.separator + "drivers");
137
                 */
138
        }
139

    
140
        /**
141
         * Obtiene la fecha de creaci?n del proyecto
142
         *
143
         * @return
144
         */
145
        public String getCreationDate() {
146
                return creationDate;
147
        }
148

    
149
        /**
150
         * Obtiene el nombre del proyecto
151
         *
152
         * @return
153
         */
154
        public String getName() {
155
                return name;
156
        }
157

    
158
//        /**
159
//         * Obtiene la ruta completa del fichero donde se guardo por ?ltima vez el
160
//         * proyecto
161
//         *
162
//         * @return
163
//         */
164
//        public String getPath() {
165
//                return path;
166
//        }
167

    
168
        /**
169
         * Asigna la fecha de creaci?n del proyecto. Este m?todo tiene sentido s?lo
170
         * por que al recuperar la fecha del XML hay que asignarla al objeto
171
         * proyecto de alguna manera. La fecha se asigna en el constructor y no se
172
         * deber?a de modificar nunca
173
         *
174
         * @param string
175
         */
176
        public void setCreationDate(String string) {
177
                creationDate = string;
178
                modified = true;
179
                change.firePropertyChange("", null, null);
180
        }
181

    
182
        /**
183
         * A?ade un mapa al proyecto
184
         *
185
         * @param m
186
         */
187
        public void addMap(ProjectMap m) {
188
                maps.add(m);
189
                m.addPropertyChangeListener(this);
190
                modified = true;
191
                change.firePropertyChange("", null, null);
192
                m.setProject(this, maps.size() - 1);
193
        }
194

    
195
        /**
196
         * Elimina un mapa del proyecto
197
         *
198
         * @param i indice del mapa
199
         */
200
        public void delMap(int i) {
201
                maps.remove(i);
202
                modified = true;
203
                change.firePropertyChange("", null, null);
204
        }
205

    
206
        /**
207
         * Establece el nombre del proyecto
208
         *
209
         * @param string
210
         */
211
        public void setName(String string) {
212
                name = string;
213
                modified = true;
214
                change.firePropertyChange("", null, null);
215
        }
216

    
217
//        /**
218
//         * establece la ruta completa de donde se encuentra guardado el proyecto
219
//         *
220
//         * @param string
221
//         */
222
//        public void setPath(String string) {
223
//                path = string;
224
//                modified = true;
225
//                change.firePropertyChange("", null, null);
226
//        }
227

    
228
        /**
229
         * DOCUMENT ME!
230
         *
231
         * @param co DOCUMENT ME!
232
         *
233
         * @return DOCUMENT ME!
234
         */
235
        public ProjectTable getTable(AlphanumericData co) {
236
                /**
237
                 * Como las tablas se pueden a?adir cuando se pincha en "ver tabla" de
238
                 * una capa, se puede intentar a?adir dos veces la misma tabla
239
                 */
240
                for (int i = 0; i < tables.size(); i++) {
241
                        if (((ProjectTable) tables.get(i)).getAssociatedTable() == co) {
242
                                return (ProjectTable) tables.get(i);
243
                        }
244
                }
245

    
246
                return null;
247
        }
248

    
249
        public ProjectTable getTable(String name) {
250
                /**
251
                 * Como las tablas se pueden a?adir cuando se pincha en "ver tabla" de
252
                 * una capa, se puede intentar a?adir dos veces la misma tabla
253
                 */
254
                for (int i = 0; i < tables.size(); i++) {
255
                        if (((ProjectTable) tables.get(i)).getName().equals(name)) {
256
                                return (ProjectTable) tables.get(i);
257
                        }
258
                }
259

    
260
                return null;
261
        }
262

    
263
        /**
264
         * A?ade una tabla al proyecto
265
         *
266
         * @param t
267
         */
268
        public void addTable(ProjectTable t) {
269
                tables.add(t);
270
                t.addPropertyChangeListener(this);
271
                modified = true;
272
                change.firePropertyChange("", null, null);
273
                t.setProject(this, tables.size() - 1);
274
        }
275

    
276
        /**
277
         * Elimina una tabla del proyecto
278
         *
279
         * @param i indice de la tabla
280
         */
281
        public void delTable(int i) {
282
                tables.remove(i);
283
                modified = true;
284
                change.firePropertyChange("", null, null);
285
        }
286

    
287
        /**
288
         * A?ade una vista al proyecto
289
         *
290
         * @param v
291
         */
292
        public void addView(ProjectView v) {
293
                views.add(v);
294
                v.addPropertyChangeListener(this);
295
                modified = true;
296
                change.firePropertyChange("", null, null);
297
                v.setProject(this, views.size() - 1);
298
        }
299

    
300
        /**
301
         * Elimina una tabla del proyecto
302
         *
303
         * @param i indice del proyecto
304
         */
305
        public void delView(int k) {
306
                ProjectView pv=(ProjectView)views.get(k);
307
                FLayers layers=pv.getMapContext().getLayers();
308

    
309
                for (int i = layers.getLayersCount()-1; i>=0; i--){
310
                try {
311
                        if (layers.getLayer(i) instanceof AlphanumericData){
312
                    Project project = ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject();
313
                    ProjectTable pt = project.getTable((AlphanumericData) layers.getLayer(i));
314

    
315
                    ArrayList tables = project.getTables();
316
                    for (int j = 0; j < tables.size(); j++) {
317
                        if (tables.get(j) == pt){
318
                            project.delTable(j);
319
                            break;
320
                        }
321
                    }
322

    
323
                    PluginServices.getMDIManager().closeSingletonWindow(pt);
324
                }
325
                layers.getLayer(i).getParentLayer().removeLayer(layers.getLayer(i));
326
                        } catch (CancelationException e1) {
327
                            e1.printStackTrace();
328
                    }
329
            }
330
                views.remove(k);
331
                modified = true;
332
                change.firePropertyChange("", null, null);
333
        }
334

    
335
        /**
336
         * Devuelve true si el proyecto (o alguna tabla, vista o mapa que contiene)
337
         * fue modificado
338
         *
339
         * @return
340
         */
341
        public boolean isModified() {
342
                if (this.getMaps().size()==0 && this.getViews().size()==0 && this.getTables().size() == 0){
343
                        return false;
344
                }
345
                return true;
346
                ///return modified;    TODO El atributo modified solo detecta cuando se elimina o a?ade una vista,
347
                ///mapa o tabla pero no cuando se modifican.
348
        }
349

    
350
        /**
351
         * Obtiene los comentarios
352
         *
353
         * @return
354
         */
355
        public String getComments() {
356
                return comments;
357
        }
358

    
359
        /**
360
         * Obtiene la fecha de la ?ltima modificaci?n
361
         *
362
         * @return
363
         */
364
        public String getModificationDate() {
365
                return modificationDate;
366
        }
367

    
368
        /**
369
         * Obtiene el propietario del proyecto
370
         *
371
         * @return
372
         */
373
        public String getOwner() {
374
                return owner;
375
        }
376

    
377
        /**
378
         * Establece una cadena como comentarios al proyecto
379
         *
380
         * @param string
381
         */
382
        public void setComments(String string) {
383
                comments = string;
384
                modified = true;
385
                change.firePropertyChange("", null, null);
386
        }
387

    
388
        /**
389
         * Establece la fecha de la ?ltima modificaci?n
390
         *
391
         * @param string
392
         */
393
        public void setModificationDate(String string) {
394
                modificationDate = string;
395
                modified = true;
396
                change.firePropertyChange("", null, null);
397
        }
398

    
399
        /**
400
         * Establece el propietario del proyecto
401
         *
402
         * @param string
403
         */
404
        public void setOwner(String string) {
405
                owner = string;
406
                modified = true;
407
                change.firePropertyChange("", null, null);
408
        }
409

    
410
        /**
411
         * Establece el flag de modificado del proyecto
412
         *
413
         * @param b
414
         */
415
        public void setModified(boolean b) {
416
                modified = b;
417
        }
418

    
419
        /**
420
         * Obtiene el color de selecci?n que se usar? en el proyecto
421
         *
422
         * @return
423
         */
424
        public Color getSelectionColor() {
425
                return selectionColor;
426
        }
427

    
428
        /**
429
         * Establece el color de selecci?n
430
         *
431
         * @param color
432
         */
433
        public void setSelectionColor(Color color) {
434
                selectionColor = color;
435
                FSymbol.setSelectionColor(color);
436
                modified = true;
437
                change.firePropertyChange("selectionColor", null, color);
438
        }
439

    
440
        /**
441
         * Obtiene el color como un entero para su serializaci?n a XML
442
         *
443
         * @return
444
         */
445
        public String getColor() {
446
                return StringUtilities.color2String(selectionColor);
447
        }
448

    
449
        /**
450
         * M?todo invocado al recuperar de XML para establecer el color de
451
         * seleccion del proyecto
452
         *
453
         * @param color Entero que representa un color
454
         */
455
        public void setColor(String color) {
456
                modified = true;
457
                selectionColor = StringUtilities.string2Color(color);
458
        }
459

    
460
        /* (non-Javadoc)
461
         * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
462
         */
463
        public void propertyChange(PropertyChangeEvent evt) {
464
                this.modified = true;
465
                change.firePropertyChange(evt);
466
        }
467

    
468
        /**
469
         * DOCUMENT ME!
470
         *
471
         * @param arg1
472
         */
473
        public void addExtent(ProjectExtent arg1) {
474
                extents.add(arg1);
475
                modified = true;
476
                change.firePropertyChange("addExtent", null, null);
477
        }
478

    
479
        /**
480
         * DOCUMENT ME!
481
         *
482
         * @param arg0
483
         *
484
         * @return
485
         */
486
        public Object removeExtent(int arg0) {
487
                modified = true;
488
                change.firePropertyChange("delExtent", null, null);
489

    
490
                return extents.remove(arg0);
491
        }
492

    
493
        /**
494
         * DOCUMENT ME!
495
         *
496
         * @return DOCUMENT ME!
497
         */
498
        public ProjectExtent[] getExtents() {
499
                return (ProjectExtent[]) extents.toArray(new ProjectExtent[0]);
500
        }
501

    
502
        /**
503
         * DOCUMENT ME!
504
         *
505
         * @param arg0
506
         */
507
        public synchronized void addPropertyChangeListener(
508
                PropertyChangeListener arg0) {
509
                change.addPropertyChangeListener(arg0);
510
        }
511

    
512
        /**
513
         * DOCUMENT ME!
514
         *
515
         * @return
516
         */
517
        public ArrayList getMaps() {
518
                return maps;
519
        }
520

    
521
        /**
522
         * DOCUMENT ME!
523
         *
524
         * @return
525
         */
526
        public ArrayList getTables() {
527
                return tables;
528
        }
529

    
530
        /**
531
         * DOCUMENT ME!
532
         *
533
         * @return
534
         */
535
        public ArrayList getViews() {
536
                return views;
537
        }
538

    
539
        /**
540
         * DOCUMENT ME!
541
         *
542
         * @return DOCUMENT ME!
543
         *
544
         * @throws DriverException
545
         * @throws XMLException
546
         */
547
        public XMLEntity getXMLEntity() throws DriverException, XMLException {
548
                XMLEntity xml = new XMLEntity();
549
                xml.putProperty("className", this.getClass().getName());
550
                xml.putProperty("VERSION", VERSION);
551
                xml.putProperty("comments", comments);
552
                xml.putProperty("creationDate", creationDate);
553

    
554
                int numExtents = extents.size();
555

    
556
                /*double[] xs = new double[size];
557
                   double[] ys = new double[size];
558
                   double[] ws = new double[size];
559
                   double[] hs = new double[size];
560
                 */
561
                xml.putProperty("numExtents", numExtents);
562

    
563
                for (int i = 0; i < numExtents; i++) {
564
                        /*        Rectangle2D rect = (Rectangle2D) extents.get(i);
565
                           xs[i] = rect.getX();
566
                           ys[i] = rect.getY();
567
                           ws[i] = rect.getWidth();
568
                           hs[i] = rect.getHeight();
569
                         */
570
                        xml.addChild(((ProjectExtent) extents.get(i)).getXMLEntity());
571
                }
572

    
573
        // NUEVO: ESTO ESTA EN PRUEBAS. SIRVE PARA
574
        // BORRAR LAS REFERENCIAS A DATASOURCES QUE HEMOS
575
        // BORRADO. Hay que probar a borrarlos cuando se
576
        // borra una tabla y cuando se borra una capa.
577
        cleanBadReferences();
578
                SourceInfo[] infos = LayerFactory.getDataSourceFactory().getDriverInfos();
579
                xml.putProperty("data-source-count", infos.length);
580

    
581
                for (int i = 0; i < infos.length; i++) {
582
                        SourceInfo di = infos[i];
583
                        XMLEntity child = this.getSourceInfoXMLEntity(di);
584
                        xml.addChild(child);
585
                }
586

    
587
                /*
588
                   xml.putProperty("extentsX", xs);
589
                   xml.putProperty("extentsY", ys);
590
                   xml.putProperty("extentsW", ws);
591
                   xml.putProperty("extentsH", hs);
592
                 */
593

    
594
                int numViews=0;
595
                for (int i = 0; i < views.size(); i++) {
596
                        try {
597
                                XMLEntity xmlchild=((ProjectView) views.get(i)).getXMLEntity();
598
                                xml.addChild(xmlchild);
599
                                numViews++;
600
                        } catch (SaveException e) {
601
                                e.showError();
602
                        }
603
                }
604
                xml.putProperty("numViews", numViews);
605

    
606
                int numMaps=0;
607
                for (int i = 0; i < maps.size(); i++) {
608
                        try {
609
                                XMLEntity xmlchild=((ProjectMap) maps.get(i)).getXMLEntity();
610
                                xml.addChild(xmlchild);
611
                                numMaps++;
612
                        } catch (SaveException e) {
613
                                e.showError();
614
                        }
615
                }
616
                xml.putProperty("numMaps", numMaps);
617
                xml.putProperty("modificationDate", modificationDate);
618
                xml.putProperty("modified", modified);
619
                xml.putProperty("name", name);
620
                xml.putProperty("owner", owner);
621
                //xml.putProperty("path", path);
622
                xml.putProperty("selectionColor",
623
                        StringUtilities.color2String(selectionColor));
624

    
625
                int numTables=0;
626
                for (int i = 0; i < tables.size(); i++) {
627
                        try {
628
                                XMLEntity xmlchild=((ProjectTable) tables.get(i)).getXMLEntity();
629
                                xml.addChild(xmlchild);
630
                                numTables++;
631
                        } catch (SaveException e) {
632

    
633
                                e.showError();
634
                        }
635
                }
636
                xml.putProperty("numTables", numTables);
637
                xml.putProperty("projection", defaultProjection.getAbrev());
638

    
639
                // save the properties of the Project Manager window
640
                IWindow []andamiViews = PluginServices.getMDIManager().getAllWindows();
641
                for (int i=0; i<andamiViews.length; i++) {
642
                        if (andamiViews[i] instanceof ProjectWindow) {
643
                                ProjectWindow pw = (ProjectWindow) andamiViews[i];
644
                                try {
645
                                        XMLEntity xmlchild = null;
646
                                        xmlchild = getWindowInfoXMLEntity(pw);
647
                                        if (xmlchild!=null) {
648
                                                xml.addChild(xmlchild);
649
                                        }
650
                                }
651
                                catch (SaveException e){
652
                                        e.showError();
653
                                }
654
                        }
655
                }
656

    
657
                return xml;
658
        }
659
        /**
660
         * DOCUMENT ME!
661
         *
662
         * @param xml DOCUMENT ME!
663
         *
664
         * @return DOCUMENT ME!
665
         * @throws XMLException
666
         * @throws DriverException
667
         * @throws DriverIOException
668
         * @throws OpenException
669
         */
670
        public static Project createFromXML03(XMLEntity xml)
671
                throws OpenException {
672
                Project p = new Project();
673
                try{
674
                p.comments = xml.getStringProperty("comments");
675
                p.creationDate = xml.getStringProperty("creationDate");
676
/*
677
                double[] xs = xml.getDoubleArrayProperty("extentsX");
678
                double[] ys = xml.getDoubleArrayProperty("extentsY");
679
                double[] ws = xml.getDoubleArrayProperty("extentsW");
680
                double[] hs = xml.getDoubleArrayProperty("extentsH");
681
*/
682
                int numExtents=xml.getIntProperty("numExtents");
683
                for (int i = 0; i < numExtents; i++) {
684
                        ProjectExtent pe=ProjectExtent.createFromXML03(xml.getChild(i));
685
                        p.extents.add(pe);
686
                }
687

    
688
                int numViews = xml.getIntProperty("numViews");
689

    
690
                for (int i = numExtents; i < numViews+numExtents; i++) {
691
                        p.views.add(ProjectView.createFromXML03(xml.getChild(i), p));
692
                }
693

    
694
                int numMaps = xml.getIntProperty("numMaps");
695

    
696
                for (int i = numViews+numExtents; i < (numMaps + numViews+numExtents); i++) {
697
                        p.maps.add(ProjectMap.createFromXML03(xml.getChild(i), p));
698
                }
699
                p.modificationDate = xml.getStringProperty("modificationDate");
700
                p.modified = xml.getBooleanProperty("modified");
701
                p.name = xml.getStringProperty("name");
702
                p.owner = xml.getStringProperty("owner");
703
//                p.path = xml.getStringProperty("path");
704
                p.selectionColor = StringUtilities.string2Color(xml.getStringProperty(
705
                                        "selectionColor"));
706

    
707
                int numTables = xml.getIntProperty("numTables");
708

    
709
                for (int i = numExtents+numMaps + numViews; i < (numExtents+numTables + numMaps + numViews);
710
                                i++) {
711
                        p.tables.add(ProjectTable.createFromXML03(xml.getChild(i), p));
712
                }
713
                String strProj = xml.getStringProperty("projection");
714
                if (strProj != null)
715
                        p.setProjection(ProjectionPool.get(strProj));
716
                }catch (Exception e) {
717
                        throw new OpenException(e,p.getClass().getName());
718
                }
719
                return p;
720
        }
721

    
722
        /**
723
         * DOCUMENT ME!
724
         *
725
         * @param xml DOCUMENT ME!
726
         *
727
         * @return DOCUMENT ME!
728
         *
729
         * @throws XMLException
730
         * @throws DriverException
731
         * @throws DriverIOException
732
         * @throws OpenException
733
         * @throws VersionException
734
         */
735
        public static Project createFromXML(XMLEntity xml)
736
                throws OpenException {
737

    
738
                int childNumber = 0;
739
                Project p = new Project();
740
                try{
741
                p.comments = xml.getStringProperty("comments");
742
                p.creationDate = xml.getStringProperty("creationDate");
743

    
744
                /*
745
                   double[] xs = xml.getDoubleArrayProperty("extentsX");
746
                   double[] ys = xml.getDoubleArrayProperty("extentsY");
747
                   double[] ws = xml.getDoubleArrayProperty("extentsW");
748
                   double[] hs = xml.getDoubleArrayProperty("extentsH");
749
                 */
750
                int numExtents = xml.getIntProperty("numExtents");
751

    
752
                for (int i = 0; i < numExtents; i++) {
753
                        ProjectExtent pe = ProjectExtent.createFromXML(xml.getChild(i));
754
                        p.extents.add(pe);
755
                }
756

    
757
                childNumber = numExtents;
758

    
759
                int numDataSources = xml.getIntProperty("data-source-count");
760

    
761
                for (int i = childNumber; i < (childNumber + numDataSources); i++) {
762
                        XMLEntity child = xml.getChild(i);
763

    
764
                        if (child.getStringProperty("type").equals("otherDriverFile")) {
765
                                LayerFactory.getDataSourceFactory().addFileDataSource(child.getStringProperty(
766
                                                "driverName"), child.getStringProperty("gdbmsname"),
767
                                        child.getStringProperty("file"));
768
                        } else if (child.getStringProperty("type").equals("sameDriverFile")) {
769
                                /*                                String layerName = child.getStringProperty("layerName");
770
                                   ProjectView vista = project.getViewByName(child.getStringProperty(
771
                                   "viewName"));
772
                                   FLayer layer = vista.getMapContext().getLayers().getLayer(layerName);
773

774
                                   modelo = ((AlphanumericData) layer).getRecordset();
775
                                   associatedTable = (AlphanumericData) layer;
776
                                 */
777
                        } else if (child.getStringProperty("type").equals("db")) {
778
                                LayerFactory.getDataSourceFactory().addDBDataSourceByTable(child.getStringProperty(
779
                                                "gdbmsname"), child.getStringProperty("host"),
780
                                        child.getIntProperty("port"),
781
                                        child.getStringProperty("user"),
782
                                        child.getStringProperty("password"),
783
                                        child.getStringProperty("dbName"),
784
                                        child.getStringProperty("tableName"),
785
                                        child.getStringProperty("driverInfo"));
786
                        }
787
                }
788

    
789
                childNumber += numDataSources;
790

    
791
                int numViews = xml.getIntProperty("numViews");
792

    
793
                for (int i = childNumber; i < (numViews + childNumber); i++) {
794
                        try{
795
                                ProjectView pv = (ProjectView) ProjectView.createFromXML(xml.getChild(i), p);
796
                                p.addView(pv);
797
                                if (pv.getSeedViewInfo()!=null) { // open the view, if it was open, and restore its dimensions
798
                                        com.iver.cit.gvsig.gui.View vista = new com.iver.cit.gvsig.gui.View();
799
                                        vista.setModel(pv);
800
                                        PluginServices.getMDIManager().addWindow(vista);
801
                                        PluginServices.getMDIManager().changeWindowInfo(vista, pv.getSeedViewInfo());
802
                                }
803
                        }catch(OpenException e){
804
                                e.showError();
805
                        }
806
                }
807

    
808
                childNumber += numViews;
809

    
810
                int numMaps = xml.getIntProperty("numMaps");
811

    
812
                for (int i = childNumber; i < (numMaps + childNumber); i++) {
813
                        try{
814
                                // p.maps.add(ProjectMap.createFromXML(xml.getChild(i), p));
815
                                ProjectMap map = (ProjectMap) ProjectMap.createFromXML(xml.getChild(i), p);
816
                                p.maps.add(map);
817
                                if (map.getSeedViewInfo()!=null) { // open the view, if it was open, and restore its dimensions
818
                                        map.getModel().setProjectMap(map);
819
                                        PluginServices.getMDIManager().addWindow(map.getModel());
820
                                        PluginServices.getMDIManager().changeWindowInfo(map.getModel(), map.getSeedViewInfo());
821
                                }
822
                        }catch(OpenException e){
823
                                e.showError();
824
                        }
825
                }
826

    
827
                childNumber += numMaps;
828
                p.modificationDate = xml.getStringProperty("modificationDate");
829
                p.modified = xml.getBooleanProperty("modified");
830
                p.name = xml.getStringProperty("name");
831
                p.owner = xml.getStringProperty("owner");
832
//                p.path = xml.getStringProperty("path");
833
                p.selectionColor = StringUtilities.string2Color(xml.getStringProperty(
834
                                        "selectionColor"));
835

    
836
                int numTables = xml.getIntProperty("numTables");
837

    
838
                for (int i = childNumber; i < (childNumber + numTables); i++) {
839
                        try{
840
                                ProjectTable ptable = (ProjectTable) ProjectTable.createFromXML(xml.getChild(i), p);
841
                                p.tables.add(ptable);
842
                                if (ptable.getSeedViewInfo()!=null && ptable.getAndamiView()!=null) { // open the view, if it was open, and restore its dimensions
843
                                        PluginServices.getMDIManager().addWindow(ptable.getAndamiView());
844
                                        PluginServices.getMDIManager().changeWindowInfo(ptable.getAndamiView(), ptable.getSeedViewInfo());
845
                                }
846
                        }catch(OpenException e){
847
                                e.showError();
848
                        }
849
                }
850

    
851

    
852
                /* The project window defines its own size!!
853
                childNumber += numTables;
854
                if (childNumber < xml.getNumChild()) { // restore the position of the project manager window
855
                        XMLEntity child = xml.getChild(childNumber);
856
                        if (child.contains("className")
857
                                        && child.getStringProperty("className").equals("com.iver.cit.gvsig.project.Project")
858
                                        && child.contains("name")
859
                                        && child.getStringProperty("name").equals("ViewInfoProperties")) {
860
                                seedProjectWindow = Project.createViewInfoFromXMLEntity(xml.getChild(childNumber));
861
                        }
862
                }
863
                 */
864

    
865
                p.setLinkTable();
866

    
867
                String strProj = xml.getStringProperty("projection");
868

    
869
                if (strProj != null) {
870
                        p.setProjection(ProjectionPool.get(strProj));
871
                }
872
        PostProcessSupport.executeCalls();
873
                }catch (Exception e) {
874
                        throw new OpenException(e,p.getClass().getName());
875
                }
876
//                p.setSignature( p.hashCode());
877
                return p;
878

    
879
        }
880

    
881
//        private void setSignature(int signature) {
882
//                this.signatureAtStartup = computeSignature();
883
//        }
884

    
885
        /**
886
         * Reestablece los link que ten?a cada tabla con las dem?s.
887
         */
888
        public void setLinkTable() {
889
                ArrayList tables = getTables();
890

    
891
                for (int i = 0; i < tables.size(); i++) {
892
                        for (int j = 0; j < tables.size(); j++) {
893
                                /*System.out.println("name = " +
894
                                        ((ProjectTable) tables.get(j)).getModelo().getName());
895
                                System.out.println("linktable = " +
896
                                        ((ProjectTable) tables.get(i)).getLinkTable());
897
*/
898
                                try {
899
                                if ((((ProjectTable) tables.get(i)).getLinkTable() != null) &&
900
                                                ((ProjectTable) tables.get(i)).getLinkTable().equals(((ProjectTable) tables
901
                                                                                                                                                                  .get(
902
                                                                j)).getModelo().getRecordset().getName())) {
903
                                        LinkSelectionListener lsl;
904

    
905
                                                lsl = new LinkSelectionListener((SelectableDataSource)((ProjectTable) tables.get(
906
                                                                        i)).getModelo().getRecordset(),
907
                                                                        (SelectableDataSource)((ProjectTable) tables.get(j)).getModelo().getRecordset(),
908
                                                                ((ProjectTable) tables.get(i)).getField1(),
909
                                                                ((ProjectTable) tables.get(i)).getField2());
910

    
911
                                                ((SelectableDataSource)((ProjectTable) tables.get(i)).getModelo().getRecordset())
912
                                         .addSelectionListener(lsl);
913

    
914
                                }
915
                                } catch (DriverLoadException e) {
916
                                        // TODO Auto-generated catch block
917
                                        e.printStackTrace();
918
                                }
919
                        }
920
                }
921
        }
922

    
923
        /**
924
         * Obtiene la vista que contiene a la capa que se pasa como par?metro
925
         *
926
         * @param layer Capa cuya vista se quiere obtener
927
         *
928
         * @return
929
         *
930
         * @throws RuntimeException Si la capa que se pasa como par?metro no se
931
         *                    encuentra en ninguna vista
932
         */
933
        public String getView(FLayer layer) {
934
                for (int v = 0; v < views.size(); v++) {
935
                        ProjectView pView = (ProjectView) views.get(v);
936
                        FLayers layers = pView.getMapContext().getLayers();
937
                        if (isView(layers,layer))return pView.getName();
938
                }
939

    
940
                throw new RuntimeException("The layer is not in a view");
941
        }
942

    
943
        public boolean isView(FLayers layers, FLayer layer) {
944
                for (int i = 0; i < layers.getLayersCount(); i++) {
945
                        if (layers.getLayer(i) instanceof FLayers){
946
                                return isView((FLayers)layers.getLayer(i),layer);
947
                        }else{
948
                                if (layers.getLayer(i) == layer) {
949
                                        return true;
950
                                }
951
                        }
952
                }
953
                return false;
954
        }
955

    
956
        /**
957
         * Devuelve la vista cuyo nombre coincide (sensible a mayusculas) con el
958
         * que se pasa como par?metro. Devuelve null si no hay ninguna vista con
959
         * ese nombre
960
         *
961
         * @param viewName Nombre de la vista que se quiere obtener
962
         *
963
         * @return DOCUMENT ME!
964
         */
965
        public ProjectView getViewByName(String viewName) {
966
                Object o = getProjectElementByName(viewName, views);
967

    
968
                if (o == null) {
969
                        return null;
970
                }
971

    
972
                return (ProjectView) o;
973
        }
974

    
975
        /**
976
         * DOCUMENT ME!
977
         *
978
         * @return DOCUMENT ME!
979
         */
980
        public IProjection getProjection() {
981
                if (projection == null)
982
                        projection = Project.defaultProjection;
983
                return projection;
984
        }
985

    
986
        /**
987
         * DOCUMENT ME!
988
         *
989
         * @param defaultProjection DOCUMENT ME!
990
         */
991
        public void setProjection(IProjection projection) {
992
                this.projection = projection;
993
        }
994

    
995

    
996
        /**
997
         * Sets the projection used when no projection is defined
998
         * @param defaultProjection DOCUMENT ME!
999
         */
1000
        public static void setDefaultProjection(IProjection defaultProjection) {
1001
                Project.defaultProjection = defaultProjection;
1002
        }
1003

    
1004
        public static IProjection getDefaultProjection() {
1005
                return Project.defaultProjection;
1006
        }
1007

    
1008
        /**
1009
         * DOCUMENT ME!
1010
         *
1011
         * @param name DOCUMENT ME!
1012
         * @param l DOCUMENT ME!
1013
         *
1014
         * @return DOCUMENT ME!
1015
         */
1016
        private Object getProjectElementByName(String name, ArrayList l) {
1017
                for (Iterator iter = l.iterator(); iter.hasNext();) {
1018
                        ProjectElement elem = (ProjectElement) iter.next();
1019

    
1020
                        if (elem.getName().equals(name)) {
1021
                                return elem;
1022
                        }
1023
                }
1024

    
1025
                return null;
1026
        }
1027

    
1028
        /**
1029
         * DOCUMENT ME!
1030
         *
1031
         * @param name
1032
         *
1033
         * @return
1034
         */
1035
        public ProjectTable getTableByName(String name) {
1036
                Object o = getProjectElementByName(name, tables);
1037

    
1038
                if (o == null) {
1039
                        return null;
1040
                }
1041

    
1042
                return (ProjectTable) o;
1043
        }
1044

    
1045
        /**
1046
         * DOCUMENT ME!
1047
         *
1048
         * @param name
1049
         *
1050
         * @return
1051
         */
1052
        public ProjectMap getLayoutByName(String name) {
1053
                Object o = getProjectElementByName(name, maps);
1054

    
1055
                if (o == null) {
1056
                        return null;
1057
                }
1058

    
1059
                return (ProjectMap) o;
1060
        }
1061

    
1062
    public SelectableDataSource getDataSourceByLayer(FLayer layer) throws DriverException {
1063
        ArrayList tables = getTables();
1064
        SelectableDataSource dataSource = null;
1065
        try {
1066
        for (int i = 0; i < tables.size(); i++) {
1067
            ProjectTable pt = (ProjectTable) tables.get(i);
1068
            if (pt.getOriginal() == ((AlphanumericData) layer).getRecordset()){
1069
                dataSource = (SelectableDataSource)pt.getModelo().getRecordset();
1070
                break;
1071
            }else if (pt.getModelo() == ((AlphanumericData) layer).getRecordset()){
1072

    
1073
                                        dataSource = (SelectableDataSource)pt.getModelo().getRecordset();
1074

    
1075
                break;
1076
            }
1077
        }
1078
        } catch (DriverLoadException e) {
1079
                        // TODO Auto-generated catch block
1080
                        e.printStackTrace();
1081
                }
1082

    
1083
        if (dataSource == null){
1084
            //No se ha creado la tabla asociada al tema
1085
            dataSource = ((AlphanumericData) layer).getRecordset();
1086
        }
1087

    
1088
        return dataSource;
1089

    
1090
    }
1091

    
1092
    /**
1093
     * Recorremos las capas y las tablas del proyecto, y creamos una lista
1094
     * con todos los datasources de GDBMS que estamos usando.
1095
     * Luego recorremos los que est?n registrados, y borramos
1096
     * aquellos que no est?n siendo usados, es decir, aquellos
1097
     * que no est?n en nuestra lista (un Hash con clave el nombre
1098
     * del GDBMS)
1099
     *
1100
     */
1101
    private void cleanBadReferences()
1102
    {
1103
        Hashtable usedDataSources = new Hashtable();
1104
        // Primero las tablas
1105
        int i, j;
1106
        try {
1107
        for (i=0; i<tables.size(); i++)
1108
        {
1109
            ProjectTable t = (ProjectTable) tables.get(i);
1110
            SelectableDataSource ds;
1111

    
1112
                                ds = (SelectableDataSource)t.getModelo().getRecordset();
1113

    
1114
            if (t.getOriginal() != null)
1115
                usedDataSources.put(t.getOriginal().getRecordset().getName(), t.getOriginal());
1116
            usedDataSources.put(ds.getName(), ds);
1117
        }
1118
        } catch (DriverLoadException e) {
1119
                        // TODO Auto-generated catch block
1120
                        e.printStackTrace();
1121
                }
1122
        // Ahora las vistas
1123
        try {
1124
            for (i=0; i<views.size(); i++)
1125
            {
1126
                ProjectView pv = (ProjectView) views.get(i);
1127

    
1128
                FLayers lyrs = pv.getMapContext().getLayers();
1129

    
1130
                for (j=0; j<lyrs.getLayersCount(); j++)
1131
                {
1132
                    FLayer lyr = lyrs.getLayer(j);
1133
                    if (lyr instanceof FLyrVect)
1134
                    {
1135
                        FLyrVect lyrVect = (FLyrVect) lyr;
1136
                        if (lyrVect.isAvailable())
1137
                                usedDataSources.put(lyrVect.getRecordset().getName(), lyrVect.getSource().getRecordset());
1138
                    }
1139
                }
1140
                MapContext aux = pv.getMapOverViewContext();
1141
                if (aux != null)
1142
                {
1143
                    FLayers lyrsOverview = aux.getLayers();
1144
                    for (j=0; j<lyrsOverview.getLayersCount(); j++)
1145
                    {
1146
                        FLayer lyr = lyrsOverview.getLayer(j);
1147
                        if (lyr instanceof FLyrVect)
1148
                        {
1149
                            FLyrVect lyrVect = (FLyrVect) lyr;
1150
                            usedDataSources.put(lyrVect.getSource().getRecordset().getName(), lyrVect.getSource().getRecordset());
1151
                        }
1152
                    }
1153
                }
1154

    
1155
            } // for i
1156
        } catch (DriverLoadException e) {
1157
                        // TODO Auto-generated catch block
1158
                        e.printStackTrace();
1159
                } catch (DriverException e) {
1160
                        // TODO Auto-generated catch block
1161
                        e.printStackTrace();
1162
                }
1163
        // Recorremos los dataSources y los borramos si no
1164
        // los estamos usando.
1165
        SourceInfo[] infos = LayerFactory.getDataSourceFactory().getDriverInfos();
1166
        try {
1167
            for (i=0; i < infos.length; i++)
1168
            {
1169
                if (!usedDataSources.containsKey(infos[i].name))
1170
                {
1171
                    DataSource ds;
1172
                    ds = LayerFactory.getDataSourceFactory().createRandomDataSource(infos[i].name);
1173
                    ds.remove();
1174
                }
1175
            }
1176
        } catch (DriverLoadException e) {
1177
            // TODO Auto-generated catch block
1178
            e.printStackTrace();
1179
        } catch (NoSuchTableException e) {
1180
            // TODO Auto-generated catch block
1181
            e.printStackTrace();
1182
        } catch (com.hardcode.gdbms.engine.data.driver.DriverException e) {
1183
            // TODO Auto-generated catch block
1184
            e.printStackTrace();
1185
        }
1186
    }
1187

    
1188
    /**
1189
         * DOCUMENT ME!
1190
         *
1191
         * @return DOCUMENT ME!
1192
     * @throws SaveException
1193
         * @throws XMLException
1194
         * @throws SaveException
1195
         */
1196
        public XMLEntity getWindowInfoXMLEntity(IWindow window) throws SaveException {
1197
                if (window!=null && PluginServices.getMDIManager().getWindowInfo(window)!=null) {
1198
                        WindowInfo vi = PluginServices.getMDIManager().getWindowInfo(window);
1199
                        XMLEntity xml = new XMLEntity();
1200
                        //xml.putProperty("nameClass", this.getClass().getName());
1201
                        try{
1202
                                xml.setName("ViewInfoProperties");
1203
                                xml.putProperty("className", this.getClass().getName());
1204
                                xml.putProperty("X", vi.getX());
1205
                                xml.putProperty("Y", vi.getY());
1206
                                xml.putProperty("Width", vi.getWidth());
1207
                                xml.putProperty("Height", vi.getHeight());
1208
                                xml.putProperty("isVisible", vi.isVisible());
1209
                                xml.putProperty("isResizable", vi.isResizable());
1210
                                xml.putProperty("isMaximizable", vi.isMaximizable());
1211
                                xml.putProperty("isModal", vi.isModal());
1212
                                xml.putProperty("isModeless", vi.isModeless());
1213
                                xml.putProperty("isClosed", vi.isClosed());
1214
                                if (vi.isMaximized()==true) {
1215
                                        xml.putProperty("isMaximized", vi.isMaximized());
1216
                                        xml.putProperty("normalX", vi.getNormalX());
1217
                                        xml.putProperty("normalY", vi.getNormalY());
1218
                                        xml.putProperty("normalWidth", vi.getNormalWidth());
1219
                                        xml.putProperty("normalHeight", vi.getNormalHeight());
1220
                                }
1221
                        }catch (Exception e) {
1222
                                throw new SaveException(e,this.getClass().getName());
1223
                        }
1224
                        return xml;
1225
                }
1226
                else
1227
                        return null;
1228
        }
1229

    
1230
        public static WindowInfo createWindowInfoFromXMLEntity(XMLEntity xml)
1231
        {
1232
                WindowInfo result = new WindowInfo();
1233
                result.setX(xml.getIntProperty("X"));
1234
                result.setY(xml.getIntProperty("Y"));
1235
                result.setHeight(xml.getIntProperty("Height"));
1236
                result.setWidth(xml.getIntProperty("Width"));
1237
                result.setClosed(xml.getBooleanProperty("isClosed"));
1238
                if (xml.contains("isMaximized")) {
1239
                        boolean maximized = xml.getBooleanProperty("isMaximized");
1240
                        result.setMaximized(maximized);
1241
                        if (maximized==true) {
1242
                                result.setNormalBounds(xml.getIntProperty("normalX"), xml.getIntProperty("normalY"), xml.getIntProperty("normalWidth"), xml.getIntProperty("normalHeight"));
1243
                        }
1244
                        else {
1245
                                result.setNormalBounds(result.getBounds());
1246
                        }
1247
                }
1248

    
1249
                return result;
1250
        }
1251

    
1252
        public static WindowInfo getSeedProjectWindow() {
1253
                return seedProjectWindow;
1254
        }
1255

    
1256
        public XMLEntity getSourceInfoXMLEntity(SourceInfo di) {
1257
                XMLEntity child = new XMLEntity();
1258

    
1259

    
1260
                if (di instanceof ObjectSourceInfo) {
1261
                        ObjectSourceInfo driver = (ObjectSourceInfo) di;
1262
                        child.putProperty("type", "sameDriverFile");
1263
                        child.putProperty("gdbmsname", driver.name);
1264
                } else if (di instanceof FileSourceInfo) {
1265
                        FileSourceInfo vfdi = (FileSourceInfo) di;
1266
                        child.putProperty("type", "otherDriverFile");
1267
                        child.putProperty("gdbmsname", vfdi.name);
1268
                        child.putProperty("file", vfdi.file);
1269
                        child.putProperty("driverName", vfdi.driverName);
1270
                } else if (di instanceof DBSourceInfo) {
1271
                        DBTableSourceInfo dbdi = (DBTableSourceInfo) di;
1272
                        child.putProperty("type", "db");
1273
                        child.putProperty("gdbmsname", dbdi.name);
1274
                        child.putProperty("dbms", dbdi.dbms);
1275
                        child.putProperty("host", dbdi.host);
1276
                        child.putProperty("port", dbdi.port);
1277
                        child.putProperty("user", dbdi.user);
1278
                        child.putProperty("password", dbdi.password);
1279
                        child.putProperty("dbName", dbdi.dbName);
1280
                        child.putProperty("tableName", dbdi.tableName);
1281
                        child.putProperty("driverInfo", dbdi.driverName);
1282
                }
1283

    
1284
                return child;
1285
        }
1286

    
1287

    
1288

    
1289
//        public boolean hasChanged() {
1290
//                return signatureAtStartup != computeSignature();
1291
//        }
1292

    
1293
//        public int computeSignature() {
1294
//
1295
////                /* TODO method also present in ProjectMap, ProjectTable,
1296
////                 *  ProjectView and ProjectExtent
1297
////                 */
1298
//                int result = 17;
1299
////
1300
////                Class clazz = getClass();
1301
////                Field[] fields = clazz.getDeclaredFields();
1302
////                for (int i = 0; i < fields.length; i++) {
1303
////                        try {
1304
////                                // don't compute following fields
1305
////                                if (fields[i].getName().equals("modificationDate")
1306
////                                                || fields[i].getName().equals("creationDate")
1307
////                                                || fields[i].getName().equals("signatureAtStartup")
1308
////                                                || fields[i].getName().equals("change")
1309
////                                                || Modifier.isStatic(fields[i].getModifiers()))
1310
////                                        continue;
1311
////
1312
////
1313
////                                String type = fields[i].getType().getName();
1314
////                                if (type.equals("boolean")) {
1315
////                                        result += 37 + ((fields[i].getBoolean(this)) ? 1 : 0);
1316
////                                } else if (type.equals("java.lang.String")) {
1317
////                                        Object v = fields[i].get(this);
1318
////                                        if (v == null) {
1319
////                                                result += 37;
1320
////                                                continue;
1321
////                                        }
1322
////                                        char[] chars = ((String) v).toCharArray();
1323
////                                        for (int j = 0; j < chars.length; j++) {
1324
////                                                result += 37 + (int) chars[i];
1325
////                                        }
1326
////                                } else if (type.equals("byte")) {
1327
////                                        result += 37 + (int) fields[i].getByte(this);
1328
////                                } else if (type.equals("char")) {
1329
////                                        result += 37 + (int) fields[i].getChar(this);
1330
////                                } else if (type.equals("short")) {
1331
////                                        result += 37 + (int) fields[i].getShort(this);
1332
////                                } else if (type.equals("int")) {
1333
////                                        result += 37 + fields[i].getInt(this);
1334
////                                } else if (type.equals("long")) {
1335
////                                        long f = fields[i].getLong(this) ;
1336
////                                        result += 37 + (f ^ (f >>> 32));
1337
////                                } else if (type.equals("float")) {
1338
////                                        result += 37 + Float.floatToIntBits(fields[i].getFloat(this));
1339
////                                } else if (type.equals("double")) {
1340
////                                        long f = Double.doubleToLongBits(fields[i].getDouble(this));
1341
////                                        result += 37 + (f ^ (f >>> 32));
1342
////                                } else {
1343
//////                                        Object obj = fields[i].get(this);
1344
//////                                        result += 37 + ((obj != null)? obj.hashCode() : 0);
1345
////                                }
1346
////                        } catch (Exception e) { e.printStackTrace(); }
1347
////
1348
////                }
1349
////
1350
////                for (int i = 0; i < views.size(); i++) {
1351
////                        ProjectView e = (ProjectView) views.get(i);
1352
////                        result += 37 + e.computeSignature();
1353
////                }
1354
////
1355
////                for (int i = 0; i < tables.size(); i++) {
1356
////                        ProjectTable e = (ProjectTable) tables.get(i);
1357
////                        result += 37 + e.computeSignature();
1358
////                }
1359
////
1360
////                for (int i = 0; i < maps.size(); i++) {
1361
////                        ProjectMap e = (ProjectMap) maps.get(i);
1362
////                        result += 37 + e.computeSignature();
1363
////                }
1364
////
1365
////                for (int i = 0; i < extents.size(); i++) {
1366
////                        ProjectExtent e = (ProjectExtent) extents.get(i);
1367
////                        result += 37 + e.computeSignature();
1368
////                }
1369
//
1370
//
1371
//                return result;
1372
//        }
1373

    
1374
}