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 |
/* 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 java.util.Collection; |
26 |
import java.util.Collections; |
27 |
import java.util.HashMap; |
28 |
import java.util.LinkedHashMap; |
29 |
import java.util.List; |
30 |
import java.util.Map; |
31 |
import java.util.function.Predicate; |
32 |
import javax.swing.AbstractButton; |
33 |
import javax.swing.Action; |
34 |
import javax.swing.JButton; |
35 |
import javax.swing.JComboBox; |
36 |
import javax.swing.JList; |
37 |
import javax.swing.JTextField; |
38 |
import javax.swing.text.JTextComponent; |
39 |
import javax.swing.tree.TreeModel; |
40 |
import org.apache.commons.lang3.StringUtils; |
41 |
import org.gvsig.expressionevaluator.Expression; |
42 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
43 |
import org.gvsig.expressionevaluator.swing.Element; |
44 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
45 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
46 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
47 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
48 |
import org.gvsig.expressionevaluator.swing.JExpressionBuilder; |
49 |
import org.gvsig.featureform.swing.CreateJFeatureFormException; |
50 |
import org.gvsig.featureform.swing.FeaturesFormContext; |
51 |
import org.gvsig.featureform.swing.JFeatureForm; |
52 |
import org.gvsig.featureform.swing.JFeatureReferencesForm; |
53 |
|
54 |
import org.gvsig.featureform.swing.JFeaturesForm; |
55 |
import org.gvsig.featureform.swing.impl.DefaultFeaturesFormContext; |
56 |
import org.gvsig.featureform.swing.impl.DefaultJFeatureForm; |
57 |
import org.gvsig.featureform.swing.impl.DefaultJFeatureReferencesForm; |
58 |
import org.gvsig.featureform.swing.impl.DefaultJFeaturesForm; |
59 |
import org.gvsig.fmap.dal.DALLocator; |
60 |
import org.gvsig.fmap.dal.DataManager; |
61 |
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 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
66 |
import org.gvsig.fmap.dal.StoresRepository; |
67 |
import org.gvsig.fmap.dal.exception.DataException; |
68 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
69 |
import org.gvsig.fmap.dal.feature.Feature; |
70 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
71 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
72 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
73 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
74 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
75 |
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 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
79 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
80 |
import org.gvsig.fmap.dal.swing.FeatureTableModel; |
81 |
import org.gvsig.fmap.dal.swing.JFeatureTable; |
82 |
import org.gvsig.fmap.dal.swing.expressionevaluator.FeatureStoreElement; |
83 |
import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorPickerController; |
84 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureTypeAttributePanel; |
85 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureTypePanel; |
86 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.DefaultFeatureStoreElement2; |
87 |
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 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultAttributeDescriptorPickerController; |
91 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureAttributePanel; |
92 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureTypePanel; |
93 |
import org.gvsig.fmap.dal.swing.impl.jdbc.DefaultJDBCConnectionPanel; |
94 |
import org.gvsig.fmap.dal.swing.impl.searchpanel.DefaultSearchPanel; |
95 |
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 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
100 |
import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel; |
101 |
import org.gvsig.tools.dynform.DynFormLocator; |
102 |
import org.gvsig.tools.dynobject.DynClass; |
103 |
import org.gvsig.tools.dynobject.DynStruct; |
104 |
import org.gvsig.tools.exception.BaseException; |
105 |
import org.gvsig.fmap.dal.swing.DALActionFactory; |
106 |
import org.gvsig.fmap.dal.swing.DALActionFactory.DALActionContext; |
107 |
import org.gvsig.fmap.dal.swing.ProjectionPickerController; |
108 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleFeaturesTableModelImpl; |
109 |
import org.gvsig.fmap.dal.swing.impl.featuretype.FeatureAttributeListCellRendererImpl; |
110 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureAttributesSelectionPanel; |
111 |
import org.gvsig.fmap.dal.swing.impl.jdbc.DefaultJDBCConnectionDialog; |
112 |
import org.gvsig.fmap.dal.swing.impl.jdbc.JDBCConnectionPickerController; |
113 |
import org.gvsig.fmap.dal.swing.impl.featurequery.DefaultFeatureQueryOrderPanel; |
114 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionDialog; |
115 |
import org.gvsig.fmap.dal.swing.searchpanel.SearchConditionPanel.SearchConditionPanelFactory; |
116 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
117 |
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryOrderPanel; |
118 |
import org.gvsig.fmap.dal.swing.featuretable.SimpleFeaturesTableModel; |
119 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributeListCellRenderer; |
120 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributesSelectionPanel; |
121 |
import org.gvsig.fmap.dal.swing.impl.actions.GraphAction.GraphActionFactory; |
122 |
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 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleEditedFeaturesTableModelImpl; |
127 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleSelectedFeaturesTableModelImpl; |
128 |
import org.gvsig.fmap.dal.swing.impl.storerepository.StoresRepositoryTreeModel; |
129 |
import org.gvsig.fmap.dal.swing.searchPostProcess.SearchPostProcessFactory; |
130 |
import org.gvsig.tools.dynform.DynFormDefinition; |
131 |
import org.gvsig.tools.dynobject.Tags; |
132 |
|
133 |
|
134 |
/**
|
135 |
* @author fdiaz
|
136 |
*
|
137 |
*/
|
138 |
@SuppressWarnings("UseSpecificCatch") |
139 |
public class DefaultDataSwingManager implements DataSwingManager { |
140 |
|
141 |
private final Map<String,DALActionFactory> featureStoreSearchActions; |
142 |
private final Map<String,SearchPostProcessFactory> searchPostProcess; |
143 |
private Map<String,SearchConditionPanelFactory> searchConditionPanelFactories; |
144 |
private Integer useLabels; |
145 |
|
146 |
public DefaultDataSwingManager() {
|
147 |
this.featureStoreSearchActions = new LinkedHashMap<>(); |
148 |
this.registerStoreAction(new SelectionAddActionFactory()); |
149 |
this.registerStoreAction(new SelectionFilterActionFactory()); |
150 |
this.registerStoreAction(new SelectionSetActionFactory()); |
151 |
this.registerStoreAction(new ShowFormActionFactory()); |
152 |
this.registerStoreAction(new GraphActionFactory()); |
153 |
|
154 |
this.searchPostProcess = new HashMap<>(); |
155 |
} |
156 |
|
157 |
@Override
|
158 |
public JFeaturesForm createJFeaturesForm(FeatureStore store) throws CreateJFeatureFormException { |
159 |
try {
|
160 |
FeatureType featureType = store.getDefaultFeatureType(); |
161 |
|
162 |
DefaultJFeaturesForm form = new DefaultJFeaturesForm();
|
163 |
form.bind(store, featureType2DynClass(store, featureType), null);
|
164 |
return form;
|
165 |
|
166 |
} catch (Exception ex) { |
167 |
throw new CreateJFeatureFormException(ex); |
168 |
} |
169 |
} |
170 |
|
171 |
@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 |
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 |
@Override
|
198 |
public JDBCConnectionPanel createJDBCConnectionPanel() {
|
199 |
JDBCConnectionPanel x = new DefaultJDBCConnectionPanel();
|
200 |
return x;
|
201 |
} |
202 |
|
203 |
@Override
|
204 |
public JDBCConnectionDialog createJDBCConectionDialog() {
|
205 |
JDBCConnectionDialog x = new DefaultJDBCConnectionDialog();
|
206 |
return x;
|
207 |
} |
208 |
|
209 |
@Override
|
210 |
public void configureExpressionBuilder(ExpressionBuilderConfig builder, FeatureStore store) { |
211 |
DataManager dataManager = DALLocator.getDataManager(); |
212 |
FeatureSymbolTable featureSymbolTable = dataManager.createFeatureSymbolTable(); |
213 |
|
214 |
builder.removeAllElements(); |
215 |
FeatureStoreProviderFactory storeFactory = (FeatureStoreProviderFactory) store.getProviderFactory(); |
216 |
Feature sampleFeature = store.getSampleFeature(); |
217 |
builder.setAllowedFunctions(storeFactory.allowFunction()); |
218 |
if( sampleFeature!=null ) { |
219 |
featureSymbolTable.setFeature(sampleFeature); |
220 |
builder.setPreviewSymbolTable(featureSymbolTable.createParent()); |
221 |
} |
222 |
builder.addSymbolTable(featureSymbolTable); |
223 |
FeatureStoreElement storeElement = new DefaultFeatureStoreElement2(store);
|
224 |
builder.addElement(storeElement); |
225 |
if( store.getProviderFactory().hasSQLSupport()==DataStoreProviderFactory.YES ) {
|
226 |
builder.getPreferences().setSQLCompatible(true);
|
227 |
} |
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 |
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 |
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 |
return builder;
|
294 |
} |
295 |
|
296 |
@Override
|
297 |
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 |
public JFeatureForm createJFeatureForm(FeatureStore store) throws CreateJFeatureFormException { |
306 |
JFeatureForm form = new DefaultJFeatureForm();
|
307 |
form.setStore(store); |
308 |
return form;
|
309 |
} |
310 |
|
311 |
@Override
|
312 |
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 |
public JFeatureForm createJFeatureForm(Feature feature) throws CreateJFeatureFormException { |
320 |
JFeatureForm form = new DefaultJFeatureForm();
|
321 |
form.setFeature(feature); |
322 |
return form;
|
323 |
} |
324 |
|
325 |
@Override
|
326 |
public JFeatureForm createJFeatureForm(DynFormDefinition definicion) throws CreateJFeatureFormException { |
327 |
JFeatureForm form = new DefaultJFeatureForm();
|
328 |
form.setDefinition(definicion); |
329 |
return form;
|
330 |
} |
331 |
|
332 |
@Override
|
333 |
public JFeatureTable createJFeatureTable(FeatureTableModel model) {
|
334 |
return this.createJFeatureTable(model, true); |
335 |
} |
336 |
|
337 |
@Override
|
338 |
public JFeatureTable createJFeatureTable(FeatureTableModel model, boolean isDoubleBuffered) { |
339 |
return new FeatureTablePanel(model, isDoubleBuffered); |
340 |
} |
341 |
|
342 |
@Override
|
343 |
public FeatureTableModel createEmptyFeatureTableModel(DynStruct struct) {
|
344 |
return new EmptyFeatureTableModel(struct); |
345 |
} |
346 |
|
347 |
@Override
|
348 |
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 |
@Override
|
362 |
public FeatureTableModel createFeatureTableModel(FeaturePagingHelper featurePager) {
|
363 |
return new DefaultFeatureTableModel(featurePager); |
364 |
} |
365 |
|
366 |
@Override
|
367 |
public ProjectionPickerController createProjectionPickerController(
|
368 |
JTextField txtProjection,
|
369 |
JButton btnSelectProjection
|
370 |
) { |
371 |
ProjectionPickerControllerImpl picker = new ProjectionPickerControllerImpl(txtProjection, btnSelectProjection);
|
372 |
return picker;
|
373 |
} |
374 |
|
375 |
@Override
|
376 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JComboBox combo) { |
377 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(combo, null); |
378 |
return controller;
|
379 |
} |
380 |
|
381 |
@Override
|
382 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JList list) { |
383 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(list, null); |
384 |
return controller;
|
385 |
} |
386 |
|
387 |
@Override
|
388 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JComboBox combo, Predicate<FeatureAttributeDescriptor> filter) { |
389 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(combo, filter);
|
390 |
return controller;
|
391 |
} |
392 |
|
393 |
@Override
|
394 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JList list, Predicate<FeatureAttributeDescriptor> filter) { |
395 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(list, filter);
|
396 |
return controller;
|
397 |
} |
398 |
|
399 |
@Override
|
400 |
public FeatureTypePanel createFeatureTypePanel() {
|
401 |
FeatureTypePanel panel = new DefaultFeatureTypePanel();
|
402 |
return panel;
|
403 |
} |
404 |
|
405 |
@Override
|
406 |
public FeatureTypeAttributePanel createFeatureTypeAttributePanel() {
|
407 |
FeatureTypeAttributePanel panel = new DefaultFeatureAttributePanel();
|
408 |
return panel;
|
409 |
} |
410 |
|
411 |
@Override
|
412 |
public FeatureStoreElement createFeatureStoreElement() {
|
413 |
FeatureStoreElement e = new DefaultFeatureStoreElement2(null); |
414 |
return e;
|
415 |
} |
416 |
|
417 |
@Override
|
418 |
public FeatureStoreElement createFeatureStoreElement(FeatureStore store) {
|
419 |
FeatureStoreElement e = new DefaultFeatureStoreElement2(store);
|
420 |
return e;
|
421 |
} |
422 |
|
423 |
@Override
|
424 |
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 |
public FeatureStoreSearchPanel createFeatureStoreSearchPanel(FeatureStore store) {
|
438 |
DefaultSearchPanel e = new DefaultSearchPanel(store);
|
439 |
return e;
|
440 |
} |
441 |
|
442 |
@Override
|
443 |
public final void registerStoreAction(DALActionFactory action) { |
444 |
this.featureStoreSearchActions.put(action.getName().toLowerCase(), action);
|
445 |
} |
446 |
|
447 |
@Override
|
448 |
public Collection<DALActionFactory> getStoreActions() { |
449 |
return Collections.unmodifiableCollection(this.featureStoreSearchActions.values()); |
450 |
} |
451 |
|
452 |
@Override
|
453 |
public DALActionFactory getStoreAction(String name) { |
454 |
DALActionFactory action = this.featureStoreSearchActions.get(name.toLowerCase());
|
455 |
return action;
|
456 |
} |
457 |
|
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 |
|
471 |
|
472 |
@Override
|
473 |
public PickerController<JDBCServerExplorerParameters> createJDBCConnectionPickerController(
|
474 |
JComboBox cboConnection, JButton btnConnection |
475 |
) { |
476 |
JDBCConnectionPickerController x = new JDBCConnectionPickerController(cboConnection, btnConnection);
|
477 |
return x;
|
478 |
} |
479 |
|
480 |
@Override
|
481 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureStore store) {
|
482 |
try {
|
483 |
SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(store);
|
484 |
return m;
|
485 |
} catch (DataException ex) {
|
486 |
throw new RuntimeException("Can't creatre SimpleFeaturesTableModel.", ex); |
487 |
} |
488 |
} |
489 |
|
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 |
|
506 |
@Override
|
507 |
public SimpleFeaturesTableModel createSimpleSelectedFeaturesTableModel(FeatureStore store, Expression filter) { |
508 |
SimpleFeaturesTableModelImpl m = new SimpleSelectedFeaturesTableModelImpl(store, filter);
|
509 |
return m;
|
510 |
} |
511 |
|
512 |
@Override
|
513 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureType featureType, List<String> columnNames, List<Feature> features) { |
514 |
SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(featureType, columnNames, features);
|
515 |
return m;
|
516 |
} |
517 |
|
518 |
@Override
|
519 |
public FeatureAttributeListCellRenderer createDefaultFeatureAttributeListCellRenderer() {
|
520 |
FeatureAttributeListCellRenderer r = new FeatureAttributeListCellRendererImpl();
|
521 |
return r;
|
522 |
} |
523 |
|
524 |
@Override
|
525 |
public FeatureQueryOrderPanel createFeatureStoreOrderPanel() {
|
526 |
DefaultFeatureQueryOrderPanel p = new DefaultFeatureQueryOrderPanel();
|
527 |
return p;
|
528 |
} |
529 |
|
530 |
@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 |
@Override
|
547 |
public FeatureAttributesSelectionPanel createFeatureAttributeSelectionPanel() {
|
548 |
FeatureAttributesSelectionPanel p = new DefaultFeatureAttributesSelectionPanel();
|
549 |
return p;
|
550 |
} |
551 |
|
552 |
@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 |
@Override
|
569 |
public FeaturesFormContext createFeaturesFormContext(FeatureStore store) {
|
570 |
DefaultFeaturesFormContext context = new DefaultFeaturesFormContext(store);
|
571 |
return context;
|
572 |
} |
573 |
|
574 |
@Override
|
575 |
public TreeModel createTreeModel(StoresRepository repository) { |
576 |
StoresRepositoryTreeModel model = new StoresRepositoryTreeModel(repository);
|
577 |
return model;
|
578 |
} |
579 |
|
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 |
} |
650 |
|
651 |
|