svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.dal / org.gvsig.fmap.dal.swing / org.gvsig.fmap.dal.swing.impl / src / main / java / org / gvsig / fmap / dal / swing / impl / DefaultDataSwingManager.java @ 42775
History | View | Annotate | Download (5.33 KB)
1 |
/* gvSIG. Desktop Geographic Information System.
|
---|---|
2 |
*
|
3 |
* Copyright ? 2007-2014 gvSIG Association
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
18 |
* MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us
|
21 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
package org.gvsig.fmap.dal.swing.impl; |
24 |
|
25 |
import org.gvsig.featureform.swing.CreateJFeatureFormException; |
26 |
import org.gvsig.featureform.swing.JFeatureForm; |
27 |
|
28 |
import org.gvsig.featureform.swing.JFeaturesForm; |
29 |
import org.gvsig.featureform.swing.impl.DefaultJFeatureForm; |
30 |
import org.gvsig.featureform.swing.impl.DefaultJFeaturesForm; |
31 |
import org.gvsig.fmap.dal.DALLocator; |
32 |
import org.gvsig.fmap.dal.feature.Feature; |
33 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
34 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
35 |
import org.gvsig.fmap.dal.feature.FeatureType; |
36 |
import org.gvsig.fmap.dal.feature.FeatureTypeDefinitionsManager; |
37 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
38 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
39 |
import org.gvsig.fmap.dal.swing.FeatureTableModel; |
40 |
import org.gvsig.fmap.dal.swing.JFeatureTable; |
41 |
import org.gvsig.fmap.dal.swing.impl.featuretable.FeatureTablePanel; |
42 |
import org.gvsig.fmap.dal.swing.impl.featuretable.table.DefaultFeatureTableModel; |
43 |
import org.gvsig.fmap.dal.swing.impl.featuretable.table.EmptyFeatureTableModel; |
44 |
import org.gvsig.fmap.dal.swing.impl.jdbc.DefaultJDBCConnectionPanel; |
45 |
import org.gvsig.fmap.dal.swing.impl.queryfilter.DefaultQueryFilterExpresion; |
46 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
47 |
import org.gvsig.fmap.dal.swing.queryfilter.QueryFilterExpresion; |
48 |
import org.gvsig.tools.dynform.DynFormLocator; |
49 |
import org.gvsig.tools.dynobject.DynClass; |
50 |
import org.gvsig.tools.dynobject.DynStruct; |
51 |
import org.gvsig.tools.exception.BaseException; |
52 |
|
53 |
|
54 |
/**
|
55 |
* @author fdiaz
|
56 |
*
|
57 |
*/
|
58 |
public class DefaultDataSwingManager implements DataSwingManager { |
59 |
|
60 |
@Override
|
61 |
public JFeaturesForm createJFeaturesForm(FeatureStore store) throws CreateJFeatureFormException { |
62 |
try {
|
63 |
FeatureType featureType = store.getDefaultFeatureType(); |
64 |
FeatureTypeDefinitionsManager featureTypeDefinitionsManager = DALLocator.getFeatureTypeDefinitionsManager(); |
65 |
if( featureTypeDefinitionsManager.contains(store,featureType) ) {
|
66 |
// Force reload next call to get.
|
67 |
featureTypeDefinitionsManager.remove(store,featureType); |
68 |
} |
69 |
DynClass dynClass = featureTypeDefinitionsManager.get(store,featureType); |
70 |
DynFormLocator.getDynFormManager().removeDefinition(dynClass.getName()); |
71 |
|
72 |
DefaultJFeaturesForm form = new DefaultJFeaturesForm();
|
73 |
form.bind(store, dynClass); |
74 |
return form;
|
75 |
|
76 |
} catch (Exception ex) { |
77 |
throw new CreateJFeatureFormException(ex); |
78 |
} |
79 |
} |
80 |
|
81 |
@Override
|
82 |
public JDBCConnectionPanel createJDBCConnectionPanel() {
|
83 |
JDBCConnectionPanel x = new DefaultJDBCConnectionPanel();
|
84 |
return x;
|
85 |
} |
86 |
|
87 |
@Override
|
88 |
public QueryFilterExpresion createQueryFilterExpresion(FeatureStore store) {
|
89 |
return new DefaultQueryFilterExpresion(store); |
90 |
} |
91 |
|
92 |
@Override
|
93 |
public JFeatureForm createJFeatureForm(FeatureStore store) throws CreateJFeatureFormException { |
94 |
JFeatureForm form = new DefaultJFeatureForm();
|
95 |
form.setStore(store); |
96 |
return form;
|
97 |
} |
98 |
|
99 |
@Override
|
100 |
public JFeatureForm createJFeatureForm(Feature feature) throws CreateJFeatureFormException { |
101 |
JFeatureForm form = new DefaultJFeatureForm();
|
102 |
form.setFeature(feature); |
103 |
return form;
|
104 |
} |
105 |
|
106 |
public JFeatureTable createJFeatureTable(FeatureTableModel model) {
|
107 |
return this.createJFeatureTable(model, true); |
108 |
} |
109 |
|
110 |
public JFeatureTable createJFeatureTable(FeatureTableModel model, boolean isDoubleBuffered) { |
111 |
return new FeatureTablePanel(model, isDoubleBuffered); |
112 |
} |
113 |
|
114 |
public FeatureTableModel createEmptyFeatureTableModel(DynStruct struct) {
|
115 |
return new EmptyFeatureTableModel(struct); |
116 |
} |
117 |
|
118 |
public FeatureTableModel createFeatureTableModel(FeatureStore featureStore,
|
119 |
FeatureQuery featureQuery) { |
120 |
try {
|
121 |
FeaturePagingHelper pager = DALLocator.getDataManager().createFeaturePagingHelper( |
122 |
featureStore, featureQuery, |
123 |
FeaturePagingHelper.DEFAULT_PAGE_SIZE |
124 |
); |
125 |
return this.createFeatureTableModel(pager); |
126 |
} catch (BaseException ex) {
|
127 |
throw new RuntimeException("Can't create a FeatureTableModel.", ex); |
128 |
} |
129 |
} |
130 |
|
131 |
public FeatureTableModel createFeatureTableModel(FeaturePagingHelper featurePager) {
|
132 |
return new DefaultFeatureTableModel(featurePager); |
133 |
} |
134 |
} |