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