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 @ 44096
History | View | Annotate | Download (6.32 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 javax.swing.ComboBoxModel; |
26 |
import javax.swing.JButton; |
27 |
import javax.swing.JComboBox; |
28 |
import javax.swing.JTextField; |
29 |
import org.gvsig.featureform.swing.CreateJFeatureFormException; |
30 |
import org.gvsig.featureform.swing.JFeatureForm; |
31 |
|
32 |
import org.gvsig.featureform.swing.JFeaturesForm; |
33 |
import org.gvsig.featureform.swing.impl.DefaultJFeatureForm; |
34 |
import org.gvsig.featureform.swing.impl.DefaultJFeaturesForm; |
35 |
import org.gvsig.fmap.dal.DALLocator; |
36 |
import org.gvsig.fmap.dal.feature.Feature; |
37 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
38 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
39 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
40 |
import org.gvsig.fmap.dal.feature.FeatureType; |
41 |
import org.gvsig.fmap.dal.feature.FeatureTypeDefinitionsManager; |
42 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
43 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
44 |
import org.gvsig.fmap.dal.swing.FeatureTableModel; |
45 |
import org.gvsig.fmap.dal.swing.JFeatureTable; |
46 |
import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorPickerController; |
47 |
import org.gvsig.fmap.dal.swing.impl.featuretable.FeatureTablePanel; |
48 |
import org.gvsig.fmap.dal.swing.impl.featuretable.table.DefaultFeatureTableModel; |
49 |
import org.gvsig.fmap.dal.swing.impl.featuretable.table.EmptyFeatureTableModel; |
50 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultAttributeDescriptorPickerController; |
51 |
import org.gvsig.fmap.dal.swing.impl.jdbc.DefaultJDBCConnectionPanel; |
52 |
import org.gvsig.fmap.dal.swing.impl.queryfilter.DefaultQueryFilterExpresion; |
53 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
54 |
import org.gvsig.fmap.dal.swing.queryfilter.QueryFilterExpresion; |
55 |
import org.gvsig.tools.dispose.DisposableIterator; |
56 |
import org.gvsig.tools.dynform.DynFormLocator; |
57 |
import org.gvsig.tools.dynobject.DynClass; |
58 |
import org.gvsig.tools.dynobject.DynObjectValueItem; |
59 |
import org.gvsig.tools.dynobject.DynStruct; |
60 |
import org.gvsig.tools.exception.BaseException; |
61 |
|
62 |
|
63 |
/**
|
64 |
* @author fdiaz
|
65 |
*
|
66 |
*/
|
67 |
public class DefaultDataSwingManager implements DataSwingManager { |
68 |
|
69 |
@Override
|
70 |
public JFeaturesForm createJFeaturesForm(FeatureStore store) throws CreateJFeatureFormException { |
71 |
try {
|
72 |
FeatureType featureType = store.getDefaultFeatureType(); |
73 |
FeatureTypeDefinitionsManager featureTypeDefinitionsManager = DALLocator.getFeatureTypeDefinitionsManager(); |
74 |
if( featureTypeDefinitionsManager.contains(store,featureType) ) {
|
75 |
// Force reload next call to get.
|
76 |
featureTypeDefinitionsManager.remove(store,featureType); |
77 |
} |
78 |
DynClass dynClass = featureTypeDefinitionsManager.get(store,featureType); |
79 |
DynFormLocator.getDynFormManager().removeDefinition(dynClass.getName()); |
80 |
|
81 |
DefaultJFeaturesForm form = new DefaultJFeaturesForm();
|
82 |
form.bind(store, dynClass); |
83 |
return form;
|
84 |
|
85 |
} catch (Exception ex) { |
86 |
throw new CreateJFeatureFormException(ex); |
87 |
} |
88 |
} |
89 |
|
90 |
@Override
|
91 |
public JDBCConnectionPanel createJDBCConnectionPanel() {
|
92 |
JDBCConnectionPanel x = new DefaultJDBCConnectionPanel();
|
93 |
return x;
|
94 |
} |
95 |
|
96 |
@Override
|
97 |
public QueryFilterExpresion createQueryFilterExpresion(FeatureStore store) {
|
98 |
return new DefaultQueryFilterExpresion(store); |
99 |
} |
100 |
|
101 |
@Override
|
102 |
public JFeatureForm createJFeatureForm(FeatureStore store) throws CreateJFeatureFormException { |
103 |
JFeatureForm form = new DefaultJFeatureForm();
|
104 |
form.setStore(store); |
105 |
return form;
|
106 |
} |
107 |
|
108 |
@Override
|
109 |
public JFeatureForm createJFeatureForm(Feature feature) throws CreateJFeatureFormException { |
110 |
JFeatureForm form = new DefaultJFeatureForm();
|
111 |
form.setFeature(feature); |
112 |
return form;
|
113 |
} |
114 |
|
115 |
public JFeatureTable createJFeatureTable(FeatureTableModel model) {
|
116 |
return this.createJFeatureTable(model, true); |
117 |
} |
118 |
|
119 |
public JFeatureTable createJFeatureTable(FeatureTableModel model, boolean isDoubleBuffered) { |
120 |
return new FeatureTablePanel(model, isDoubleBuffered); |
121 |
} |
122 |
|
123 |
public FeatureTableModel createEmptyFeatureTableModel(DynStruct struct) {
|
124 |
return new EmptyFeatureTableModel(struct); |
125 |
} |
126 |
|
127 |
public FeatureTableModel createFeatureTableModel(FeatureStore featureStore,
|
128 |
FeatureQuery featureQuery) { |
129 |
try {
|
130 |
FeaturePagingHelper pager = DALLocator.getDataManager().createFeaturePagingHelper( |
131 |
featureStore, featureQuery, |
132 |
FeaturePagingHelper.DEFAULT_PAGE_SIZE |
133 |
); |
134 |
return this.createFeatureTableModel(pager); |
135 |
} catch (BaseException ex) {
|
136 |
throw new RuntimeException("Can't create a FeatureTableModel.", ex); |
137 |
} |
138 |
} |
139 |
|
140 |
public FeatureTableModel createFeatureTableModel(FeaturePagingHelper featurePager) {
|
141 |
return new DefaultFeatureTableModel(featurePager); |
142 |
} |
143 |
|
144 |
public ProjectionPickerController createProjectionPickerController(
|
145 |
JTextField txtProjection,
|
146 |
JButton btnSelectProjection
|
147 |
) { |
148 |
ProjectionPickerController picker = new ProjectionPickerController(txtProjection, btnSelectProjection);
|
149 |
return picker;
|
150 |
} |
151 |
|
152 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JComboBox combo) { |
153 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(combo);
|
154 |
return controller;
|
155 |
} |
156 |
} |