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