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 @ 46485
History | View | Annotate | Download (27.5 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 | 44263 | jjdelcerro | import java.util.Collection; |
26 | import java.util.Collections; |
||
27 | 44707 | jjdelcerro | import java.util.HashMap; |
28 | 44263 | jjdelcerro | import java.util.LinkedHashMap; |
29 | 44340 | jjdelcerro | import java.util.List; |
30 | 44263 | jjdelcerro | import java.util.Map; |
31 | 44128 | jjdelcerro | import java.util.function.Predicate; |
32 | 44410 | jjdelcerro | import javax.swing.AbstractButton; |
33 | import javax.swing.Action; |
||
34 | 44077 | jjdelcerro | import javax.swing.JButton; |
35 | 44096 | jjdelcerro | import javax.swing.JComboBox; |
36 | 44215 | jjdelcerro | import javax.swing.JList; |
37 | 44077 | jjdelcerro | import javax.swing.JTextField; |
38 | 44662 | jjdelcerro | import javax.swing.text.JTextComponent; |
39 | 46399 | jjdelcerro | import javax.swing.tree.TreeModel; |
40 | 44855 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
41 | 46472 | jjdelcerro | import org.gvsig.expressionevaluator.Expression; |
42 | 46421 | jjdelcerro | import org.gvsig.expressionevaluator.ExpressionUtils; |
43 | 44855 | jjdelcerro | import org.gvsig.expressionevaluator.swing.Element; |
44 | import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
||
45 | 44128 | jjdelcerro | import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
46 | import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
||
47 | 44662 | jjdelcerro | import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
48 | 44128 | jjdelcerro | import org.gvsig.expressionevaluator.swing.JExpressionBuilder; |
49 | 42112 | jjdelcerro | import org.gvsig.featureform.swing.CreateJFeatureFormException; |
50 | 45827 | jjdelcerro | import org.gvsig.featureform.swing.FeaturesFormContext; |
51 | 42775 | jjdelcerro | import org.gvsig.featureform.swing.JFeatureForm; |
52 | 45788 | jjdelcerro | import org.gvsig.featureform.swing.JFeatureReferencesForm; |
53 | 42112 | jjdelcerro | |
54 | 42775 | jjdelcerro | import org.gvsig.featureform.swing.JFeaturesForm; |
55 | 45827 | jjdelcerro | import org.gvsig.featureform.swing.impl.DefaultFeaturesFormContext; |
56 | 42112 | jjdelcerro | import org.gvsig.featureform.swing.impl.DefaultJFeatureForm; |
57 | 45788 | jjdelcerro | import org.gvsig.featureform.swing.impl.DefaultJFeatureReferencesForm; |
58 | 42775 | jjdelcerro | import org.gvsig.featureform.swing.impl.DefaultJFeaturesForm; |
59 | import org.gvsig.fmap.dal.DALLocator; |
||
60 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.DataManager; |
61 | 46485 | fdiaz | import static org.gvsig.fmap.dal.DataManager.DAL_USE_LABELS; |
62 | import static org.gvsig.fmap.dal.DataManager.USE_LABELS_BOTH; |
||
63 | import static org.gvsig.fmap.dal.DataManager.USE_LABELS_NO; |
||
64 | import static org.gvsig.fmap.dal.DataManager.USE_LABELS_YES; |
||
65 | 44191 | jjdelcerro | import org.gvsig.fmap.dal.DataStoreProviderFactory; |
66 | 46399 | jjdelcerro | import org.gvsig.fmap.dal.StoresRepository; |
67 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.exception.DataException; |
68 | import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
||
69 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.feature.Feature; |
70 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
71 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureQuery; |
72 | 45788 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureReference; |
73 | 42112 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
74 | 44712 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
75 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureType; |
76 | import org.gvsig.fmap.dal.feature.FeatureTypeDefinitionsManager; |
||
77 | import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
||
78 | 44308 | jjdelcerro | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
79 | 42112 | jjdelcerro | import org.gvsig.fmap.dal.swing.DataSwingManager; |
80 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.swing.FeatureTableModel; |
81 | import org.gvsig.fmap.dal.swing.JFeatureTable; |
||
82 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.swing.expressionevaluator.FeatureStoreElement; |
83 | 44096 | jjdelcerro | import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorPickerController; |
84 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.swing.featuretype.FeatureTypeAttributePanel; |
85 | import org.gvsig.fmap.dal.swing.featuretype.FeatureTypePanel; |
||
86 | 44263 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.expressionevaluator.DefaultFeatureStoreElement2; |
87 | 42775 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretable.FeatureTablePanel; |
88 | import org.gvsig.fmap.dal.swing.impl.featuretable.table.DefaultFeatureTableModel; |
||
89 | import org.gvsig.fmap.dal.swing.impl.featuretable.table.EmptyFeatureTableModel; |
||
90 | 44096 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultAttributeDescriptorPickerController; |
91 | 44713 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureAttributePanel; |
92 | 44128 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureTypePanel; |
93 | 42112 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.jdbc.DefaultJDBCConnectionPanel; |
94 | 44259 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.searchpanel.DefaultSearchPanel; |
95 | 44281 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.actions.SelectionAddAction.SelectionAddActionFactory; |
96 | import org.gvsig.fmap.dal.swing.impl.actions.SelectionFilterAction.SelectionFilterActionFactory; |
||
97 | import org.gvsig.fmap.dal.swing.impl.actions.SelectionSetAction.SelectionSetActionFactory; |
||
98 | import org.gvsig.fmap.dal.swing.impl.actions.ShowFormAction.ShowFormActionFactory; |
||
99 | 42112 | jjdelcerro | import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
100 | 44259 | jjdelcerro | import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel; |
101 | 42620 | jjdelcerro | import org.gvsig.tools.dynform.DynFormLocator; |
102 | import org.gvsig.tools.dynobject.DynClass; |
||
103 | 42775 | jjdelcerro | import org.gvsig.tools.dynobject.DynStruct; |
104 | import org.gvsig.tools.exception.BaseException; |
||
105 | 44281 | jjdelcerro | import org.gvsig.fmap.dal.swing.DALActionFactory; |
106 | 44410 | jjdelcerro | import org.gvsig.fmap.dal.swing.DALActionFactory.DALActionContext; |
107 | 45602 | jjdelcerro | import org.gvsig.fmap.dal.swing.ProjectionPickerController; |
108 | 45425 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleFeaturesTableModelImpl; |
109 | 45739 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretype.FeatureAttributeListCellRendererImpl; |
110 | 44712 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureAttributesSelectionPanel; |
111 | 44308 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.jdbc.DefaultJDBCConnectionDialog; |
112 | import org.gvsig.fmap.dal.swing.impl.jdbc.JDBCConnectionPickerController; |
||
113 | 44712 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featurequery.DefaultFeatureQueryOrderPanel; |
114 | 44308 | jjdelcerro | import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionDialog; |
115 | 44707 | jjdelcerro | import org.gvsig.fmap.dal.swing.searchpanel.SearchConditionPanel.SearchConditionPanelFactory; |
116 | 44308 | jjdelcerro | import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
117 | 44712 | jjdelcerro | import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryOrderPanel; |
118 | 45788 | jjdelcerro | import org.gvsig.fmap.dal.swing.featuretable.SimpleFeaturesTableModel; |
119 | 45739 | jjdelcerro | import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributeListCellRenderer; |
120 | 44713 | jjdelcerro | import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributesSelectionPanel; |
121 | 46050 | omartinez | import org.gvsig.fmap.dal.swing.impl.actions.GraphAction.GraphActionFactory; |
122 | 44855 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.CheckTableFieldsSuggestionProviderFactory; |
123 | import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.QuotesForFieldNameSuggestionProviderFactory; |
||
124 | import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.StorePointFieldSuggestionProviderFactory; |
||
125 | import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.WrongNameFieldSuggestionProviderFactory; |
||
126 | 46472 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleEditedFeaturesTableModelImpl; |
127 | import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleSelectedFeaturesTableModelImpl; |
||
128 | 46399 | jjdelcerro | import org.gvsig.fmap.dal.swing.impl.storerepository.StoresRepositoryTreeModel; |
129 | 45537 | jolivas | import org.gvsig.fmap.dal.swing.searchPostProcess.SearchPostProcessFactory; |
130 | 45726 | jjdelcerro | import org.gvsig.tools.dynform.DynFormDefinition; |
131 | 46485 | fdiaz | import org.gvsig.tools.dynobject.Tags; |
132 | 42112 | jjdelcerro | |
133 | |||
134 | /**
|
||
135 | * @author fdiaz
|
||
136 | *
|
||
137 | */
|
||
138 | 44128 | jjdelcerro | @SuppressWarnings("UseSpecificCatch") |
139 | 42775 | jjdelcerro | public class DefaultDataSwingManager implements DataSwingManager { |
140 | 42112 | jjdelcerro | |
141 | 44281 | jjdelcerro | private final Map<String,DALActionFactory> featureStoreSearchActions; |
142 | 45739 | jjdelcerro | private final Map<String,SearchPostProcessFactory> searchPostProcess; |
143 | 44707 | jjdelcerro | private Map<String,SearchConditionPanelFactory> searchConditionPanelFactories; |
144 | 46485 | fdiaz | private Integer useLabels; |
145 | 44263 | jjdelcerro | |
146 | public DefaultDataSwingManager() {
|
||
147 | this.featureStoreSearchActions = new LinkedHashMap<>(); |
||
148 | 44281 | jjdelcerro | this.registerStoreAction(new SelectionAddActionFactory()); |
149 | this.registerStoreAction(new SelectionFilterActionFactory()); |
||
150 | this.registerStoreAction(new SelectionSetActionFactory()); |
||
151 | this.registerStoreAction(new ShowFormActionFactory()); |
||
152 | 46050 | omartinez | this.registerStoreAction(new GraphActionFactory()); |
153 | 45537 | jolivas | |
154 | this.searchPostProcess = new HashMap<>(); |
||
155 | 44263 | jjdelcerro | } |
156 | |||
157 | 42512 | jjdelcerro | @Override
|
158 | 42775 | jjdelcerro | public JFeaturesForm createJFeaturesForm(FeatureStore store) throws CreateJFeatureFormException { |
159 | 42112 | jjdelcerro | try {
|
160 | 42775 | jjdelcerro | FeatureType featureType = store.getDefaultFeatureType(); |
161 | |||
162 | DefaultJFeaturesForm form = new DefaultJFeaturesForm();
|
||
163 | 45532 | jjdelcerro | form.bind(store, featureType2DynClass(store, featureType), null);
|
164 | 42775 | jjdelcerro | return form;
|
165 | |||
166 | } catch (Exception ex) { |
||
167 | throw new CreateJFeatureFormException(ex); |
||
168 | 42112 | jjdelcerro | } |
169 | } |
||
170 | |||
171 | 45532 | jjdelcerro | @Override
|
172 | public JFeaturesForm createJFeaturesForm(FeatureStore store, FeatureQuery query) throws CreateJFeatureFormException { |
||
173 | try {
|
||
174 | FeatureType featureType = store.getDefaultFeatureType(); |
||
175 | |||
176 | DefaultJFeaturesForm form = new DefaultJFeaturesForm();
|
||
177 | form.bind(store, featureType2DynClass(store, featureType), query); |
||
178 | return form;
|
||
179 | |||
180 | } catch (Exception ex) { |
||
181 | throw new CreateJFeatureFormException(ex); |
||
182 | } |
||
183 | } |
||
184 | |||
185 | 44202 | jjdelcerro | public DynClass featureType2DynClass(FeatureStore store, FeatureType type) {
|
186 | FeatureTypeDefinitionsManager featureTypeDefinitionsManager = DALLocator.getFeatureTypeDefinitionsManager(); |
||
187 | if( featureTypeDefinitionsManager.contains(store,type) ) {
|
||
188 | // Force reload next call to get.
|
||
189 | featureTypeDefinitionsManager.remove(store,type); |
||
190 | } |
||
191 | DynClass dynClass = featureTypeDefinitionsManager.get(store,type); |
||
192 | // Force reload next call to get.
|
||
193 | DynFormLocator.getDynFormManager().removeDefinition(dynClass.getName()); |
||
194 | return dynClass;
|
||
195 | } |
||
196 | |||
197 | 42512 | jjdelcerro | @Override
|
198 | 42112 | jjdelcerro | public JDBCConnectionPanel createJDBCConnectionPanel() {
|
199 | JDBCConnectionPanel x = new DefaultJDBCConnectionPanel();
|
||
200 | return x;
|
||
201 | } |
||
202 | |||
203 | 42512 | jjdelcerro | @Override
|
204 | 44308 | jjdelcerro | public JDBCConnectionDialog createJDBCConectionDialog() {
|
205 | JDBCConnectionDialog x = new DefaultJDBCConnectionDialog();
|
||
206 | return x;
|
||
207 | } |
||
208 | |||
209 | @Override
|
||
210 | 44855 | jjdelcerro | public void configureExpressionBuilder(ExpressionBuilderConfig builder, FeatureStore store) { |
211 | 44128 | jjdelcerro | DataManager dataManager = DALLocator.getDataManager(); |
212 | 44202 | jjdelcerro | FeatureSymbolTable featureSymbolTable = dataManager.createFeatureSymbolTable(); |
213 | 44128 | jjdelcerro | |
214 | 45922 | jjdelcerro | builder.removeAllElements(); |
215 | 44712 | jjdelcerro | FeatureStoreProviderFactory storeFactory = (FeatureStoreProviderFactory) store.getProviderFactory(); |
216 | 45527 | jjdelcerro | Feature sampleFeature = store.getSampleFeature(); |
217 | 44712 | jjdelcerro | builder.setAllowedFunctions(storeFactory.allowFunction()); |
218 | 44128 | jjdelcerro | if( sampleFeature!=null ) { |
219 | featureSymbolTable.setFeature(sampleFeature); |
||
220 | builder.setPreviewSymbolTable(featureSymbolTable.createParent()); |
||
221 | } |
||
222 | 44202 | jjdelcerro | builder.addSymbolTable(featureSymbolTable); |
223 | 44263 | jjdelcerro | FeatureStoreElement storeElement = new DefaultFeatureStoreElement2(store);
|
224 | 44209 | jjdelcerro | builder.addElement(storeElement); |
225 | 44191 | jjdelcerro | if( store.getProviderFactory().hasSQLSupport()==DataStoreProviderFactory.YES ) {
|
226 | 44259 | jjdelcerro | builder.getPreferences().setSQLCompatible(true);
|
227 | 44855 | jjdelcerro | } |
228 | builder.addSuggestionFactory(new StorePointFieldSuggestionProviderFactory(store));
|
||
229 | builder.addSuggestionFactory(new QuotesForFieldNameSuggestionProviderFactory(store));
|
||
230 | builder.addSuggestionFactory(new WrongNameFieldSuggestionProviderFactory(store));
|
||
231 | builder.addSuggestionFactory(new CheckTableFieldsSuggestionProviderFactory(store));
|
||
232 | } |
||
233 | |||
234 | @Override
|
||
235 | 46421 | jjdelcerro | public void resetExpressionBuilder(ExpressionBuilderConfig builder) { |
236 | builder.removeAllElements(); |
||
237 | builder.setPreviewSymbolTable(ExpressionUtils.createSymbolTable()); |
||
238 | } |
||
239 | |||
240 | @Override
|
||
241 | public void addToExpressionBuilder(ExpressionBuilderConfig builder, FeatureStore store, String name) { |
||
242 | // Este metodo permite a?adir mas de un store al builder llamandolo
|
||
243 | // con un name distinto para cada store. En el arbol se presentaran todos
|
||
244 | // los stores que se configuren en el builder.
|
||
245 | // Ojo, que las expresiones creadas por estos builder no son compatible
|
||
246 | // con SQL.
|
||
247 | DataManager dataManager = DALLocator.getDataManager(); |
||
248 | |||
249 | // Creamos el store-element y lo a?adimos al builder
|
||
250 | FeatureStoreElement n = new DefaultFeatureStoreElement2(store, name);
|
||
251 | builder.addElement(n); |
||
252 | |||
253 | // Creamos una tabla de simbolos de ejemplo basada en el store, y la
|
||
254 | // a?adimos a la tabla de simbolos de previsualizacion del builder.
|
||
255 | FeatureSymbolTable featureSymbolTable = dataManager.createFeatureSymbolTable(); |
||
256 | Feature sampleFeature = store.getSampleFeature(); |
||
257 | if( sampleFeature!=null ) { |
||
258 | featureSymbolTable.setFeature(sampleFeature); |
||
259 | builder.getPreviewSymbolTable().addSymbolTable(featureSymbolTable); |
||
260 | } |
||
261 | |||
262 | // forzamos a que al insertar campos de un store se indique siempre
|
||
263 | // en nombre del store. Necesario si hay mas de un store en el builder.
|
||
264 | List<Element> elements = builder.getElements(); |
||
265 | for (Element item : elements) { |
||
266 | if( item instanceof FeatureStoreElement ) { |
||
267 | ((FeatureStoreElement)item).setUseFullyQualifiedNames(true);
|
||
268 | } |
||
269 | } |
||
270 | // Marcamos como no compatible sql las expresiones que vamos a generar.
|
||
271 | builder.getPreferences().setSQLCompatible(false);
|
||
272 | |||
273 | // A?adimos los generadores de sugerencias.
|
||
274 | builder.addSuggestionFactory(new StorePointFieldSuggestionProviderFactory(store));
|
||
275 | builder.addSuggestionFactory(new QuotesForFieldNameSuggestionProviderFactory(store));
|
||
276 | builder.addSuggestionFactory(new WrongNameFieldSuggestionProviderFactory(store));
|
||
277 | builder.addSuggestionFactory(new CheckTableFieldsSuggestionProviderFactory(store));
|
||
278 | } |
||
279 | |||
280 | @Override
|
||
281 | 44855 | jjdelcerro | public JExpressionBuilder createQueryFilterExpresion(FeatureStore store) {
|
282 | return this.createJExpressionBuilder(store); |
||
283 | } |
||
284 | |||
285 | @Override
|
||
286 | public JExpressionBuilder createJExpressionBuilder(final FeatureStore store) { |
||
287 | ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
||
288 | final JExpressionBuilder builder = expressionSwingManager.createJExpressionBuilder();
|
||
289 | this.configureExpressionBuilder(builder, store);
|
||
290 | builder.expandElement( |
||
291 | (Element t) -> t!=null && StringUtils.equals(t.getName(),store.getName()) |
||
292 | ); |
||
293 | 44128 | jjdelcerro | return builder;
|
294 | 42489 | jjdelcerro | } |
295 | 42112 | jjdelcerro | |
296 | 42775 | jjdelcerro | @Override
|
297 | 44855 | jjdelcerro | public ExpressionPickerController createExpressionPickerController(FeatureStore store, JTextComponent text, JButton button, JButton bookmarks, JButton history) { |
298 | ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
||
299 | ExpressionPickerController builder = expressionSwingManager.createExpressionPickerController(text, button, bookmarks, history); |
||
300 | this.configureExpressionBuilder(builder, store);
|
||
301 | return builder;
|
||
302 | } |
||
303 | |||
304 | @Override
|
||
305 | 42775 | jjdelcerro | public JFeatureForm createJFeatureForm(FeatureStore store) throws CreateJFeatureFormException { |
306 | JFeatureForm form = new DefaultJFeatureForm();
|
||
307 | form.setStore(store); |
||
308 | return form;
|
||
309 | } |
||
310 | |||
311 | @Override
|
||
312 | 45788 | jjdelcerro | public JFeatureReferencesForm createJFeatureReferencesForm(FeatureStore store, List<FeatureReference> references) throws CreateJFeatureFormException { |
313 | JFeatureReferencesForm form = new DefaultJFeatureReferencesForm();
|
||
314 | form.bind(store, references); |
||
315 | return form;
|
||
316 | } |
||
317 | |||
318 | @Override
|
||
319 | 42775 | jjdelcerro | public JFeatureForm createJFeatureForm(Feature feature) throws CreateJFeatureFormException { |
320 | JFeatureForm form = new DefaultJFeatureForm();
|
||
321 | form.setFeature(feature); |
||
322 | return form;
|
||
323 | } |
||
324 | |||
325 | 44202 | jjdelcerro | @Override
|
326 | 45726 | jjdelcerro | public JFeatureForm createJFeatureForm(DynFormDefinition definicion) throws CreateJFeatureFormException { |
327 | JFeatureForm form = new DefaultJFeatureForm();
|
||
328 | form.setDefinition(definicion); |
||
329 | return form;
|
||
330 | } |
||
331 | |||
332 | @Override
|
||
333 | 42775 | jjdelcerro | public JFeatureTable createJFeatureTable(FeatureTableModel model) {
|
334 | return this.createJFeatureTable(model, true); |
||
335 | } |
||
336 | |||
337 | 44202 | jjdelcerro | @Override
|
338 | 42775 | jjdelcerro | public JFeatureTable createJFeatureTable(FeatureTableModel model, boolean isDoubleBuffered) { |
339 | return new FeatureTablePanel(model, isDoubleBuffered); |
||
340 | } |
||
341 | |||
342 | 44202 | jjdelcerro | @Override
|
343 | 42775 | jjdelcerro | public FeatureTableModel createEmptyFeatureTableModel(DynStruct struct) {
|
344 | return new EmptyFeatureTableModel(struct); |
||
345 | } |
||
346 | |||
347 | 44202 | jjdelcerro | @Override
|
348 | 42775 | jjdelcerro | public FeatureTableModel createFeatureTableModel(FeatureStore featureStore,
|
349 | FeatureQuery featureQuery) { |
||
350 | try {
|
||
351 | FeaturePagingHelper pager = DALLocator.getDataManager().createFeaturePagingHelper( |
||
352 | featureStore, featureQuery, |
||
353 | FeaturePagingHelper.DEFAULT_PAGE_SIZE |
||
354 | ); |
||
355 | return this.createFeatureTableModel(pager); |
||
356 | } catch (BaseException ex) {
|
||
357 | throw new RuntimeException("Can't create a FeatureTableModel.", ex); |
||
358 | } |
||
359 | } |
||
360 | |||
361 | 44202 | jjdelcerro | @Override
|
362 | 42775 | jjdelcerro | public FeatureTableModel createFeatureTableModel(FeaturePagingHelper featurePager) {
|
363 | return new DefaultFeatureTableModel(featurePager); |
||
364 | } |
||
365 | 44077 | jjdelcerro | |
366 | 44202 | jjdelcerro | @Override
|
367 | 44077 | jjdelcerro | public ProjectionPickerController createProjectionPickerController(
|
368 | JTextField txtProjection,
|
||
369 | JButton btnSelectProjection
|
||
370 | ) { |
||
371 | 45602 | jjdelcerro | ProjectionPickerControllerImpl picker = new ProjectionPickerControllerImpl(txtProjection, btnSelectProjection);
|
372 | 44077 | jjdelcerro | return picker;
|
373 | } |
||
374 | 44096 | jjdelcerro | |
375 | 44202 | jjdelcerro | @Override
|
376 | 44096 | jjdelcerro | public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JComboBox combo) { |
377 | 44128 | jjdelcerro | AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(combo, null); |
378 | 44096 | jjdelcerro | return controller;
|
379 | } |
||
380 | 44128 | jjdelcerro | |
381 | 44202 | jjdelcerro | @Override
|
382 | 44215 | jjdelcerro | public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JList list) { |
383 | AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(list, null); |
||
384 | return controller;
|
||
385 | } |
||
386 | |||
387 | @Override
|
||
388 | 44128 | jjdelcerro | public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JComboBox combo, Predicate<FeatureAttributeDescriptor> filter) { |
389 | AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(combo, filter);
|
||
390 | return controller;
|
||
391 | } |
||
392 | |||
393 | 44202 | jjdelcerro | @Override
|
394 | 44215 | jjdelcerro | public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JList list, Predicate<FeatureAttributeDescriptor> filter) { |
395 | AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(list, filter);
|
||
396 | return controller;
|
||
397 | } |
||
398 | |||
399 | @Override
|
||
400 | 44128 | jjdelcerro | public FeatureTypePanel createFeatureTypePanel() {
|
401 | FeatureTypePanel panel = new DefaultFeatureTypePanel();
|
||
402 | return panel;
|
||
403 | } |
||
404 | |||
405 | 44202 | jjdelcerro | @Override
|
406 | 44128 | jjdelcerro | public FeatureTypeAttributePanel createFeatureTypeAttributePanel() {
|
407 | 44713 | jjdelcerro | FeatureTypeAttributePanel panel = new DefaultFeatureAttributePanel();
|
408 | 44128 | jjdelcerro | return panel;
|
409 | } |
||
410 | |||
411 | 44202 | jjdelcerro | @Override
|
412 | 44259 | jjdelcerro | public FeatureStoreElement createFeatureStoreElement() {
|
413 | 44263 | jjdelcerro | FeatureStoreElement e = new DefaultFeatureStoreElement2(null); |
414 | 44128 | jjdelcerro | return e;
|
415 | } |
||
416 | 44259 | jjdelcerro | |
417 | @Override
|
||
418 | 44285 | jjdelcerro | public FeatureStoreElement createFeatureStoreElement(FeatureStore store) {
|
419 | FeatureStoreElement e = new DefaultFeatureStoreElement2(store);
|
||
420 | return e;
|
||
421 | } |
||
422 | |||
423 | @Override
|
||
424 | 44662 | jjdelcerro | public ExpressionPickerController createExpressionPickerController(FeatureStore store, JTextComponent text, JButton button) { |
425 | FeatureSymbolTable previewSymbolTable = DALLocator.getManager().createFeatureSymbolTable(); |
||
426 | previewSymbolTable.setFeature(store.getSampleFeature()); |
||
427 | |||
428 | ExpressionPickerController controller = ExpressionEvaluatorSwingLocator.getManager().createExpressionPickerController(text, button); |
||
429 | controller.addElement(this.createFeatureStoreElement(store));
|
||
430 | controller.setPreviewSymbolTable(previewSymbolTable); |
||
431 | |||
432 | return controller;
|
||
433 | } |
||
434 | |||
435 | |||
436 | @Override
|
||
437 | 44259 | jjdelcerro | public FeatureStoreSearchPanel createFeatureStoreSearchPanel(FeatureStore store) {
|
438 | DefaultSearchPanel e = new DefaultSearchPanel(store);
|
||
439 | return e;
|
||
440 | } |
||
441 | |||
442 | 44263 | jjdelcerro | @Override
|
443 | 44281 | jjdelcerro | public final void registerStoreAction(DALActionFactory action) { |
444 | 44263 | jjdelcerro | this.featureStoreSearchActions.put(action.getName().toLowerCase(), action);
|
445 | } |
||
446 | 44259 | jjdelcerro | |
447 | 44263 | jjdelcerro | @Override
|
448 | 44281 | jjdelcerro | public Collection<DALActionFactory> getStoreActions() { |
449 | 44263 | jjdelcerro | return Collections.unmodifiableCollection(this.featureStoreSearchActions.values()); |
450 | } |
||
451 | 44308 | jjdelcerro | |
452 | @Override
|
||
453 | 44340 | jjdelcerro | public DALActionFactory getStoreAction(String name) { |
454 | DALActionFactory action = this.featureStoreSearchActions.get(name.toLowerCase());
|
||
455 | return action;
|
||
456 | } |
||
457 | 44410 | jjdelcerro | |
458 | @Override
|
||
459 | public void setStoreAction(AbstractButton component, String name, boolean preserveLabel, DALActionContext context) { |
||
460 | DALActionFactory factory = this.getStoreAction(name);
|
||
461 | Action action = factory.createAction(context);
|
||
462 | if( preserveLabel ) {
|
||
463 | String s = component.getText();
|
||
464 | component.setAction(action); |
||
465 | component.setText(s); |
||
466 | } else {
|
||
467 | component.setAction(action); |
||
468 | } |
||
469 | } |
||
470 | 44340 | jjdelcerro | |
471 | 44410 | jjdelcerro | |
472 | 44340 | jjdelcerro | @Override
|
473 | 44308 | jjdelcerro | public PickerController<JDBCServerExplorerParameters> createJDBCConnectionPickerController(
|
474 | JComboBox cboConnection, JButton btnConnection |
||
475 | ) { |
||
476 | JDBCConnectionPickerController x = new JDBCConnectionPickerController(cboConnection, btnConnection);
|
||
477 | return x;
|
||
478 | } |
||
479 | 44340 | jjdelcerro | |
480 | @Override
|
||
481 | 45788 | jjdelcerro | public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureStore store) {
|
482 | 44340 | jjdelcerro | try {
|
483 | 45425 | jjdelcerro | SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(store);
|
484 | 44340 | jjdelcerro | return m;
|
485 | } catch (DataException ex) {
|
||
486 | throw new RuntimeException("Can't creatre SimpleFeaturesTableModel.", ex); |
||
487 | } |
||
488 | } |
||
489 | 46472 | jjdelcerro | |
490 | @Override
|
||
491 | public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureStore store, Expression filter) { |
||
492 | try {
|
||
493 | SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(store, filter);
|
||
494 | return m;
|
||
495 | } catch (DataException ex) {
|
||
496 | throw new RuntimeException("Can't creatre SimpleFeaturesTableModel.", ex); |
||
497 | } |
||
498 | } |
||
499 | |||
500 | @Override
|
||
501 | public SimpleFeaturesTableModel createSimpleEditedFeaturesTableModel(FeatureStore store, Expression filter) { |
||
502 | SimpleFeaturesTableModelImpl m = new SimpleEditedFeaturesTableModelImpl(store, filter);
|
||
503 | return m;
|
||
504 | } |
||
505 | 44308 | jjdelcerro | |
506 | 44340 | jjdelcerro | @Override
|
507 | 46472 | jjdelcerro | public SimpleFeaturesTableModel createSimpleSelectedFeaturesTableModel(FeatureStore store, Expression filter) { |
508 | SimpleFeaturesTableModelImpl m = new SimpleSelectedFeaturesTableModelImpl(store, filter);
|
||
509 | return m;
|
||
510 | } |
||
511 | |||
512 | @Override
|
||
513 | 45788 | jjdelcerro | public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureType featureType, List<String> columnNames, List<Feature> features) { |
514 | 45425 | jjdelcerro | SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(featureType, columnNames, features);
|
515 | 44340 | jjdelcerro | return m;
|
516 | } |
||
517 | 45425 | jjdelcerro | |
518 | 44644 | jjdelcerro | @Override
|
519 | 45739 | jjdelcerro | public FeatureAttributeListCellRenderer createDefaultFeatureAttributeListCellRenderer() {
|
520 | FeatureAttributeListCellRenderer r = new FeatureAttributeListCellRendererImpl();
|
||
521 | 44644 | jjdelcerro | return r;
|
522 | } |
||
523 | |||
524 | @Override
|
||
525 | 44712 | jjdelcerro | public FeatureQueryOrderPanel createFeatureStoreOrderPanel() {
|
526 | DefaultFeatureQueryOrderPanel p = new DefaultFeatureQueryOrderPanel();
|
||
527 | 44644 | jjdelcerro | return p;
|
528 | } |
||
529 | 44308 | jjdelcerro | |
530 | 44707 | jjdelcerro | @Override
|
531 | public Iterable<SearchConditionPanelFactory> getSearchConditionPanels() { |
||
532 | if( this.searchConditionPanelFactories==null ) { |
||
533 | return Collections.EMPTY_LIST; |
||
534 | } |
||
535 | return this.searchConditionPanelFactories.values(); |
||
536 | } |
||
537 | |||
538 | @Override
|
||
539 | public void registerSearchConditionPanel(SearchConditionPanelFactory factory) { |
||
540 | if( this.searchConditionPanelFactories==null ) { |
||
541 | this.searchConditionPanelFactories = new HashMap<>(); |
||
542 | } |
||
543 | this.searchConditionPanelFactories.put(factory.getName(), factory);
|
||
544 | } |
||
545 | |||
546 | 45537 | jolivas | @Override
|
547 | public FeatureAttributesSelectionPanel createFeatureAttributeSelectionPanel() {
|
||
548 | FeatureAttributesSelectionPanel p = new DefaultFeatureAttributesSelectionPanel();
|
||
549 | return p;
|
||
550 | } |
||
551 | 44707 | jjdelcerro | |
552 | 45537 | jolivas | @Override
|
553 | public void registerSearchPostProcess(SearchPostProcessFactory process) { |
||
554 | this.searchPostProcess.put(process.getName(), process);
|
||
555 | } |
||
556 | |||
557 | @Override
|
||
558 | public Map<String,SearchPostProcessFactory> getSearchPostProcess() { |
||
559 | return this.searchPostProcess; |
||
560 | } |
||
561 | |||
562 | @Override
|
||
563 | public SearchPostProcessFactory getSearchPostProcess(String name) { |
||
564 | SearchPostProcessFactory process = this.searchPostProcess.get(name);
|
||
565 | return process;
|
||
566 | } |
||
567 | |||
568 | 45827 | jjdelcerro | @Override
|
569 | public FeaturesFormContext createFeaturesFormContext(FeatureStore store) {
|
||
570 | DefaultFeaturesFormContext context = new DefaultFeaturesFormContext(store);
|
||
571 | return context;
|
||
572 | } |
||
573 | |||
574 | 46399 | jjdelcerro | @Override
|
575 | public TreeModel createTreeModel(StoresRepository repository) { |
||
576 | StoresRepositoryTreeModel model = new StoresRepositoryTreeModel(repository);
|
||
577 | return model;
|
||
578 | } |
||
579 | 46485 | fdiaz | |
580 | @Override
|
||
581 | public String getAttributeDescriptorLabel(FeatureAttributeDescriptor attrdesc) { |
||
582 | return getAttributeDescriptorLabel(attrdesc, null); |
||
583 | } |
||
584 | |||
585 | @Override
|
||
586 | public String getAttributeDescriptorLabel(FeatureAttributeDescriptor attrdesc, String tableName) { |
||
587 | String theLabel;
|
||
588 | int theUseLabels;
|
||
589 | if (getUseLabels() == null) { |
||
590 | Tags tags = attrdesc.getTags(); |
||
591 | if (tags.has(DAL_USE_LABELS)) {
|
||
592 | theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
||
593 | } else {
|
||
594 | if (attrdesc.getFeatureType() != null) { |
||
595 | tags = attrdesc.getFeatureType().getTags(); |
||
596 | theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
||
597 | } else {
|
||
598 | theUseLabels = USE_LABELS_NO; |
||
599 | } |
||
600 | } |
||
601 | } else {
|
||
602 | theUseLabels = getUseLabels(); |
||
603 | } |
||
604 | switch (theUseLabels) {
|
||
605 | case USE_LABELS_BOTH:
|
||
606 | if (!StringUtils.equals(attrdesc.getLocalizedLabel(), attrdesc.getName())){
|
||
607 | if (StringUtils.isBlank(tableName)) {
|
||
608 | theLabel = String.format("%s [%s]", attrdesc.getLocalizedLabel(), attrdesc.getName()); |
||
609 | } else {
|
||
610 | theLabel = String.format("%s [%s/%s]", attrdesc.getLocalizedLabel(), attrdesc.getName(), tableName); |
||
611 | } |
||
612 | break;
|
||
613 | } |
||
614 | case USE_LABELS_YES:
|
||
615 | if (StringUtils.isBlank(tableName)) {
|
||
616 | theLabel = attrdesc.getLocalizedLabel(); |
||
617 | } else {
|
||
618 | theLabel = String.format("%s [%s]", attrdesc.getLocalizedLabel(), tableName); |
||
619 | } |
||
620 | break;
|
||
621 | default:
|
||
622 | case USE_LABELS_NO:
|
||
623 | if (StringUtils.isBlank(tableName)) {
|
||
624 | theLabel = attrdesc.getName(); |
||
625 | } else {
|
||
626 | theLabel = String.format("%s [%s]", attrdesc.getName(), tableName); |
||
627 | } |
||
628 | break;
|
||
629 | } |
||
630 | return theLabel;
|
||
631 | } |
||
632 | |||
633 | /**
|
||
634 | * @return the useLabels
|
||
635 | */
|
||
636 | @Override
|
||
637 | public Integer getUseLabels() { |
||
638 | return useLabels;
|
||
639 | } |
||
640 | |||
641 | /**
|
||
642 | * @param useLabels the useLabels to set
|
||
643 | */
|
||
644 | @Override
|
||
645 | public void setUseLabels(Integer useLabels) { |
||
646 | this.useLabels = useLabels;
|
||
647 | } |
||
648 | |||
649 | 42112 | jjdelcerro | } |
650 | 45537 | jolivas |