Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / table / ProjectTable.java @ 24759

History | View | Annotate | Download (21.9 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.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
}