Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extGeoDB / src / org / gvsig / geodb / vectorialdb / wizard / TablesListItemVectorial.java @ 38608

History | View | Annotate | Download (3.79 KB)

1 29199 jmvivo
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (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
* 2009 IVER T.I   {{Task}}
26
*/
27
28 29628 jpiera
package org.gvsig.geodb.vectorialdb.wizard;
29 29199 jmvivo
30
import java.util.ArrayList;
31
import java.util.Iterator;
32
33 29628 jpiera
import org.gvsig.andami.messages.NotificationManager;
34 29199 jmvivo
import org.gvsig.fmap.dal.DataTypes;
35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor;
37
import org.gvsig.fmap.dal.feature.FeatureType;
38
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorer;
39
import org.gvsig.fmap.dal.store.db.DBStoreParameters;
40
import org.gvsig.fmap.mapcontrol.MapControl;
41
42
43
public class TablesListItemVectorial extends TablesListItem {
44
        private MapControl mc;
45
46
47
        public TablesListItemVectorial(DBServerExplorer explorer,
48
                        DBStoreParameters param,
49
                        MapControl _mc, WizardVectorialDB _parent) {
50
                super(explorer, param, _parent);
51
                mc = _mc;
52
        }
53
54
    public UserTableSettingsPanel getUserTableSettingsPanel(String espView) {
55
                if (tableSettingsPanel == null) {
56
57
                        String[] ids = new String[0];
58
                        FeatureType ft = null;
59
60
                        try {
61
                                ft = explorer.getFeatureType(parameters);
62
                        } catch (DataException e) {
63
                                NotificationManager.addError(e);
64
                                return null;
65
                        }
66
67
                        ArrayList auxAll = new ArrayList();
68
                        String[] geos = new String[0];
69
                        ArrayList auxGeo = new ArrayList();
70
                        ArrayList auxId = new ArrayList();
71
                        Iterator iter = ft.iterator();
72
                        while (iter.hasNext()) {
73
                                FeatureAttributeDescriptor dbattr = (FeatureAttributeDescriptor) iter
74
                                                .next();
75 33331 jjdelcerro
                                if (dbattr.getDataType().getType() == DataTypes.GEOMETRY) {
76 29199 jmvivo
                                        auxGeo.add(dbattr.getName());
77
                                }
78
                                if (dbattr.isPrimaryKey()) {
79
                                        auxId.add(dbattr.getName());
80
                                }
81
                                auxAll.add(dbattr.getName());
82
83
                        }
84
85
                        geos = (String[]) auxGeo.toArray(new String[0]);
86
                        if (auxId.size() > 0) {
87
                                StringBuilder strb = new StringBuilder();
88
                                strb.append('{');
89
                                for (int i = 0; i < auxId.size() - 1; i++) {
90 37547 jpiera
                                        strb.append(auxId.get(i));
91 29199 jmvivo
                                        strb.append(',');
92
                                }
93
                                strb.append(auxId.get(auxId.size() - 1));
94
95
                                strb.append('}');
96
                                if (auxId.size() == 1) {
97
                                        auxAll.remove(auxId.get(0));
98
                                }
99
                                auxAll.add(0, strb.toString());
100
                        }
101
                        ids = (String[]) auxAll.toArray(new String[auxAll.size()]);
102
                        int ids_size = ids.length;
103
                        FieldComboItem[] ids_ci = new FieldComboItem[ids_size];
104
105
                        for (int i = 0; i < ids_size; i++) {
106
                                ids_ci[i] = new FieldComboItem(ids[i]);
107
                        }
108
109
110
                        int geos_size = geos.length;
111
                        FieldComboItem[] geos_ci = new FieldComboItem[geos_size];
112
113
                        for (int i = 0; i < geos_size; i++) {
114
                                geos_ci[i] = new FieldComboItem(geos[i]);
115
                        }
116
117
                        tableSettingsPanel = new UserTableSettingsVectorialPanel(ids_ci,
118
                                        geos_ci,
119
                                        tableName, mc, false, (WizardVectorialDB) parent,
120
                                        getParameters(),
121
                                        currentProjection(espView,
122
                                                        ids_ci, geos_ci));
123
                }
124
125
                return tableSettingsPanel;
126
        }
127
128
    public void setEnabledPanels(boolean b) {
129
            super.setEnabledPanels(b);
130
                tableSettingsPanel.enableSpatialControls(b);
131
                tableSettingsPanel.enableAlphaControls(b);
132
        }
133
134
}