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 @ 47417
History | View | Annotate | Download (41.9 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.awt.Component; |
26 |
import java.awt.event.ActionEvent; |
27 |
import java.net.URL; |
28 |
import java.util.ArrayList; |
29 |
import java.util.Collection; |
30 |
import java.util.Collections; |
31 |
import java.util.HashMap; |
32 |
import java.util.LinkedHashMap; |
33 |
import java.util.List; |
34 |
import java.util.Map; |
35 |
import java.util.function.Predicate; |
36 |
import javax.json.JsonObject; |
37 |
import javax.swing.AbstractButton; |
38 |
import javax.swing.Action; |
39 |
import javax.swing.Icon; |
40 |
import javax.swing.ImageIcon; |
41 |
import javax.swing.JButton; |
42 |
import javax.swing.JComboBox; |
43 |
import javax.swing.JList; |
44 |
import javax.swing.JOptionPane; |
45 |
import javax.swing.JPanel; |
46 |
import javax.swing.JTextField; |
47 |
import javax.swing.JTree; |
48 |
import javax.swing.text.JTextComponent; |
49 |
import org.apache.commons.lang3.StringUtils; |
50 |
import org.gvsig.expressionevaluator.Expression; |
51 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
52 |
import org.gvsig.expressionevaluator.swing.Element; |
53 |
import org.gvsig.expressionevaluator.swing.ExpressionBuilderConfig; |
54 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
55 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
56 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
57 |
import org.gvsig.expressionevaluator.swing.JExpressionBuilder; |
58 |
import org.gvsig.featureform.swing.CreateJFeatureFormException; |
59 |
import org.gvsig.featureform.swing.FeaturesFormContext; |
60 |
import org.gvsig.featureform.swing.JFeatureForm; |
61 |
import org.gvsig.featureform.swing.JFeatureReferencesForm; |
62 |
import org.gvsig.featureform.swing.JFeaturesForm; |
63 |
import org.gvsig.featureform.swing.impl.DefaultFeaturesFormContext; |
64 |
import org.gvsig.featureform.swing.impl.DefaultJFeatureForm; |
65 |
import org.gvsig.featureform.swing.impl.DefaultJFeatureReferencesForm; |
66 |
import org.gvsig.featureform.swing.impl.DefaultJFeaturesForm; |
67 |
import org.gvsig.fmap.dal.DALLocator; |
68 |
import org.gvsig.fmap.dal.DataManager; |
69 |
import static org.gvsig.fmap.dal.DataManager.DAL_USE_LABELS; |
70 |
import static org.gvsig.fmap.dal.DataManager.USE_LABELS_BOTH; |
71 |
import static org.gvsig.fmap.dal.DataManager.USE_LABELS_NO; |
72 |
import static org.gvsig.fmap.dal.DataManager.USE_LABELS_YES; |
73 |
import org.gvsig.fmap.dal.DataStore; |
74 |
import org.gvsig.fmap.dal.DataStoreParameters; |
75 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
76 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
77 |
import org.gvsig.fmap.dal.StoresRepository; |
78 |
import org.gvsig.fmap.dal.exception.DataException; |
79 |
import org.gvsig.fmap.dal.expressionevaluator.FeatureSymbolTable; |
80 |
import org.gvsig.fmap.dal.feature.Feature; |
81 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
82 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
83 |
import org.gvsig.fmap.dal.feature.FeatureReference; |
84 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
85 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
86 |
import org.gvsig.fmap.dal.feature.FeatureType; |
87 |
import org.gvsig.fmap.dal.feature.FeatureTypeDefinitionsManager; |
88 |
import org.gvsig.fmap.dal.feature.paging.FeaturePagingHelper; |
89 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
90 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
91 |
import org.gvsig.fmap.dal.swing.AbstractDALActionFactory; |
92 |
import org.gvsig.fmap.dal.swing.DALActionFactory; |
93 |
import org.gvsig.fmap.dal.swing.DALActionFactory.DALActionContext; |
94 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
95 |
import org.gvsig.fmap.dal.swing.FeatureTableModel; |
96 |
import org.gvsig.fmap.dal.swing.JFeatureTable; |
97 |
import org.gvsig.fmap.dal.swing.ProjectionPickerController; |
98 |
import org.gvsig.fmap.dal.swing.expressionevaluator.FeatureStoreElement; |
99 |
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryOrderPanel; |
100 |
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryPickerController; |
101 |
import org.gvsig.fmap.dal.swing.featuretable.SimpleFeaturesTableModel; |
102 |
import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorAndExpressionPickerController; |
103 |
import org.gvsig.fmap.dal.swing.featuretype.AttributeDescriptorPickerController; |
104 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributeListCellRenderer; |
105 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributeTableCellRenderer; |
106 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributesSelectionPanel; |
107 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureTypeAttributePanel; |
108 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureTypePanel; |
109 |
import org.gvsig.fmap.dal.swing.impl.actions.ReportStoreAction; |
110 |
import org.gvsig.fmap.dal.swing.impl.actions.ReportStoreAction.ReportStoreActionFactory; |
111 |
import org.gvsig.fmap.dal.swing.impl.actions.ReportUtils; |
112 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.DefaultFeatureStoreElement2; |
113 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.CheckTableFieldsSuggestionProviderFactory; |
114 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.DivSuggestionProviderFactory; |
115 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.QuotesForFieldNameSuggestionProviderFactory; |
116 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.StorePointFieldSuggestionProviderFactory; |
117 |
import org.gvsig.fmap.dal.swing.impl.expressionevaluator.suggestions.WrongNameFieldSuggestionProviderFactory; |
118 |
import org.gvsig.fmap.dal.swing.impl.featurequery.DefaultFeatureQueryOrderPanel; |
119 |
import org.gvsig.fmap.dal.swing.impl.featurequery.DefaultFeatureQueryPickerController; |
120 |
import org.gvsig.fmap.dal.swing.impl.featuretable.FeatureTablePanel; |
121 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleEditedFeaturesTableModelImpl; |
122 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleFeaturesTableModelImpl; |
123 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleSelectedFeaturesTableModelImpl; |
124 |
import org.gvsig.fmap.dal.swing.impl.featuretable.table.DefaultFeatureTableModel; |
125 |
import org.gvsig.fmap.dal.swing.impl.featuretable.table.EmptyFeatureTableModel; |
126 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultAttributeDescriptorAndExpressionPickerController; |
127 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultAttributeDescriptorPickerController; |
128 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureAttributePanel; |
129 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureAttributesSelectionPanel; |
130 |
import org.gvsig.fmap.dal.swing.impl.featuretype.DefaultFeatureTypePanel; |
131 |
import org.gvsig.fmap.dal.swing.impl.featuretype.FeatureAttributeListCellRendererImpl; |
132 |
import org.gvsig.fmap.dal.swing.impl.featuretype.FeatureAttributeTableCellRendererImpl; |
133 |
import org.gvsig.fmap.dal.swing.impl.jdbc.DefaultJDBCConnectionDialog; |
134 |
import org.gvsig.fmap.dal.swing.impl.jdbc.DefaultJDBCConnectionPanel; |
135 |
import org.gvsig.fmap.dal.swing.impl.jdbc.JDBCConnectionPickerControllerImpl; |
136 |
import org.gvsig.fmap.dal.swing.impl.searchpanel.DefaultSearchPanel; |
137 |
import org.gvsig.fmap.dal.swing.impl.searchpanel.DefaultSearchParameters; |
138 |
import org.gvsig.fmap.dal.swing.impl.storesrepository.StoresRepositoryControllerImpl; |
139 |
import org.gvsig.fmap.dal.swing.impl.storesrepository.StoresRepositoryTreeModelImpl; |
140 |
import org.gvsig.fmap.dal.swing.impl.visualdbmodeler.Visualdbmodeler; |
141 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionDialog; |
142 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCConnectionPanel; |
143 |
import org.gvsig.fmap.dal.swing.jdbc.JDBCServerExplorerParametersController; |
144 |
import org.gvsig.fmap.dal.swing.report.ReportAction; |
145 |
import org.gvsig.fmap.dal.swing.report.ReportActionFactory; |
146 |
import org.gvsig.fmap.dal.swing.report.ReportActionFactory.ReportCustomActionFactory; |
147 |
import org.gvsig.fmap.dal.swing.searchPostProcess.SearchPostProcessFactory; |
148 |
import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel; |
149 |
import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel.SearchResultsPanelFactory; |
150 |
import org.gvsig.fmap.dal.swing.searchpanel.SearchConditionPanel.SearchConditionPanelFactory; |
151 |
import org.gvsig.fmap.dal.swing.searchpanel.SearchParameters; |
152 |
import org.gvsig.fmap.dal.swing.storesrepository.StoresRepositoryController; |
153 |
import org.gvsig.fmap.dal.swing.storesrepository.StoresRepositoryTreeModel; |
154 |
import org.gvsig.fmap.geom.Geometry; |
155 |
import org.gvsig.tools.ToolsLocator; |
156 |
import org.gvsig.tools.dynform.DynFormDefinition; |
157 |
import org.gvsig.tools.dynform.DynFormLocator; |
158 |
import org.gvsig.tools.dynobject.DynClass; |
159 |
import org.gvsig.tools.dynobject.DynStruct; |
160 |
import org.gvsig.tools.dynobject.Tags; |
161 |
import org.gvsig.tools.exception.BaseException; |
162 |
import org.gvsig.tools.i18n.I18nManager; |
163 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
164 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
165 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
166 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
167 |
import org.gvsig.tools.util.Factory; |
168 |
import org.slf4j.Logger; |
169 |
import org.slf4j.LoggerFactory; |
170 |
|
171 |
|
172 |
/**
|
173 |
* @author fdiaz
|
174 |
*
|
175 |
*/
|
176 |
@SuppressWarnings("UseSpecificCatch") |
177 |
public class DefaultDataSwingManager implements DataSwingManager { |
178 |
|
179 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultDataSwingManager.class); |
180 |
|
181 |
private final Map<String,DALActionFactory> featureStoreActions; |
182 |
private final Map<String,SearchPostProcessFactory> searchPostProcess; |
183 |
private Map<String,SearchConditionPanelFactory> searchConditionPanelFactories; |
184 |
private Integer useLabels; |
185 |
private HashMap<String, SearchResultsPanelFactory> searchResultsPanelFactories; |
186 |
|
187 |
public DefaultDataSwingManager() {
|
188 |
this.featureStoreActions = new LinkedHashMap<>(); |
189 |
this.searchPostProcess = new HashMap<>(); |
190 |
} |
191 |
|
192 |
@Override
|
193 |
public JFeaturesForm createJFeaturesForm(FeatureStore store) throws CreateJFeatureFormException { |
194 |
try {
|
195 |
FeatureType featureType = store.getDefaultFeatureType(); |
196 |
|
197 |
DefaultJFeaturesForm form = new DefaultJFeaturesForm();
|
198 |
form.bind(store, featureType2DynClass(store, featureType), null);
|
199 |
return form;
|
200 |
|
201 |
} catch (Exception ex) { |
202 |
throw new CreateJFeatureFormException(ex); |
203 |
} |
204 |
} |
205 |
|
206 |
@Override
|
207 |
public JFeaturesForm createJFeaturesForm(FeatureStore store, FeatureQuery query) throws CreateJFeatureFormException { |
208 |
try {
|
209 |
FeatureType featureType = store.getDefaultFeatureType(); |
210 |
|
211 |
DefaultJFeaturesForm form = new DefaultJFeaturesForm();
|
212 |
form.bind(store, featureType2DynClass(store, featureType), query); |
213 |
return form;
|
214 |
|
215 |
} catch (Exception ex) { |
216 |
throw new CreateJFeatureFormException(ex); |
217 |
} |
218 |
} |
219 |
|
220 |
public DynClass featureType2DynClass(FeatureStore store, FeatureType type) {
|
221 |
FeatureTypeDefinitionsManager featureTypeDefinitionsManager = DALLocator.getFeatureTypeDefinitionsManager(); |
222 |
if( featureTypeDefinitionsManager.contains(store,type) ) {
|
223 |
// Force reload next call to get.
|
224 |
featureTypeDefinitionsManager.remove(store,type); |
225 |
} |
226 |
DynClass dynClass = featureTypeDefinitionsManager.get(store,type); |
227 |
// Force reload next call to get.
|
228 |
DynFormLocator.getDynFormManager().removeDefinition(dynClass.getName()); |
229 |
return dynClass;
|
230 |
} |
231 |
|
232 |
@Override
|
233 |
public JDBCConnectionPanel createJDBCConnectionPanel() {
|
234 |
JDBCConnectionPanel x = new DefaultJDBCConnectionPanel();
|
235 |
return x;
|
236 |
} |
237 |
|
238 |
@Override
|
239 |
public JDBCConnectionDialog createJDBCConectionDialog() {
|
240 |
JDBCConnectionDialog x = new DefaultJDBCConnectionDialog();
|
241 |
return x;
|
242 |
} |
243 |
|
244 |
@Override
|
245 |
public void configureExpressionBuilder(ExpressionBuilderConfig builder, FeatureStore store) { |
246 |
DataManager dataManager = DALLocator.getDataManager(); |
247 |
FeatureSymbolTable featureSymbolTable = dataManager.createFeatureSymbolTable(); |
248 |
|
249 |
builder.removeAllElements(); |
250 |
FeatureStoreProviderFactory storeFactory = (FeatureStoreProviderFactory) store.getProviderFactory(); |
251 |
Feature sampleFeature = store.getSampleFeature(); |
252 |
builder.setAllowedFunctions(storeFactory.allowFunction()); |
253 |
if( sampleFeature!=null ) { |
254 |
featureSymbolTable.setFeature(sampleFeature); |
255 |
builder.setPreviewSymbolTable(featureSymbolTable.createParent()); |
256 |
} |
257 |
builder.addSymbolTable(featureSymbolTable); |
258 |
FeatureStoreElement storeElement = new DefaultFeatureStoreElement2(store);
|
259 |
builder.addElement(storeElement); |
260 |
if( store.getProviderFactory().hasSQLSupport()==DataStoreProviderFactory.YES ) {
|
261 |
builder.getPreferences().setSQLCompatible(true);
|
262 |
} |
263 |
builder.addSuggestionFactory(new StorePointFieldSuggestionProviderFactory(store));
|
264 |
builder.addSuggestionFactory(new QuotesForFieldNameSuggestionProviderFactory(store));
|
265 |
builder.addSuggestionFactory(new WrongNameFieldSuggestionProviderFactory(store));
|
266 |
builder.addSuggestionFactory(new CheckTableFieldsSuggestionProviderFactory(store));
|
267 |
builder.addSuggestionFactory(new DivSuggestionProviderFactory(store));
|
268 |
} |
269 |
|
270 |
@Override
|
271 |
public void resetExpressionBuilder(ExpressionBuilderConfig builder) { |
272 |
builder.removeAllElements(); |
273 |
builder.removeAddedElements(); |
274 |
builder.setPreviewSymbolTable(ExpressionUtils.createSymbolTable()); |
275 |
} |
276 |
|
277 |
@Override
|
278 |
public void addToExpressionBuilder(ExpressionBuilderConfig builder, FeatureStore store, String name) { |
279 |
this.addToExpressionBuilder(builder, store, name, false); |
280 |
} |
281 |
|
282 |
@Override
|
283 |
public void addToExpressionBuilder(ExpressionBuilderConfig builder, FeatureStore store, String name, boolean useHostVariable) { |
284 |
// Este metodo permite a?adir mas de un store al builder llamandolo
|
285 |
// con un name distinto para cada store. En el arbol se presentaran todos
|
286 |
// los stores que se configuren en el builder.
|
287 |
// Ojo, que las expresiones creadas por estos builder no son compatible
|
288 |
// con SQL.
|
289 |
DataManager dataManager = DALLocator.getDataManager(); |
290 |
|
291 |
// Creamos el store-element y lo a?adimos al builder
|
292 |
FeatureStoreElement n = new DefaultFeatureStoreElement2(store, name, useHostVariable);
|
293 |
builder.addElement(n); |
294 |
|
295 |
// Creamos una tabla de simbolos de ejemplo basada en el store, y la
|
296 |
// a?adimos a la tabla de simbolos de previsualizacion del builder.
|
297 |
FeatureSymbolTable featureSymbolTable = dataManager.createFeatureSymbolTable(); |
298 |
Feature sampleFeature = store.getSampleFeature(); |
299 |
if( sampleFeature!=null ) { |
300 |
featureSymbolTable.setFeature(sampleFeature); |
301 |
builder.getPreviewSymbolTable().addSymbolTable(featureSymbolTable); |
302 |
} |
303 |
|
304 |
// forzamos a que al insertar campos de un store se indique siempre
|
305 |
// en nombre del store. Necesario si hay mas de un store en el builder.
|
306 |
List<Element> elements = builder.getElements(); |
307 |
for (Element item : elements) { |
308 |
if( item instanceof FeatureStoreElement ) { |
309 |
((FeatureStoreElement)item).setUseFullyQualifiedNames(true);
|
310 |
} |
311 |
} |
312 |
// Marcamos como no compatible sql las expresiones que vamos a generar.
|
313 |
builder.getPreferences().setSQLCompatible(false);
|
314 |
|
315 |
// A?adimos los generadores de sugerencias.
|
316 |
builder.addSuggestionFactory(new StorePointFieldSuggestionProviderFactory(store));
|
317 |
builder.addSuggestionFactory(new QuotesForFieldNameSuggestionProviderFactory(store));
|
318 |
builder.addSuggestionFactory(new WrongNameFieldSuggestionProviderFactory(store));
|
319 |
builder.addSuggestionFactory(new CheckTableFieldsSuggestionProviderFactory(store));
|
320 |
builder.addSuggestionFactory(new DivSuggestionProviderFactory(store));
|
321 |
} |
322 |
|
323 |
@Override
|
324 |
public JExpressionBuilder createQueryFilterExpresion(FeatureStore store) {
|
325 |
return this.createJExpressionBuilder(store); |
326 |
} |
327 |
|
328 |
@Override
|
329 |
public JExpressionBuilder createJExpressionBuilder(final FeatureStore store) { |
330 |
ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
331 |
final JExpressionBuilder builder = expressionSwingManager.createJExpressionBuilder();
|
332 |
this.configureExpressionBuilder(builder.getConfig(), store);
|
333 |
builder.expandElement( |
334 |
(Element t) -> t!=null && StringUtils.equals(t.getName(),store.getName()) |
335 |
); |
336 |
return builder;
|
337 |
} |
338 |
|
339 |
@Override
|
340 |
public ExpressionPickerController createExpressionPickerController(FeatureStore store, JTextComponent text, JButton button, JButton bookmarks, JButton history) { |
341 |
ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
342 |
ExpressionPickerController builder = expressionSwingManager.createExpressionPickerController(text, button, bookmarks, history); |
343 |
if( store !=null ) { |
344 |
this.configureExpressionBuilder(builder.getConfig(), store);
|
345 |
} |
346 |
return builder;
|
347 |
} |
348 |
|
349 |
@Override
|
350 |
public AttributeDescriptorAndExpressionPickerController createExpressionPickerController(FeatureStore store, JComboBox combo, JButton button, JButton bookmarks, JButton history) { |
351 |
DefaultAttributeDescriptorAndExpressionPickerController controller = new DefaultAttributeDescriptorAndExpressionPickerController(combo, button, bookmarks, history, null); |
352 |
if( store !=null ) { |
353 |
this.configureExpressionBuilder(controller.getConfig(), store);
|
354 |
} |
355 |
return controller;
|
356 |
} |
357 |
|
358 |
@Override
|
359 |
public JFeatureForm createJFeatureForm(FeatureStore store) throws CreateJFeatureFormException { |
360 |
JFeatureForm form = new DefaultJFeatureForm();
|
361 |
form.setStore(store); |
362 |
return form;
|
363 |
} |
364 |
|
365 |
@Override
|
366 |
public JFeatureReferencesForm createJFeatureReferencesForm(FeatureStore store, List<FeatureReference> references) throws CreateJFeatureFormException { |
367 |
JFeatureReferencesForm form = new DefaultJFeatureReferencesForm();
|
368 |
form.bind(store, references); |
369 |
return form;
|
370 |
} |
371 |
|
372 |
@Override
|
373 |
public JFeatureForm createJFeatureForm(Feature feature) throws CreateJFeatureFormException { |
374 |
JFeatureForm form = new DefaultJFeatureForm();
|
375 |
form.setFeature(feature); |
376 |
return form;
|
377 |
} |
378 |
|
379 |
@Override
|
380 |
public JFeatureForm createJFeatureForm(DynFormDefinition definicion) throws CreateJFeatureFormException { |
381 |
JFeatureForm form = new DefaultJFeatureForm();
|
382 |
form.setDefinition(definicion); |
383 |
return form;
|
384 |
} |
385 |
|
386 |
@Override
|
387 |
public JFeatureTable createJFeatureTable(FeatureTableModel model) {
|
388 |
return this.createJFeatureTable(model, true); |
389 |
} |
390 |
|
391 |
@Override
|
392 |
public JFeatureTable createJFeatureTable(FeatureTableModel model, boolean isDoubleBuffered) { |
393 |
return new FeatureTablePanel(model, isDoubleBuffered); |
394 |
} |
395 |
|
396 |
@Override
|
397 |
public FeatureTableModel createEmptyFeatureTableModel(DynStruct struct) {
|
398 |
return new EmptyFeatureTableModel(struct); |
399 |
} |
400 |
|
401 |
@Override
|
402 |
public FeatureTableModel createFeatureTableModel(FeatureStore featureStore,
|
403 |
FeatureQuery featureQuery) { |
404 |
try {
|
405 |
FeaturePagingHelper pager = DALLocator.getDataManager().createFeaturePagingHelper( |
406 |
featureStore, featureQuery, |
407 |
FeaturePagingHelper.DEFAULT_PAGE_SIZE |
408 |
); |
409 |
return this.createFeatureTableModel(pager); |
410 |
} catch (BaseException ex) {
|
411 |
throw new RuntimeException("Can't create a FeatureTableModel.", ex); |
412 |
} |
413 |
} |
414 |
|
415 |
@Override
|
416 |
public FeatureTableModel createFeatureTableModel(FeaturePagingHelper featurePager) {
|
417 |
return new DefaultFeatureTableModel(featurePager); |
418 |
} |
419 |
|
420 |
@Override
|
421 |
public ProjectionPickerController createProjectionPickerController(
|
422 |
JTextField txtProjection,
|
423 |
JButton btnSelectProjection
|
424 |
) { |
425 |
ProjectionPickerControllerImpl picker = new ProjectionPickerControllerImpl(txtProjection, btnSelectProjection);
|
426 |
return picker;
|
427 |
} |
428 |
|
429 |
@Override
|
430 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JComboBox combo) { |
431 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(combo, null); |
432 |
return controller;
|
433 |
} |
434 |
|
435 |
@Override
|
436 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JList list) { |
437 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(list, null); |
438 |
return controller;
|
439 |
} |
440 |
|
441 |
@Override
|
442 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JComboBox combo, Predicate<FeatureAttributeDescriptor> filter) { |
443 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(combo, filter);
|
444 |
return controller;
|
445 |
} |
446 |
|
447 |
@Override
|
448 |
public AttributeDescriptorPickerController createAttributeDescriptorPickerController(JList list, Predicate<FeatureAttributeDescriptor> filter) { |
449 |
AttributeDescriptorPickerController controller = new DefaultAttributeDescriptorPickerController(list, filter);
|
450 |
return controller;
|
451 |
} |
452 |
|
453 |
@Override
|
454 |
public FeatureTypePanel createFeatureTypePanel() {
|
455 |
FeatureTypePanel panel = new DefaultFeatureTypePanel();
|
456 |
return panel;
|
457 |
} |
458 |
|
459 |
@Override
|
460 |
public FeatureTypeAttributePanel createFeatureTypeAttributePanel() {
|
461 |
FeatureTypeAttributePanel panel = new DefaultFeatureAttributePanel();
|
462 |
return panel;
|
463 |
} |
464 |
|
465 |
@Override
|
466 |
public FeatureStoreElement createFeatureStoreElement() {
|
467 |
FeatureStoreElement e = new DefaultFeatureStoreElement2(null); |
468 |
return e;
|
469 |
} |
470 |
|
471 |
@Override
|
472 |
public FeatureStoreElement createFeatureStoreElement(FeatureStore store) {
|
473 |
FeatureStoreElement e = new DefaultFeatureStoreElement2(store);
|
474 |
return e;
|
475 |
} |
476 |
|
477 |
@Override
|
478 |
public ExpressionPickerController createExpressionPickerController(FeatureStore store, JTextComponent text, JButton button) { |
479 |
FeatureSymbolTable previewSymbolTable = DALLocator.getManager().createFeatureSymbolTable(); |
480 |
previewSymbolTable.setFeature(store.getSampleFeature()); |
481 |
|
482 |
ExpressionPickerController controller = ExpressionEvaluatorSwingLocator.getManager().createExpressionPickerController(text, button); |
483 |
controller.getConfig().addElement(this.createFeatureStoreElement(store));
|
484 |
controller.getConfig().setPreviewSymbolTable(previewSymbolTable); |
485 |
|
486 |
return controller;
|
487 |
} |
488 |
|
489 |
|
490 |
@Override
|
491 |
public FeatureStoreSearchPanel createFeatureStoreSearchPanel(FeatureStore store) {
|
492 |
DefaultSearchPanel e = new DefaultSearchPanel(store);
|
493 |
return e;
|
494 |
} |
495 |
|
496 |
@Override
|
497 |
public final void registerStoreAction(DALActionFactory action) { |
498 |
this.featureStoreActions.put(action.getName().toLowerCase(), action);
|
499 |
} |
500 |
|
501 |
@Override
|
502 |
public Collection<DALActionFactory> getStoreActions() { |
503 |
return Collections.unmodifiableCollection(this.featureStoreActions.values()); |
504 |
} |
505 |
|
506 |
@Override
|
507 |
public Collection<DALActionFactory> getApplicableStoreActions(DALActionContext context) { |
508 |
Collection<DALActionFactory> factories = new ArrayList<>(); |
509 |
try {
|
510 |
for (DALActionFactory factory : this.featureStoreActions.values()) { |
511 |
if (factory == null ) { |
512 |
continue;
|
513 |
} |
514 |
try {
|
515 |
if (factory.isApplicable(context)) {
|
516 |
factories.add(factory); |
517 |
} |
518 |
} catch (Exception ex) { |
519 |
LOGGER.warn("Can't access to DAL action factory " + factory.getName(), ex);
|
520 |
} |
521 |
|
522 |
} |
523 |
} catch (Exception ex) { |
524 |
LOGGER.warn("Can't get DAL action factories", ex);
|
525 |
} |
526 |
return factories;
|
527 |
} |
528 |
|
529 |
@Override
|
530 |
public DALActionFactory getStoreAction(String name) { |
531 |
DALActionFactory action = this.featureStoreActions.get(name.toLowerCase());
|
532 |
return action;
|
533 |
} |
534 |
|
535 |
@Override
|
536 |
public void setStoreAction(AbstractButton component, String name, boolean preserveLabel, DALActionContext context) { |
537 |
DALActionFactory factory = this.getStoreAction(name);
|
538 |
Action action = factory.createAction(context);
|
539 |
if( preserveLabel ) {
|
540 |
String s = component.getText();
|
541 |
component.setAction(action); |
542 |
component.setText(s); |
543 |
} else {
|
544 |
component.setAction(action); |
545 |
} |
546 |
} |
547 |
|
548 |
|
549 |
@Override
|
550 |
public JDBCServerExplorerParametersController createJDBCConnectionPickerController(
|
551 |
JComboBox cboConnection, JButton btnConnection |
552 |
) { |
553 |
JDBCConnectionPickerControllerImpl x = new JDBCConnectionPickerControllerImpl(cboConnection, btnConnection);
|
554 |
return x;
|
555 |
} |
556 |
|
557 |
@Override
|
558 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureStore store) {
|
559 |
try {
|
560 |
SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(store);
|
561 |
return m;
|
562 |
} catch (DataException ex) {
|
563 |
throw new RuntimeException("Can't creatre SimpleFeaturesTableModel.", ex); |
564 |
} |
565 |
} |
566 |
|
567 |
@Override
|
568 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureStore store, Expression filter) { |
569 |
try {
|
570 |
SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(store, filter);
|
571 |
return m;
|
572 |
} catch (DataException ex) {
|
573 |
throw new RuntimeException("Can't creatre SimpleFeaturesTableModel.", ex); |
574 |
} |
575 |
} |
576 |
|
577 |
@Override
|
578 |
public SimpleFeaturesTableModel createSimpleEditedFeaturesTableModel(FeatureStore store, Expression filter) { |
579 |
SimpleFeaturesTableModelImpl m = new SimpleEditedFeaturesTableModelImpl(store, filter);
|
580 |
return m;
|
581 |
} |
582 |
|
583 |
@Override
|
584 |
public SimpleFeaturesTableModel createSimpleSelectedFeaturesTableModel(FeatureStore store, Expression filter) { |
585 |
SimpleFeaturesTableModelImpl m = new SimpleSelectedFeaturesTableModelImpl(store, filter);
|
586 |
return m;
|
587 |
} |
588 |
|
589 |
@Override
|
590 |
public SimpleFeaturesTableModel createSimpleFeaturesTableModel(FeatureType featureType, List<String> columnNames, List<Feature> features) { |
591 |
SimpleFeaturesTableModelImpl m = new SimpleFeaturesTableModelImpl(featureType, columnNames, features);
|
592 |
return m;
|
593 |
} |
594 |
|
595 |
@Override
|
596 |
public FeatureAttributeListCellRenderer createDefaultFeatureAttributeListCellRenderer() {
|
597 |
FeatureAttributeListCellRenderer r = new FeatureAttributeListCellRendererImpl();
|
598 |
return r;
|
599 |
} |
600 |
|
601 |
@Override
|
602 |
public FeatureAttributeTableCellRenderer createDefaultFeatureAttributeTableCellRenderer() {
|
603 |
FeatureAttributeTableCellRenderer r = new FeatureAttributeTableCellRendererImpl();
|
604 |
return r;
|
605 |
} |
606 |
|
607 |
@Override
|
608 |
public FeatureQueryOrderPanel createFeatureStoreOrderPanel() {
|
609 |
DefaultFeatureQueryOrderPanel p = new DefaultFeatureQueryOrderPanel();
|
610 |
return p;
|
611 |
} |
612 |
|
613 |
@Override
|
614 |
public Iterable<SearchConditionPanelFactory> getSearchConditionPanels() { |
615 |
if( this.searchConditionPanelFactories==null ) { |
616 |
return Collections.EMPTY_LIST; |
617 |
} |
618 |
return this.searchConditionPanelFactories.values(); |
619 |
} |
620 |
|
621 |
@Override
|
622 |
public void registerSearchConditionPanel(SearchConditionPanelFactory factory) { |
623 |
if( this.searchConditionPanelFactories==null ) { |
624 |
this.searchConditionPanelFactories = new HashMap<>(); |
625 |
} |
626 |
this.searchConditionPanelFactories.put(factory.getName(), factory);
|
627 |
} |
628 |
|
629 |
@Override
|
630 |
public void registerSearchResultsPanel(SearchResultsPanelFactory factory) { |
631 |
if( this.searchResultsPanelFactories==null ) { |
632 |
this.searchResultsPanelFactories = new HashMap<>(); |
633 |
} |
634 |
this.searchResultsPanelFactories.put(factory.getName(), factory);
|
635 |
} |
636 |
|
637 |
@Override
|
638 |
public Iterable<SearchResultsPanelFactory> getSearchResultsPanels() { |
639 |
if( this.searchResultsPanelFactories==null ) { |
640 |
return Collections.EMPTY_LIST; |
641 |
} |
642 |
return this.searchResultsPanelFactories.values(); |
643 |
} |
644 |
|
645 |
@Override
|
646 |
public FeatureAttributesSelectionPanel createFeatureAttributeSelectionPanel() {
|
647 |
FeatureAttributesSelectionPanel p = new DefaultFeatureAttributesSelectionPanel();
|
648 |
return p;
|
649 |
} |
650 |
|
651 |
@Override
|
652 |
public void registerSearchPostProcess(SearchPostProcessFactory process) { |
653 |
this.searchPostProcess.put(process.getName(), process);
|
654 |
} |
655 |
|
656 |
@Override
|
657 |
public Map<String,SearchPostProcessFactory> getSearchPostProcess() { |
658 |
return this.searchPostProcess; |
659 |
} |
660 |
|
661 |
@Override
|
662 |
public SearchPostProcessFactory getSearchPostProcess(String name) { |
663 |
SearchPostProcessFactory process = this.searchPostProcess.get(name);
|
664 |
return process;
|
665 |
} |
666 |
|
667 |
@Override
|
668 |
public FeaturesFormContext createFeaturesFormContext(FeatureStore store) {
|
669 |
DefaultFeaturesFormContext context = new DefaultFeaturesFormContext(store);
|
670 |
return context;
|
671 |
} |
672 |
|
673 |
@Override
|
674 |
public StoresRepositoryTreeModel createTreeModel(StoresRepository repository) {
|
675 |
StoresRepositoryTreeModelImpl model = new StoresRepositoryTreeModelImpl(repository);
|
676 |
return model;
|
677 |
} |
678 |
|
679 |
@Override
|
680 |
public String getAttributeDescriptorLabel(FeatureAttributeDescriptor attrdesc) { |
681 |
return getAttributeDescriptorLabel(attrdesc, null); |
682 |
} |
683 |
|
684 |
@Override
|
685 |
public String getAttributeDescriptorLabel(FeatureAttributeDescriptor attrdesc, String tableName) { |
686 |
String theLabel;
|
687 |
int theUseLabels;
|
688 |
if (getUseLabels() == null) { |
689 |
Tags tags = attrdesc.getTags(); |
690 |
if (tags.has(DAL_USE_LABELS)) {
|
691 |
theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
692 |
} else {
|
693 |
if (attrdesc.getFeatureType() != null) { |
694 |
tags = attrdesc.getFeatureType().getTags(); |
695 |
theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
696 |
} else {
|
697 |
theUseLabels = USE_LABELS_NO; |
698 |
} |
699 |
} |
700 |
} else {
|
701 |
theUseLabels = getUseLabels(); |
702 |
} |
703 |
switch (theUseLabels) {
|
704 |
case USE_LABELS_BOTH:
|
705 |
if (!StringUtils.equals(attrdesc.getLocalizedLabel(), attrdesc.getName())){
|
706 |
if (StringUtils.isBlank(tableName)) {
|
707 |
theLabel = String.format("%s [%s]", attrdesc.getLocalizedLabel(), attrdesc.getName()); |
708 |
} else {
|
709 |
theLabel = String.format("%s [%s/%s]", attrdesc.getLocalizedLabel(), attrdesc.getName(), tableName); |
710 |
} |
711 |
break;
|
712 |
} |
713 |
case USE_LABELS_YES:
|
714 |
if (StringUtils.isBlank(tableName)) {
|
715 |
theLabel = attrdesc.getLocalizedLabel(); |
716 |
} else {
|
717 |
theLabel = String.format("%s [%s]", attrdesc.getLocalizedLabel(), tableName); |
718 |
} |
719 |
break;
|
720 |
default:
|
721 |
case USE_LABELS_NO:
|
722 |
if (StringUtils.isBlank(tableName)) {
|
723 |
theLabel = attrdesc.getName(); |
724 |
} else {
|
725 |
theLabel = String.format("%s [%s]", attrdesc.getName(), tableName); |
726 |
} |
727 |
break;
|
728 |
} |
729 |
return theLabel;
|
730 |
} |
731 |
|
732 |
/**
|
733 |
* @return the useLabels
|
734 |
*/
|
735 |
@Override
|
736 |
public Integer getUseLabels() { |
737 |
return useLabels;
|
738 |
} |
739 |
|
740 |
/**
|
741 |
* @param useLabels the useLabels to set
|
742 |
*/
|
743 |
@Override
|
744 |
public void setUseLabels(Integer useLabels) { |
745 |
this.useLabels = useLabels;
|
746 |
} |
747 |
|
748 |
@Override
|
749 |
public SearchParameters createFeatureStoreSearchPanelParameters() {
|
750 |
return new DefaultSearchParameters(); |
751 |
} |
752 |
|
753 |
@Override
|
754 |
public FeatureQueryPickerController createFeatureQueryPickerController(JTextComponent text, JButton button, JButton history, JButton bookmarks) { |
755 |
DefaultFeatureQueryPickerController controller = new DefaultFeatureQueryPickerController(text, button, history, bookmarks);
|
756 |
return controller;
|
757 |
} |
758 |
|
759 |
@Override
|
760 |
public StoresRepositoryController createStoresRepositoryController(JTree tree) { |
761 |
StoresRepositoryControllerImpl src = new StoresRepositoryControllerImpl(tree);
|
762 |
return src;
|
763 |
} |
764 |
|
765 |
@Override
|
766 |
public Icon getStoreGeometryIcon(FeatureStore store) { |
767 |
try {
|
768 |
if( store == null ) { |
769 |
return null; |
770 |
} |
771 |
FeatureType ft = store.getDefaultFeatureTypeQuietly(); |
772 |
if( ft == null ) { |
773 |
return null; |
774 |
} |
775 |
FeatureAttributeDescriptor geomattr = ft.getDefaultGeometryAttribute(); |
776 |
if( geomattr == null ) { |
777 |
return null; |
778 |
} |
779 |
int geometryType = geomattr.getGeomType().getType();
|
780 |
String name;
|
781 |
switch (geometryType) {
|
782 |
case Geometry.TYPES.LINE:
|
783 |
name = "store-geomtype-line";
|
784 |
break;
|
785 |
case Geometry.TYPES.POINT:
|
786 |
name = "store-geomtype-point";
|
787 |
break;
|
788 |
case Geometry.TYPES.POLYGON:
|
789 |
name = "store-geomtype-polygon";
|
790 |
break;
|
791 |
case Geometry.TYPES.MULTILINE:
|
792 |
name = "store-geomtype-multiline";
|
793 |
break;
|
794 |
case Geometry.TYPES.MULTIPOINT:
|
795 |
name = "store-geomtype-multipoint";
|
796 |
break;
|
797 |
case Geometry.TYPES.MULTIPOLYGON:
|
798 |
name = "store-geomtype-multipolygon";
|
799 |
break;
|
800 |
case Geometry.TYPES.GEOMETRY:
|
801 |
name = "store-geomtype-mix";
|
802 |
break;
|
803 |
default:
|
804 |
return null; |
805 |
} |
806 |
if (!store.isFeatureSelectionEmpty()) {
|
807 |
name = name + "-sel";
|
808 |
} |
809 |
name = name + ".png";
|
810 |
URL url = this.getClass().getResource("/storegeomtypes/" + name); |
811 |
if (url == null) { |
812 |
return null; |
813 |
} |
814 |
Icon icon = new ImageIcon(url); |
815 |
return icon;
|
816 |
} catch (Exception ex) { |
817 |
return null; |
818 |
} |
819 |
} |
820 |
|
821 |
@Override
|
822 |
public int askUserStopEditing(FeatureStore featureStore) { |
823 |
return this.askUserStopEditing(null, featureStore, true); |
824 |
} |
825 |
|
826 |
@Override
|
827 |
public int askUserStopEditing(FeatureStore featureStore, boolean allowContinue) { |
828 |
return this.askUserStopEditing(null, featureStore, allowContinue); |
829 |
} |
830 |
|
831 |
@Override
|
832 |
public int askUserStopEditing(Component parent, FeatureStore featureStore, boolean allowContinue) { |
833 |
boolean allowWrite = featureStore.allowWrite();
|
834 |
|
835 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
836 |
String message;
|
837 |
String[] options = new String[allowContinue?3:2]; |
838 |
int defaultoption;
|
839 |
|
840 |
message = "<html>"+
|
841 |
"<p>"+i18n.getTranslation("stop_edition")+"</p><br>"; |
842 |
if( allowWrite ) {
|
843 |
message = message + |
844 |
"<b>"+i18n.getTranslation("_Guardar")+": </b>"+i18n.getTranslation("_Save_changes")+"<br>"; |
845 |
options[0] = i18n.getTranslation("_Guardar"); |
846 |
defaultoption = 0;
|
847 |
} else {
|
848 |
message = message + |
849 |
"<b>"+i18n.getTranslation("_Export")+": </b>"+i18n.getTranslation("_Export_table")+"<br>"; |
850 |
options[0] = i18n.getTranslation("_Export"); |
851 |
defaultoption = allowContinue?2:0; |
852 |
} |
853 |
message = message + |
854 |
"<b>"+i18n.getTranslation("_Descartar")+": </b>"+i18n.getTranslation("_Discard_and_lose_changes")+"<br>"; |
855 |
options[1] = i18n.getTranslation("_Descartar"); |
856 |
if( allowContinue ) {
|
857 |
message = message + |
858 |
"<b>"+i18n.getTranslation("_Continuar")+": </b>"+i18n.getTranslation("_Continue_editing_without_saving")+"<br>"; |
859 |
options[2] = i18n.getTranslation("_Continuar"); |
860 |
} |
861 |
message = message + "</html>";
|
862 |
|
863 |
int resp = JOptionPane |
864 |
.showOptionDialog( |
865 |
parent, |
866 |
message, |
867 |
i18n.getTranslation("stop_edition"),
|
868 |
allowContinue?JOptionPane.YES_NO_CANCEL_OPTION:JOptionPane.YES_NO_OPTION, |
869 |
JOptionPane.QUESTION_MESSAGE, null, options, |
870 |
options[defaultoption]); |
871 |
|
872 |
switch( resp ) {
|
873 |
case 0: |
874 |
if( allowWrite )
|
875 |
return STOP_EDITING_SAVE;
|
876 |
return STOP_EDITING_EXPORT;
|
877 |
case 1: |
878 |
return STOP_EDITING_DISCARD;
|
879 |
default:
|
880 |
case 2: |
881 |
return STOP_EDITING_CONTINUE;
|
882 |
} |
883 |
} |
884 |
|
885 |
public boolean exportStore(FeatureStore store, WindowManager.MODE mode) { |
886 |
DALActionFactory exportActionFactory = null;
|
887 |
for (DALActionFactory action : this.getStoreActions()) { |
888 |
if( StringUtils.equalsIgnoreCase("Export", action.getName()) ) { |
889 |
exportActionFactory = action; |
890 |
break;
|
891 |
} |
892 |
} |
893 |
if( exportActionFactory == null ) { |
894 |
return false; |
895 |
} |
896 |
DALActionContext context = new AbstractDALActionFactory.AbstractDALActionContext("ExportActionContext") { |
897 |
@Override
|
898 |
public DataStore getStore() {
|
899 |
return store;
|
900 |
} |
901 |
}; |
902 |
context.set("WindowMode", mode);
|
903 |
Action action = exportActionFactory.createAction(context);
|
904 |
action.actionPerformed(new ActionEvent(store, 0, exportActionFactory.getName())); |
905 |
return true; |
906 |
} |
907 |
|
908 |
@Override
|
909 |
public JPanel createVisualdbModelerPanel() { |
910 |
return new Visualdbmodeler(); |
911 |
} |
912 |
|
913 |
private Map<String,ReportActionFactory> reportActionFactories; |
914 |
|
915 |
@Override
|
916 |
public void registerReportAction(ReportActionFactory factory) { |
917 |
if( this.reportActionFactories == null ) { |
918 |
this.reportActionFactories = new HashMap<>(); |
919 |
} |
920 |
this.reportActionFactories.put(factory.getName().toLowerCase(), factory);
|
921 |
} |
922 |
|
923 |
@Override
|
924 |
public ReportActionFactory getReportActionFactory(String name) { |
925 |
if( StringUtils.isBlank(name) ) {
|
926 |
return null; |
927 |
} |
928 |
return this.reportActionFactories.get(name.toLowerCase()); |
929 |
} |
930 |
|
931 |
@Override
|
932 |
public Collection<ReportActionFactory> getReportActionFactories() { |
933 |
return this.reportActionFactories.values(); |
934 |
} |
935 |
|
936 |
@Override
|
937 |
public void registerReportsCustomAction(ReportCustomActionFactory customFactory, boolean insertSeparator) { |
938 |
ReportStoreActionFactory factory = (ReportStoreActionFactory) this.getStoreAction(ReportStoreAction.ACTION_NAME);
|
939 |
factory.registerCustomAction(customFactory, insertSeparator); |
940 |
} |
941 |
|
942 |
|
943 |
public boolean connectToDatabaseWorkspace(JDBCServerExplorerParameters conn) { |
944 |
if( conn == null ) { |
945 |
return false; |
946 |
} |
947 |
DataManager dataManager = DALLocator.getDataManager(); |
948 |
DatabaseWorkspaceManager workspace = dataManager.createDatabaseWorkspaceManager(conn); |
949 |
StoresRepository repo = workspace.getStoresRepository(); |
950 |
if( hasConflictTheRepositoryWithOtherRepositoryAlreadyRegistered(repo) ) {
|
951 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
952 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
953 |
int n = dialogs.confirmDialog(
|
954 |
i18n.getTranslation("_The_name_of_some_tables_of_the_repository_coincide_with_those_of_another_repository_already_registered") +
|
955 |
" ("+repo.getLabel()+")\n" + |
956 |
i18n.getTranslation("_If_you_connect_to_this_repository_and_have_tables_or_layers_loaded_from_the_previous_repository_you_may_notice_inconsistencies_in_the_data") + "\n" + |
957 |
i18n.getTranslation("_Do_you_want_to_connect_with_the_current_repository_anyway"),
|
958 |
i18n.getTranslation("_Connect_to_repository"),
|
959 |
JOptionPane.YES_NO_OPTION,
|
960 |
JOptionPane.QUESTION_MESSAGE
|
961 |
); |
962 |
if( n!=JOptionPane.YES_OPTION ) { |
963 |
return false; |
964 |
} |
965 |
} |
966 |
workspace.connect(); |
967 |
return true; |
968 |
} |
969 |
|
970 |
private boolean hasConflictTheRepositoryWithOtherRepositoryAlreadyRegistered(StoresRepository repo) { |
971 |
DataManager dataManager = DALLocator.getDataManager(); |
972 |
StoresRepository globalRepository = dataManager.getStoresRepository(); |
973 |
for (String name : repo.keySet()) { |
974 |
DataStoreParameters params = repo.get(name); |
975 |
if( params instanceof JDBCStoreParameters ) { |
976 |
DataStoreParameters registeredParams = globalRepository.get(name); |
977 |
if( registeredParams instanceof JDBCStoreParameters ) { |
978 |
String url = ((JDBCStoreParameters) params).getUrl();
|
979 |
String registeredUrl = ((JDBCStoreParameters) registeredParams).getUrl();
|
980 |
if( !StringUtils.equals(url, registeredUrl)) {
|
981 |
return true; |
982 |
} |
983 |
} |
984 |
} |
985 |
} |
986 |
return false; |
987 |
} |
988 |
|
989 |
@Override
|
990 |
public List<JsonObject> getReports(FeatureStore store) { |
991 |
return ReportUtils.getReports(store);
|
992 |
} |
993 |
|
994 |
@Override
|
995 |
public List<ReportAction> getReportActions(DataStore store) { |
996 |
return ReportUtils.getReportActions(store);
|
997 |
} |
998 |
|
999 |
@Override
|
1000 |
public List<ReportAction> getReportActions(DataStore store, Predicate filter) { |
1001 |
return ReportUtils.getReportActions(store, filter);
|
1002 |
} |
1003 |
} |
1004 |
|