Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / project / document / table / FeatureTableDocument.java @ 25068

History | View | Annotate | Download (5.21 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Gobernment (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 {DiSiD Technologies}  {TableDocument implementation based on the gvSIG DAL API}
26
 */
27
package org.gvsig.project.document.table;
28

    
29
import org.gvsig.fmap.dal.exception.DataException;
30
import org.gvsig.fmap.dal.feature.FeatureQuery;
31
import org.gvsig.fmap.dal.feature.FeatureStore;
32
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
33
import org.gvsig.project.document.table.gui.FeatureTableDocumentPanel;
34

    
35
import com.iver.andami.ui.mdiManager.IWindow;
36
import com.iver.cit.gvsig.project.Project;
37
import com.iver.cit.gvsig.project.documents.ProjectDocument;
38
import com.iver.cit.gvsig.project.documents.exceptions.OpenException;
39
import com.iver.cit.gvsig.project.documents.exceptions.SaveException;
40
import com.iver.utiles.XMLEntity;
41
import com.iver.utiles.XMLException;
42

    
43
/**
44
 * @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
45
 */
46
public class FeatureTableDocument extends ProjectDocument {
47

    
48
    private static final long serialVersionUID = -1842181135614158881L;
49

    
50
    private FeatureQuery query;
51

    
52
    private FeatureStore store;
53

    
54
    private String linkTable;
55

    
56
        private String field1;
57

    
58
        private String field2;
59

    
60
        private LinkSelectionObserver linkSelectionObserver;
61

    
62
        private FLyrVect associatedTable;
63

    
64

    
65
    public FeatureTableDocument(FeatureStore store) {
66
        this(store, null);
67
    }
68

    
69
    public FeatureTableDocument(FeatureStore store, FeatureQuery query) {
70
        this.store = store;
71
        this.query = query;
72
    }
73

    
74
    @Override
75
    public void afterAdd() {
76
        // Nothing to do
77
    }
78

    
79
    @Override
80
    public void afterRemove() {
81
        // Nothing to do
82
    }
83

    
84
    @Override
85
    public IWindow createWindow() {
86
        try {
87
            return new FeatureTableDocumentPanel(getStore(), getQuery());
88
        } catch (DataException e) {
89
            // TODO ?QU? SE HACE EN ESTOS CASOS?
90
            e.printStackTrace();
91
        }
92

    
93
        return null;
94
    }
95

    
96
    @Override
97
    public void exportToXML(XMLEntity root, Project project)
98
            throws SaveException {
99
        // TODO Auto-generated method stub
100

    
101
    }
102

    
103
    @Override
104
    public IWindow getProperties() {
105
        // TODO Auto-generated method stub
106
        return null;
107
    }
108

    
109
    /**
110
     * @return the query
111
     */
112
    public FeatureQuery getQuery() {
113
        return query;
114
    }
115

    
116
    /**
117
     * @return the store
118
     */
119
    public FeatureStore getStore() {
120
        return store;
121
    }
122

    
123
        @Override
124
        public void importFromXML(XMLEntity root, XMLEntity typeRoot,
125
                        int elementIndex, Project project, boolean removeDocumentsFromRoot)
126
                        throws XMLException, OpenException,
127
                        org.gvsig.fmap.dal.exception.ReadException {
128
                // TODO Auto-generated method stub
129

    
130
        }
131

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

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

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

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

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

    
191
        }
192

    
193
        public FLyrVect getAssociatedLayer() {
194
                return associatedTable;
195
        }
196

    
197
        /**
198
         * DOCUMENT ME!
199
         *
200
         * @param associatedTable
201
         *            DOCUMENT ME!
202
         */
203
        public void setAssociatedLayer(FLyrVect associatedTable) {
204
                this.associatedTable = associatedTable;
205
        }
206

    
207
        public void setStore(FeatureStore fs) {
208
                this.store=fs;
209
        }
210
}