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 / searchpanel / DefaultSearchPanel.java @ 45166
History | View | Annotate | Download (41.7 KB)
1 |
package org.gvsig.fmap.dal.swing.impl.searchpanel; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Cursor; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.FlowLayout; |
7 |
import java.awt.event.ActionEvent; |
8 |
import java.awt.event.ActionListener; |
9 |
import java.awt.event.ComponentAdapter; |
10 |
import java.awt.event.ComponentEvent; |
11 |
import java.net.URL; |
12 |
import java.text.DateFormat; |
13 |
import java.text.SimpleDateFormat; |
14 |
import java.util.ArrayList; |
15 |
import java.util.Calendar; |
16 |
import java.util.Collection; |
17 |
import java.util.Collections; |
18 |
import java.util.Date; |
19 |
import java.util.HashMap; |
20 |
import java.util.List; |
21 |
import java.util.Map; |
22 |
import javax.swing.AbstractAction; |
23 |
import javax.swing.Action; |
24 |
import static javax.swing.Action.ACTION_COMMAND_KEY; |
25 |
import static javax.swing.Action.NAME; |
26 |
import javax.swing.BorderFactory; |
27 |
import javax.swing.ImageIcon; |
28 |
import javax.swing.JButton; |
29 |
import javax.swing.JComponent; |
30 |
import javax.swing.JOptionPane; |
31 |
import javax.swing.SwingUtilities; |
32 |
import javax.swing.event.ListSelectionEvent; |
33 |
import javax.swing.event.ListSelectionListener; |
34 |
import javax.swing.table.DefaultTableModel; |
35 |
import javax.swing.table.TableModel; |
36 |
import org.apache.commons.io.FilenameUtils; |
37 |
import org.apache.commons.lang.mutable.MutableObject; |
38 |
import org.apache.commons.lang3.StringUtils; |
39 |
import org.apache.commons.lang3.mutable.MutableLong; |
40 |
import org.gvsig.configurableactions.ConfigurableActionsMamager; |
41 |
import org.gvsig.expressionevaluator.Expression; |
42 |
import org.gvsig.expressionevaluator.ExpressionBuilder; |
43 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
44 |
import static org.gvsig.fmap.dal.DataManager.DAL_USE_LABELS; |
45 |
import static org.gvsig.fmap.dal.DataManager.USE_LABELS_BOTH; |
46 |
import static org.gvsig.fmap.dal.DataManager.USE_LABELS_NO; |
47 |
import static org.gvsig.fmap.dal.DataManager.USE_LABELS_YES; |
48 |
import org.gvsig.fmap.dal.DataStore; |
49 |
import org.gvsig.fmap.dal.DataStoreProviderFactory; |
50 |
import org.gvsig.fmap.dal.complements.Search; |
51 |
import org.gvsig.fmap.dal.feature.Feature; |
52 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
53 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
54 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
55 |
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory; |
56 |
import org.gvsig.fmap.dal.feature.FeatureType; |
57 |
import org.gvsig.fmap.dal.feature.paging.FacadeOfAFeaturePagingHelper; |
58 |
import org.gvsig.fmap.dal.swing.AbstractDALActionFactory.AbstractDALActionContext; |
59 |
import org.gvsig.fmap.dal.swing.DALActionFactory; |
60 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
61 |
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryCalculatedColumnsPanel; |
62 |
import org.gvsig.fmap.dal.swing.impl.featuretable.SimpleFeaturesTableModel; |
63 |
import org.gvsig.fmap.dal.swing.impl.featurequery.DefaultFeatureQueryGroupByPanel; |
64 |
import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel; |
65 |
import org.gvsig.fmap.dal.swing.searchpanel.SearchConditionPanel; |
66 |
import org.gvsig.fmap.dal.swing.searchpanel.SearchConditionPanel.SearchConditionPanelFactory; |
67 |
import org.gvsig.tools.ToolsLocator; |
68 |
import org.gvsig.tools.dataTypes.DataType; |
69 |
import org.gvsig.tools.dynobject.Tags; |
70 |
import org.gvsig.tools.i18n.I18nManager; |
71 |
import org.gvsig.tools.swing.api.ActionListenerSupport; |
72 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
73 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
74 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
75 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
76 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
77 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
78 |
import org.gvsig.tools.util.ToolsUtilLocator; |
79 |
import org.slf4j.Logger; |
80 |
import org.slf4j.LoggerFactory; |
81 |
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryGroupByPanel; |
82 |
import org.gvsig.fmap.dal.swing.featurequery.FeatureQueryOrderPanel; |
83 |
import org.gvsig.fmap.dal.swing.impl.featurequery.DefaultFeatureQueryCalculatedColumnsPanel; |
84 |
import org.gvsig.fmap.dal.swing.featuretype.FeatureAttributesSelectionPanel; |
85 |
import org.gvsig.fmap.dal.swing.searchpanel.SearchParameters; |
86 |
import org.gvsig.tools.bookmarksandhistory.Bookmarks; |
87 |
import org.gvsig.tools.bookmarksandhistory.History; |
88 |
import org.gvsig.tools.dispose.Disposable; |
89 |
import org.gvsig.tools.dispose.DisposeUtils; |
90 |
import org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue; |
91 |
import static org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue.ID_GETVALUE; |
92 |
import static org.gvsig.tools.swing.api.bookmarkshistory.ActionEventWithCurrentValue.ID_SETVALUE; |
93 |
import org.gvsig.tools.swing.api.bookmarkshistory.BookmarksController; |
94 |
import org.gvsig.tools.swing.api.bookmarkshistory.HistoryController; |
95 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
96 |
|
97 |
/**
|
98 |
*
|
99 |
* @author jjdelcerro
|
100 |
*/
|
101 |
@SuppressWarnings({"UseSpecificCatch"}) |
102 |
public class DefaultSearchPanel |
103 |
extends DefaultSearchPanelView
|
104 |
implements FeatureStoreSearchPanel {
|
105 |
|
106 |
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultSearchPanel.class); |
107 |
|
108 |
static /* friend */ Integer useLabels = null; |
109 |
private BookmarksController bookmarksController;
|
110 |
private HistoryController historyController;
|
111 |
private FeatureQuery lastQuery;
|
112 |
|
113 |
public static class UseLabelsYesAction extends AbstractAction { |
114 |
|
115 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
116 |
public UseLabelsYesAction() {
|
117 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
118 |
|
119 |
this.putValue(NAME, i18n.getTranslation("_Use_labels")); |
120 |
this.putValue(ACTION_COMMAND_KEY, "UseLabelsYes"); |
121 |
} |
122 |
|
123 |
@Override
|
124 |
public Object getValue(String key) { |
125 |
if (NAME.equals(key)) {
|
126 |
// Cuando se registra la accion aun no se han cargado las traducciones
|
127 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
128 |
return i18n.getTranslation("_Use_labels"); |
129 |
} |
130 |
return super.getValue(key); |
131 |
} |
132 |
|
133 |
@Override
|
134 |
public void actionPerformed(ActionEvent ae) { |
135 |
DefaultSearchPanel.useLabels = USE_LABELS_YES; |
136 |
} |
137 |
} |
138 |
|
139 |
public static class UseLabelsNoAction extends AbstractAction { |
140 |
|
141 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
142 |
public UseLabelsNoAction() {
|
143 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
144 |
this.putValue(NAME, i18n.getTranslation("_Use_names")); |
145 |
this.putValue(ACTION_COMMAND_KEY, "UseLabelsNo"); |
146 |
} |
147 |
|
148 |
@Override
|
149 |
public Object getValue(String key) { |
150 |
if (NAME.equals(key)) {
|
151 |
// Cuando se registra la accion aun no se han cargado las traducciones
|
152 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
153 |
return i18n.getTranslation("_Use_names"); |
154 |
} |
155 |
return super.getValue(key); |
156 |
} |
157 |
|
158 |
@Override
|
159 |
public void actionPerformed(ActionEvent ae) { |
160 |
DefaultSearchPanel.useLabels = USE_LABELS_NO; |
161 |
} |
162 |
} |
163 |
|
164 |
public static class UseLabelsBothAction extends AbstractAction { |
165 |
|
166 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
167 |
public UseLabelsBothAction() {
|
168 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
169 |
|
170 |
this.putValue(NAME, i18n.getTranslation("_Use_labels_and_names")); |
171 |
this.putValue(ACTION_COMMAND_KEY, "UseLabelsBoth"); |
172 |
} |
173 |
|
174 |
@Override
|
175 |
public Object getValue(String key) { |
176 |
if (NAME.equals(key)) {
|
177 |
// Cuando se registra la accion aun no se han cargado las traducciones
|
178 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
179 |
return i18n.getTranslation("_Use_labels_and_names"); |
180 |
} |
181 |
return super.getValue(key); |
182 |
} |
183 |
|
184 |
@Override
|
185 |
public void actionPerformed(ActionEvent ae) { |
186 |
DefaultSearchPanel.useLabels = USE_LABELS_BOTH; |
187 |
} |
188 |
} |
189 |
|
190 |
public static class SelectColumnsAction extends AbstractAction { |
191 |
|
192 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
193 |
public SelectColumnsAction() {
|
194 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
195 |
|
196 |
this.putValue(NAME, i18n.getTranslation("_Select_columns_to_display")); |
197 |
this.putValue(ACTION_COMMAND_KEY, "SelectColumns"); |
198 |
} |
199 |
|
200 |
@Override
|
201 |
public Object getValue(String key) { |
202 |
if (NAME.equals(key)) {
|
203 |
// Cuando se registra la accion aun no se han cargado las traducciones
|
204 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
205 |
return i18n.getTranslation("_Select_columns_to_display"); |
206 |
} |
207 |
return super.getValue(key); |
208 |
} |
209 |
|
210 |
@Override
|
211 |
public void actionPerformed(ActionEvent ae) { |
212 |
DefaultSearchPanel panel = (DefaultSearchPanel) ae.getSource(); |
213 |
panel.doSelectResultColumnNames(); |
214 |
} |
215 |
} |
216 |
|
217 |
public static class CalculatedColumnsAction extends AbstractAction { |
218 |
|
219 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
220 |
public CalculatedColumnsAction() {
|
221 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
222 |
|
223 |
this.putValue(NAME, i18n.getTranslation("_Calculated_columns")); |
224 |
this.putValue(ACTION_COMMAND_KEY, "CalculatedColumns"); |
225 |
} |
226 |
|
227 |
@Override
|
228 |
public Object getValue(String key) { |
229 |
if (NAME.equals(key)) {
|
230 |
// Cuando se registra la accion aun no se han cargado las traducciones
|
231 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
232 |
return i18n.getTranslation("_Calculated_columns"); |
233 |
} |
234 |
return super.getValue(key); |
235 |
} |
236 |
|
237 |
@Override
|
238 |
public void actionPerformed(ActionEvent ae) { |
239 |
DefaultSearchPanel panel = (DefaultSearchPanel) ae.getSource(); |
240 |
panel.doCalculatedColumns(); |
241 |
} |
242 |
} |
243 |
|
244 |
public static class GroupByAction extends AbstractAction { |
245 |
|
246 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
247 |
public GroupByAction() {
|
248 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
249 |
|
250 |
this.putValue(NAME, i18n.getTranslation("_Group_by")); |
251 |
this.putValue(ACTION_COMMAND_KEY, "GroupBy"); |
252 |
} |
253 |
|
254 |
@Override
|
255 |
public Object getValue(String key) { |
256 |
if (NAME.equals(key)) {
|
257 |
// Cuando se registra la accion aun no se han cargado las traducciones
|
258 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
259 |
return i18n.getTranslation("_Group_by"); |
260 |
} |
261 |
return super.getValue(key); |
262 |
} |
263 |
|
264 |
@Override
|
265 |
public void actionPerformed(ActionEvent ae) { |
266 |
DefaultSearchPanel panel = (DefaultSearchPanel) ae.getSource(); |
267 |
panel.doGroupBy(); |
268 |
} |
269 |
} |
270 |
|
271 |
public static class OrderByAction extends AbstractAction { |
272 |
|
273 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
274 |
public OrderByAction() {
|
275 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
276 |
|
277 |
this.putValue(NAME, i18n.getTranslation("_Order_by")); |
278 |
this.putValue(ACTION_COMMAND_KEY, "SelectOrderBy"); |
279 |
} |
280 |
|
281 |
@Override
|
282 |
public Object getValue(String key) { |
283 |
if (NAME.equals(key)) {
|
284 |
// Cuando se registra la accion aun no se han cargado las traducciones
|
285 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
286 |
return i18n.getTranslation("_Order_by"); |
287 |
} |
288 |
return super.getValue(key); |
289 |
} |
290 |
|
291 |
@Override
|
292 |
public void actionPerformed(ActionEvent ae) { |
293 |
DefaultSearchPanel panel = (DefaultSearchPanel) ae.getSource(); |
294 |
panel.doOrderBy(); |
295 |
} |
296 |
} |
297 |
|
298 |
private class ActionButtons { |
299 |
|
300 |
private final DALActionFactory factory; |
301 |
private final Action action; |
302 |
private final JButton button; |
303 |
|
304 |
public ActionButtons(DALActionFactory factory, Action action, JButton button) { |
305 |
this.factory = factory;
|
306 |
this.action = action;
|
307 |
this.button = button;
|
308 |
} |
309 |
} |
310 |
|
311 |
public static class SearchActionContext extends AbstractDALActionContext { |
312 |
|
313 |
private final DefaultSearchPanel panel; |
314 |
|
315 |
public SearchActionContext(DefaultSearchPanel panel) {
|
316 |
super(FeatureStoreSearchPanel.ACTION_CONTEXT_NAME);
|
317 |
this.panel = panel;
|
318 |
} |
319 |
|
320 |
@Override
|
321 |
public DataStore getStore() {
|
322 |
return this.panel.getStore(); |
323 |
} |
324 |
|
325 |
@Override
|
326 |
public JComponent getActionButton(String actionName) { |
327 |
return this.panel.getActionButton(actionName); |
328 |
} |
329 |
|
330 |
@Override
|
331 |
public int getSelectedsCount() { |
332 |
return this.panel.getSelectedFeatureCount(); |
333 |
} |
334 |
|
335 |
@Override
|
336 |
public Expression getFilterForSelecteds() { |
337 |
return this.panel.getFilterForSelectedFeature(); |
338 |
} |
339 |
|
340 |
@Override
|
341 |
public FeatureQuery getQuery() {
|
342 |
return this.panel.getQuery(); |
343 |
} |
344 |
} |
345 |
|
346 |
private FeatureStore store;
|
347 |
private final ActionListenerSupport acctionListeners; |
348 |
private final Map<String, ActionButtons> actions; |
349 |
private boolean showActions = true; |
350 |
private DefaultSearchParameters parameters;
|
351 |
|
352 |
private List<SearchConditionPanel> conditionPanels; |
353 |
|
354 |
private static final int PANEL_SIMPLIFIED = 0; |
355 |
private static final int PANEL_ADVANCED = 1; |
356 |
private static final String BOOKMARKSANDHISTORY_NAME = "SearchPanel"; |
357 |
private final Bookmarks<Object> bookmarks; |
358 |
private final History<Object> history; |
359 |
|
360 |
public DefaultSearchPanel(FeatureStore store) {
|
361 |
this.store = store;
|
362 |
this.acctionListeners = ToolsSwingLocator.getToolsSwingManager().createActionListenerSupport();
|
363 |
this.actions = new HashMap<>(); |
364 |
this.parameters = new DefaultSearchParameters(); |
365 |
FeatureQuery featureQuery = this.store.createFeatureQuery();
|
366 |
featureQuery.retrievesAllAttributes(); |
367 |
this.parameters.setQuery(featureQuery);
|
368 |
|
369 |
Search search = (Search) ToolsLocator.getComplementsManager().get( |
370 |
Search.COMPLEMENT_MANE, getFeatureType() |
371 |
); |
372 |
List<Search.OrderedAttribute> attributos = search.getOrderedAttributes(
|
373 |
Search.BASIC_TYPES_FILTER, |
374 |
Search.STR_INT_LONG_LABEL_ORDER, |
375 |
12
|
376 |
); |
377 |
for (Search.OrderedAttribute attrdesc : attributos) {
|
378 |
this.parameters.getResultColumnNames().add(attrdesc.getDescriptor().getName());
|
379 |
} |
380 |
this.bookmarks = ToolsLocator.getBookmarksAndHistoryManager().getBookmarksGroup(BOOKMARKSANDHISTORY_NAME);
|
381 |
this.history = ToolsLocator.getBookmarksAndHistoryManager().getHistoryGroup(BOOKMARKSANDHISTORY_NAME);
|
382 |
} |
383 |
|
384 |
@Override
|
385 |
public void dispose() { |
386 |
DisposeUtils.disposeQuietly(store); |
387 |
TableModel m = this.tblResults.getModel(); |
388 |
if( m instanceof Disposable ) { |
389 |
DisposeUtils.disposeQuietly((Disposable) m); |
390 |
} |
391 |
this.store = null; |
392 |
this.tblResults.setModel(new DefaultTableModel()); |
393 |
} |
394 |
|
395 |
@Override
|
396 |
public JComponent asJComponent() { |
397 |
if (this.conditionPanels == null) { |
398 |
this.initComponents();
|
399 |
} |
400 |
return this; |
401 |
} |
402 |
|
403 |
private void addActions() { |
404 |
if (!this.showActions) { |
405 |
return;
|
406 |
} |
407 |
this.pnlActions.removeAll();
|
408 |
this.pnlActions.setLayout(new FlowLayout(FlowLayout.TRAILING, 8, 4)); |
409 |
SearchActionContext actionContext = new SearchActionContext(this); |
410 |
Collection<DALActionFactory> factories = DALSwingLocator.getSwingManager().getStoreActions();
|
411 |
for (DALActionFactory factory : factories) {
|
412 |
Action action = factory.createAction(actionContext);
|
413 |
JButton button = new JButton(action); |
414 |
this.actions.put(factory.getName(), new ActionButtons(factory, action, button)); |
415 |
button.setBorder(BorderFactory.createEmptyBorder());
|
416 |
button.setBorderPainted(false);
|
417 |
button.setFocusPainted(false);
|
418 |
button.setContentAreaFilled(false);
|
419 |
button.setCursor(new Cursor(Cursor.HAND_CURSOR)); |
420 |
this.pnlActions.add(button);
|
421 |
} |
422 |
this.pnlActions.revalidate();
|
423 |
this.pnlActions.repaint();
|
424 |
} |
425 |
|
426 |
@Override
|
427 |
public void addActionListener(ActionListener listener) { |
428 |
this.acctionListeners.addActionListener(listener);
|
429 |
} |
430 |
|
431 |
@Override
|
432 |
public ActionListener[] getActionListeners() { |
433 |
return this.acctionListeners.getActionListeners(); |
434 |
} |
435 |
|
436 |
@Override
|
437 |
public void removeActionListener(ActionListener listener) { |
438 |
this.acctionListeners.removeActionListener(listener);
|
439 |
} |
440 |
|
441 |
@Override
|
442 |
public void removeAllActionListener() { |
443 |
this.acctionListeners.removeAllActionListener();
|
444 |
} |
445 |
|
446 |
@Override
|
447 |
public void fireActionEvent(ActionEvent event) { |
448 |
this.acctionListeners.fireActionEvent(event);
|
449 |
} |
450 |
|
451 |
@Override
|
452 |
public boolean hasActionListeners() { |
453 |
return this.acctionListeners.hasActionListeners(); |
454 |
} |
455 |
|
456 |
private void initComponents() { |
457 |
this.conditionPanels = new ArrayList<>(); |
458 |
|
459 |
ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager(); |
460 |
swingManager.translate(this.tabSearchMode);
|
461 |
swingManager.translate(this.btnSearch);
|
462 |
swingManager.translate(this.btnClear);
|
463 |
swingManager.translate(this.lblExpressionDeBusqueda);
|
464 |
swingManager.translate(this.btnAddAccumulatedFilter);
|
465 |
swingManager.translate(this.btnRemoveAccumulatedFilter);
|
466 |
swingManager.translate(this.btnViewAccumulatedFilter);
|
467 |
|
468 |
ConfigurableActionsMamager cfgActionsManager = ToolsUtilLocator.getConfigurableActionsMamager(); |
469 |
JComponent c = cfgActionsManager.getConfigurableActionsComponent(CONFIGURABLE_PANEL_ID, this); |
470 |
this.pnlCfgActions.setLayout(new BorderLayout(0, 0)); |
471 |
this.pnlCfgActions.add(c, BorderLayout.CENTER); |
472 |
|
473 |
this.conditionPanels.add(
|
474 |
new SearchConditionPanelSimplified(
|
475 |
store, |
476 |
btnAddAccumulatedFilter, |
477 |
btnRemoveAccumulatedFilter, |
478 |
btnViewAccumulatedFilter, |
479 |
lblField1, |
480 |
lblExtraFields1, |
481 |
lblRelationalOperator1, |
482 |
cboValue1, |
483 |
lblLogicalOperators1, |
484 |
lblField2, |
485 |
lblExtraFields2, |
486 |
lblRelationalOperator2, |
487 |
cboValue2, |
488 |
lblLogicalOperators2, |
489 |
lblField3, |
490 |
lblExtraFields3, |
491 |
lblRelationalOperator3, |
492 |
cboValue3, |
493 |
lblLogicalOperators3, |
494 |
lblField4, |
495 |
lblExtraFields4, |
496 |
lblRelationalOperator4, |
497 |
cboValue4, |
498 |
null
|
499 |
) |
500 |
); |
501 |
this.conditionPanels.add(
|
502 |
new SearchConditionPanelAdvanced(
|
503 |
this.store,
|
504 |
txtAdvancedExpression, |
505 |
btnAdvancedExpression, |
506 |
btnAdvancedExpressionHistory, |
507 |
btnAdvancedExpressionBookmarks |
508 |
) |
509 |
); |
510 |
for (SearchConditionPanelFactory factory : DALSwingLocator.getManager().getSearchConditionPanels()) {
|
511 |
String factoryName = "unknown"; |
512 |
try {
|
513 |
factoryName = factory.getName(); |
514 |
if (factory.isApplicable(store)) {
|
515 |
SearchConditionPanel panel = factory.create(this);
|
516 |
this.conditionPanels.add(panel);
|
517 |
this.tabSearchMode.add(factory.getName(), panel.asJComponent());
|
518 |
} |
519 |
} catch (Throwable th) { |
520 |
LOGGER.warn("Can't create search panel '" + factoryName + "'."); |
521 |
} |
522 |
} |
523 |
|
524 |
this.btnSearch.addActionListener((ActionEvent e) -> { |
525 |
search(); |
526 |
}); |
527 |
|
528 |
this.tblResults.getSelectionModel().addListSelectionListener((ListSelectionEvent e) -> { |
529 |
for (ActionButtons actionButton : actions.values()) {
|
530 |
if (actionButton.action instanceof ListSelectionListener) { |
531 |
((ListSelectionListener) actionButton.action).valueChanged(e);
|
532 |
} |
533 |
} |
534 |
}); |
535 |
this.btnClear.addActionListener((ActionEvent e) -> { |
536 |
clear(); |
537 |
}); |
538 |
addActions(); |
539 |
|
540 |
swingManager.createTableColumnAdjuster(tblResults); |
541 |
|
542 |
this.setPreferredSize(new Dimension(DEFAULT_WIDTH, DEFAULT_HEIGHT)); |
543 |
|
544 |
this.bookmarksController = ToolsSwingLocator.getToolsSwingManager().createBookmarksController(this.bookmarks, btnBookmarks); |
545 |
this.historyController = ToolsSwingLocator.getToolsSwingManager().createHistoryController(this.history, btnHistory); |
546 |
|
547 |
this.historyController.setFilter(null); |
548 |
|
549 |
ActionListener bookmarksAndHistoryListener = new ActionListener() { |
550 |
@Override
|
551 |
public void actionPerformed(ActionEvent e) { |
552 |
ActionEventWithCurrentValue<DefaultSearchParameters> b = (ActionEventWithCurrentValue<DefaultSearchParameters>) e; |
553 |
switch (b.getID()) {
|
554 |
case ID_GETVALUE:
|
555 |
DefaultSearchParameters actualParams = (DefaultSearchParameters) fetch(null);
|
556 |
b.setCurrentValue(actualParams); |
557 |
break;
|
558 |
|
559 |
case ID_SETVALUE:
|
560 |
if (b.getCurrentValue() == null) { |
561 |
return;
|
562 |
} |
563 |
DefaultSearchParameters searchParams; |
564 |
try {
|
565 |
searchParams = b.getCurrentValue().getCopy(); |
566 |
} catch (Exception ex) { |
567 |
LOGGER.warn("Not been able to clone export parameters", ex);
|
568 |
return;
|
569 |
} |
570 |
clear(); |
571 |
put(searchParams); |
572 |
break;
|
573 |
} |
574 |
|
575 |
} |
576 |
}; |
577 |
this.historyController.addActionListener(bookmarksAndHistoryListener);
|
578 |
this.bookmarksController.addActionListener(bookmarksAndHistoryListener);
|
579 |
this.addComponentListener(new ComponentAdapter() { |
580 |
@Override
|
581 |
public void componentHidden(ComponentEvent e) { |
582 |
dispose(); |
583 |
} |
584 |
}); |
585 |
search(); |
586 |
} |
587 |
|
588 |
private FeatureType getFeatureType() {
|
589 |
try {
|
590 |
return store.getDefaultFeatureType();
|
591 |
} catch (Exception ex) { |
592 |
throw new RuntimeException("Can't retrieve the feature type.", ex); |
593 |
} |
594 |
} |
595 |
|
596 |
@Override
|
597 |
public void setEnabled(boolean enabled) { |
598 |
if (this.conditionPanels == null) { |
599 |
this.initComponents();
|
600 |
} |
601 |
for (SearchConditionPanel conditionPanel : conditionPanels) {
|
602 |
conditionPanel.setEnabled(enabled); |
603 |
} |
604 |
|
605 |
this.btnClear.setEnabled(enabled);
|
606 |
this.btnSearch.setEnabled(enabled);
|
607 |
for (ActionButtons actionButton : actions.values()) {
|
608 |
actionButton.action.setEnabled(enabled); |
609 |
} |
610 |
} |
611 |
|
612 |
@Override
|
613 |
public void clear() { |
614 |
if (this.conditionPanels == null) { |
615 |
return;
|
616 |
} |
617 |
for (SearchConditionPanel conditionPanel : conditionPanels) {
|
618 |
conditionPanel.clear(); |
619 |
} |
620 |
} |
621 |
|
622 |
@Override
|
623 |
public FeatureQuery getLastQuery() {
|
624 |
return this.lastQuery; |
625 |
} |
626 |
|
627 |
public boolean isValid(StringBuilder message) { |
628 |
int searchMode = this.tabSearchMode.getSelectedIndex(); |
629 |
SearchConditionPanel panel = this.conditionPanels.get(searchMode);
|
630 |
boolean valid = panel.isValid(message);
|
631 |
return valid;
|
632 |
} |
633 |
|
634 |
@Override
|
635 |
public void search() { |
636 |
final MutableObject model = new MutableObject(null); |
637 |
|
638 |
StringBuilder message = new StringBuilder(); |
639 |
if (!this.isValid(message)) { |
640 |
ThreadSafeDialogsManager dialogManager = ToolsSwingLocator.getThreadSafeDialogsManager(); |
641 |
dialogManager.messageDialog( |
642 |
"_The_specified_search_condition_is_not_valid",
|
643 |
"_Search",
|
644 |
JOptionPane.WARNING_MESSAGE
|
645 |
); |
646 |
return;
|
647 |
} |
648 |
lblMsg.setText(ToolsLocator.getI18nManager().getTranslation("_Searching")+"..."); |
649 |
setEnabled(false);
|
650 |
Thread th = new Thread(() -> { |
651 |
FeatureQuery myQuery = null;
|
652 |
SearchParameters searchParams; |
653 |
try {
|
654 |
searchParams = this.fetch(this.parameters.getCopy()); // esto lo actualiza a la ultima // decidir si se devuelve clonado |
655 |
Date date = Calendar.getInstance().getTime(); |
656 |
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); |
657 |
String strDate = dateFormat.format(date);
|
658 |
searchParams.setName("Params: " + strDate);
|
659 |
} catch (Exception ex) { |
660 |
LOGGER.warn("Not able to create search parameters.", ex);
|
661 |
return;
|
662 |
} |
663 |
|
664 |
final MutableLong rowCount=new MutableLong(); |
665 |
try {
|
666 |
final List<Feature> features; |
667 |
|
668 |
myQuery = this.getQuery().getCopy();
|
669 |
features = store.getFeatures(myQuery, 20);
|
670 |
FacadeOfAFeaturePagingHelper facade = (FacadeOfAFeaturePagingHelper) features; |
671 |
FeatureType ftype = facade.getFeaturePagingHelper().getFeatureSet().getDefaultFeatureType(); |
672 |
// al modelo le pasamos el ftype de esas features
|
673 |
SimpleFeaturesTableModel tableModel = new SimpleFeaturesTableModel(
|
674 |
ftype, |
675 |
searchParams.getResultColumnNames(), |
676 |
features |
677 |
); |
678 |
model.setValue(tableModel); |
679 |
rowCount.setValue(tableModel.getRowCount()); |
680 |
} catch (Exception ex) { |
681 |
LOGGER.warn("Search not able to be executed. Can't get features or create table model", ex);
|
682 |
} finally {
|
683 |
SwingUtilities.invokeLater(() -> {
|
684 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
685 |
TableModel oldmodel = tblResults.getModel();
|
686 |
SimpleFeaturesTableModel m = (SimpleFeaturesTableModel) model.getValue(); |
687 |
tblResults.setModel(m); |
688 |
if( oldmodel instanceof SimpleFeaturesTableModel ) { |
689 |
((SimpleFeaturesTableModel)oldmodel).dispose(); |
690 |
} |
691 |
if( m.hasErrors() ) {
|
692 |
lblMsg.setText("_Errors_occurred_during_search");
|
693 |
} else {
|
694 |
lblMsg.setText(String.format("%d " + i18n.getTranslation("_elements"), rowCount.getValue())); |
695 |
} |
696 |
setEnabled(true);
|
697 |
}); |
698 |
if (this.parameters != null && this.parameters.getQuery() != null) { |
699 |
this.history.add(searchParams);
|
700 |
} |
701 |
} |
702 |
}); |
703 |
th.start(); |
704 |
} |
705 |
|
706 |
public void setResultColumnNames(List<String> names) { |
707 |
this.parameters.getResultColumnNames().clear();
|
708 |
this.parameters.getResultColumnNames().addAll(names);
|
709 |
if (this.conditionPanels == null) { |
710 |
return;
|
711 |
} |
712 |
SimpleFeaturesTableModel model; |
713 |
model = (SimpleFeaturesTableModel) this.tblResults.getModel();
|
714 |
List<Feature> features = store.getFeatures(this.parameters.getQuery()); |
715 |
FacadeOfAFeaturePagingHelper facade = (FacadeOfAFeaturePagingHelper) features; |
716 |
FeatureType ftype = facade.getFeaturePagingHelper().getFeatureSet().getDefaultFeatureType(); |
717 |
model = new SimpleFeaturesTableModel(
|
718 |
ftype, |
719 |
this.parameters.getResultColumnNames(),
|
720 |
features |
721 |
); |
722 |
tblResults.setModel(model); |
723 |
} |
724 |
|
725 |
@Override
|
726 |
public boolean setFilter(Expression filter) { |
727 |
try {
|
728 |
if (this.conditionPanels == null) { |
729 |
this.initComponents();
|
730 |
} |
731 |
if (ExpressionUtils.isPhraseEmpty(filter)) {
|
732 |
this.clear();
|
733 |
return true; |
734 |
} |
735 |
int panel = 0; |
736 |
int selected = PANEL_ADVANCED;
|
737 |
for (SearchConditionPanel conditionPanel : conditionPanels) {
|
738 |
if (panel != PANEL_ADVANCED && conditionPanel.set(filter)) {
|
739 |
selected = panel; |
740 |
} |
741 |
panel++; |
742 |
} |
743 |
this.tabSearchMode.setSelectedIndex(selected);
|
744 |
|
745 |
// SimpleFeaturesTableModel model = new SimpleFeaturesTableModel(this.getStore());
|
746 |
// tblResults.setModel(model);
|
747 |
// lblMsg.setText("");
|
748 |
return true; |
749 |
} catch (Exception ex) { |
750 |
LOGGER.warn("Can't set current search", ex);
|
751 |
return false; |
752 |
} |
753 |
} |
754 |
|
755 |
@Override
|
756 |
public List<SearchConditionPanel> getConditionPanels() { |
757 |
return Collections.unmodifiableList(this.conditionPanels); |
758 |
} |
759 |
|
760 |
@Override
|
761 |
public SearchConditionPanel getConditionPanel(String name) { |
762 |
for (SearchConditionPanel panel : conditionPanels) {
|
763 |
if (StringUtils.equalsIgnoreCase(name, panel.getFactory().getName())) {
|
764 |
return panel;
|
765 |
} |
766 |
} |
767 |
return null; |
768 |
} |
769 |
|
770 |
@Override
|
771 |
public Expression getFilterForSelectedFeature() { |
772 |
if (this.conditionPanels == null) { |
773 |
return null; |
774 |
} |
775 |
int selectedRow = this.tblResults.getSelectedRow(); |
776 |
if (selectedRow < 0) { |
777 |
return null; |
778 |
} |
779 |
try {
|
780 |
List<Feature> features = ((SimpleFeaturesTableModel) this.tblResults.getModel()).getFeatures(); |
781 |
Feature feature = features.get(selectedRow); |
782 |
|
783 |
ExpressionBuilder builder = ExpressionUtils.createExpressionBuilder(); |
784 |
FeatureType ftype = this.store.getDefaultFeatureType();
|
785 |
for (FeatureAttributeDescriptor attrdesc : ftype.getPrimaryKey()) {
|
786 |
builder.and( |
787 |
builder.eq( |
788 |
builder.column(attrdesc.getName()), |
789 |
builder.constant(feature.get(attrdesc.getName())) |
790 |
) |
791 |
); |
792 |
} |
793 |
Expression filter = ExpressionUtils.createExpression(builder.toString());
|
794 |
return filter;
|
795 |
} catch (Exception ex) { |
796 |
LOGGER.warn("Can't build search for the selected feature.", ex);
|
797 |
return null; |
798 |
} |
799 |
} |
800 |
|
801 |
@Override
|
802 |
public FeatureStore getStore() {
|
803 |
return store;
|
804 |
} |
805 |
|
806 |
private void doOrderBy() { |
807 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
808 |
WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
809 |
FeatureQueryOrderPanel orderPanel = DALSwingLocator.getDataSwingManager().createFeatureStoreOrderPanel(); |
810 |
orderPanel.setStore(store); |
811 |
orderPanel.put(parameters.getQuery()); |
812 |
Dialog dialog = windowManager.createDialog(
|
813 |
orderPanel.asJComponent(), |
814 |
i18n.getTranslation("_Select_order"),
|
815 |
null,
|
816 |
WindowManager_v2.BUTTONS_OK_CANCEL |
817 |
); |
818 |
dialog.addActionListener((ActionEvent e) -> {
|
819 |
if (dialog.getAction() == WindowManager_v2.BUTTON_OK) {
|
820 |
orderPanel.fetch(this.parameters.getQuery());
|
821 |
search(); |
822 |
} |
823 |
}); |
824 |
dialog.show(WindowManager.MODE.DIALOG); |
825 |
|
826 |
} |
827 |
|
828 |
@Override
|
829 |
public ImageIcon loadImage(String imageName) { |
830 |
String name = FilenameUtils.getBaseName(imageName);
|
831 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getDefault(); |
832 |
if (theme.exists(name)) {
|
833 |
return theme.get(name);
|
834 |
} |
835 |
URL url = this.getClass().getResource(name + ".png"); |
836 |
if (url == null) { |
837 |
return null; |
838 |
} |
839 |
return new ImageIcon(url); |
840 |
} |
841 |
|
842 |
@Override
|
843 |
public int getSelectedFeatureCount() { |
844 |
if (this.conditionPanels == null) { |
845 |
return 0; |
846 |
} |
847 |
return this.tblResults.getSelectedRowCount(); |
848 |
} |
849 |
|
850 |
@Override
|
851 |
public JComponent getActionButton(String name) { |
852 |
ActionButtons actionButton = this.actions.get(name);
|
853 |
if (actionButton == null) { |
854 |
return null; |
855 |
} |
856 |
return actionButton.button;
|
857 |
} |
858 |
|
859 |
@Override
|
860 |
public void setShowActions(boolean showActions) { |
861 |
this.showActions = showActions;
|
862 |
} |
863 |
|
864 |
@Override
|
865 |
public boolean isShowActions() { |
866 |
return this.showActions; |
867 |
} |
868 |
|
869 |
public static String getAttributeDescriptorLabel(FeatureAttributeDescriptor attrdesc, String tableName) { |
870 |
String theLabel;
|
871 |
int theUseLabels;
|
872 |
if (useLabels == null) { |
873 |
Tags tags = attrdesc.getTags(); |
874 |
if (tags.has(DAL_USE_LABELS)) {
|
875 |
theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
876 |
} else {
|
877 |
tags = attrdesc.getFeatureType().getTags(); |
878 |
theUseLabels = tags.getInt(DAL_USE_LABELS, USE_LABELS_NO); |
879 |
} |
880 |
} else {
|
881 |
theUseLabels = useLabels; |
882 |
} |
883 |
switch (theUseLabels) {
|
884 |
case USE_LABELS_YES:
|
885 |
if (StringUtils.isBlank(tableName)) {
|
886 |
theLabel = attrdesc.getLocalizedLabel(); |
887 |
} else {
|
888 |
theLabel = String.format("%s [%s]", attrdesc.getLocalizedLabel(), tableName); |
889 |
} |
890 |
break;
|
891 |
default:
|
892 |
case USE_LABELS_NO:
|
893 |
if (StringUtils.isBlank(tableName)) {
|
894 |
theLabel = attrdesc.getName(); |
895 |
} else {
|
896 |
theLabel = String.format("%s [%s]", attrdesc.getName(), tableName); |
897 |
} |
898 |
break;
|
899 |
case USE_LABELS_BOTH:
|
900 |
if (StringUtils.isBlank(tableName)) {
|
901 |
theLabel = String.format("%s [%s]", attrdesc.getLocalizedLabel(), attrdesc.getName()); |
902 |
} else {
|
903 |
theLabel = String.format("%s [%s/%s]", attrdesc.getLocalizedLabel(), attrdesc.getName(), tableName); |
904 |
} |
905 |
break;
|
906 |
} |
907 |
return theLabel;
|
908 |
} |
909 |
|
910 |
private void doCalculatedColumns() { |
911 |
WindowManager_v2 winmanager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
912 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
913 |
final FeatureQueryCalculatedColumnsPanel panel = new DefaultFeatureQueryCalculatedColumnsPanel(); |
914 |
panel.setStore(this.store);
|
915 |
panel.put(this.parameters.getQuery());
|
916 |
final Dialog dialog = winmanager.createDialog( |
917 |
panel.asJComponent(), |
918 |
i18n.getTranslation("_Calculated_columns"),
|
919 |
null,
|
920 |
WindowManager_v2.BUTTONS_OK_CANCEL |
921 |
); |
922 |
dialog.addActionListener((ActionEvent e) -> {
|
923 |
if (dialog.getAction() == WindowManager_v2.BUTTONS_OK) {
|
924 |
panel.fetch(this.parameters.getQuery());
|
925 |
search(); |
926 |
} |
927 |
}); |
928 |
dialog.show(WindowManager.MODE.DIALOG); |
929 |
} |
930 |
|
931 |
private void doGroupBy() { |
932 |
DataStoreProviderFactory dataFactory = this.store.getProviderFactory();
|
933 |
int allowGroupBy = ((FeatureStoreProviderFactory) dataFactory).allowGroupBy();
|
934 |
if (allowGroupBy != DataType.YES) {
|
935 |
// FIXME: mensaje al usaurio.
|
936 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
937 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
938 |
dialogs.messageDialog( |
939 |
i18n.getTranslation("_The_group_function_is_not_available_for_this_table"),
|
940 |
i18n.getTranslation("_Information"),
|
941 |
JOptionPane.INFORMATION_MESSAGE
|
942 |
); |
943 |
return;
|
944 |
} |
945 |
|
946 |
WindowManager_v2 winmanager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
947 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
948 |
final FeatureQueryGroupByPanel panel = new DefaultFeatureQueryGroupByPanel(); |
949 |
panel.setStore(this.store);
|
950 |
panel.put(this.parameters.getQuery());
|
951 |
final Dialog dialog = winmanager.createDialog( |
952 |
panel.asJComponent(), |
953 |
i18n.getTranslation("_Select_group_columns_and_aggregate_functions"),
|
954 |
null,
|
955 |
WindowManager_v2.BUTTONS_OK_CANCEL |
956 |
); |
957 |
dialog.addActionListener((ActionEvent e) -> {
|
958 |
if (dialog.getAction() == WindowManager_v2.BUTTONS_OK) {
|
959 |
panel.fetch(this.parameters.getQuery());
|
960 |
search(); |
961 |
} |
962 |
}); |
963 |
dialog.show(WindowManager.MODE.DIALOG); |
964 |
} |
965 |
|
966 |
private void doSelectResultColumnNames() { |
967 |
WindowManager_v2 winmanager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
968 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
969 |
final FeatureAttributesSelectionPanel panel = DALSwingLocator.getManager().createFeatureAttributeSelectionPanel();
|
970 |
panel.allowCalculatedAttributes(false);
|
971 |
FeatureType ftype = this.getFeatureType();
|
972 |
try {
|
973 |
Feature f = store.findFirst(this.parameters.getQuery());
|
974 |
if( f!=null ) { |
975 |
ftype = f.getType(); |
976 |
} |
977 |
} catch (Throwable ex) { |
978 |
LOGGER.warn("Can't retrieve the feature type from the first feature.",ex);
|
979 |
} |
980 |
panel.setFeatureType(ftype); |
981 |
panel.setSelectedNames(this.parameters.getResultColumnNames());
|
982 |
final Dialog dialog = winmanager.createDialog( |
983 |
panel.asJComponent(), |
984 |
i18n.getTranslation("_Select_the_columns_to_display"),
|
985 |
null,
|
986 |
WindowManager_v2.BUTTONS_OK_CANCEL |
987 |
); |
988 |
dialog.addActionListener((ActionEvent e) -> {
|
989 |
if (dialog.getAction() == WindowManager_v2.BUTTONS_OK) {
|
990 |
this.setResultColumnNames(panel.getSelectedNames());
|
991 |
} |
992 |
}); |
993 |
dialog.show(WindowManager.MODE.DIALOG); |
994 |
} |
995 |
|
996 |
@Override
|
997 |
public void put(SearchParameters inParams) { |
998 |
for (SearchConditionPanel conditionPanel : this.conditionPanels) { |
999 |
try {
|
1000 |
conditionPanel.put(inParams); |
1001 |
} catch (Exception ex) { |
1002 |
LOGGER.warn("Can't open panel", ex);
|
1003 |
} |
1004 |
} |
1005 |
this.parameters = (DefaultSearchParameters) inParams;
|
1006 |
|
1007 |
} |
1008 |
|
1009 |
private FeatureQuery getQuery() {
|
1010 |
FeatureQuery query; |
1011 |
try {
|
1012 |
int searchMode = this.tabSearchMode.getSelectedIndex(); |
1013 |
SearchConditionPanel panel = this.conditionPanels.get(searchMode);
|
1014 |
Expression filter = panel.get();
|
1015 |
if (searchMode != PANEL_ADVANCED) {
|
1016 |
this.conditionPanels.get(PANEL_ADVANCED).set(filter);
|
1017 |
} |
1018 |
query = (FeatureQuery) this.parameters.getQuery().clone();
|
1019 |
query.retrievesAllAttributes(); |
1020 |
if (ExpressionUtils.isPhraseEmpty(filter)) {
|
1021 |
return query;
|
1022 |
} |
1023 |
query.setFilter(filter); |
1024 |
query.retrievesAllAttributes(); |
1025 |
return query;
|
1026 |
} catch (Exception ex) { |
1027 |
LOGGER.warn("Can't build query.", ex);
|
1028 |
return null; |
1029 |
} |
1030 |
} |
1031 |
|
1032 |
@Override
|
1033 |
public SearchParameters fetch(SearchParameters outParams) {
|
1034 |
// Actualiza el fquery del parameters con los paneles
|
1035 |
for (SearchConditionPanel conditionPanel : conditionPanels) {
|
1036 |
try {
|
1037 |
conditionPanel.fetch(this.parameters);
|
1038 |
} catch (Exception ex) { |
1039 |
LOGGER.warn("Panel not able to fetch values", ex);
|
1040 |
} |
1041 |
} |
1042 |
|
1043 |
// Actualiza el filtro con el panel activo
|
1044 |
int searchMode = this.tabSearchMode.getSelectedIndex(); |
1045 |
SearchConditionPanel panel = this.conditionPanels.get(searchMode);
|
1046 |
Expression filter = panel.get();
|
1047 |
if (searchMode != PANEL_ADVANCED) {
|
1048 |
this.conditionPanels.get(PANEL_ADVANCED).set(filter);
|
1049 |
} |
1050 |
FeatureQuery query = (FeatureQuery) this.parameters.getQuery();
|
1051 |
this.lastQuery = query.getCopy();
|
1052 |
query.retrievesAllAttributes(); |
1053 |
query.clearFilter(); |
1054 |
if (!ExpressionUtils.isPhraseEmpty(filter)) {
|
1055 |
query.setFilter(filter); |
1056 |
query.retrievesAllAttributes(); |
1057 |
} |
1058 |
|
1059 |
if (outParams == null) { |
1060 |
return this.parameters.getCopy(); |
1061 |
} |
1062 |
outParams.copyFrom(this.parameters.getCopy());
|
1063 |
return outParams;
|
1064 |
} |
1065 |
|
1066 |
public static void selfRegister() { |
1067 |
String[][] iconNames = new String[][]{ |
1068 |
new String[]{"dalswing", "featurestore-column"}, |
1069 |
new String[]{"dalswing", "featurestore-foreing-key"}, |
1070 |
new String[]{"dalswing", "featurestore-table"}, |
1071 |
new String[]{"dalswing", "search-action-showform"}, |
1072 |
new String[]{"dalswing", "search-action-select"}, |
1073 |
new String[]{"dalswing", "search-action-select-add"}, |
1074 |
new String[]{"dalswing", "search-action-select-filter"} |
1075 |
}; |
1076 |
IconTheme theme = ToolsSwingLocator.getIconThemeManager().getCurrent(); |
1077 |
for (String[] icon : iconNames) { |
1078 |
URL url = DefaultSearchPanel.class.getResource(icon[1] + ".png"); |
1079 |
theme.registerDefault("DALSwing", icon[0], icon[1], null, url); |
1080 |
} |
1081 |
|
1082 |
ConfigurableActionsMamager cfgActionsManager = ToolsUtilLocator.getConfigurableActionsMamager(); |
1083 |
cfgActionsManager.addConfigurableAction(CONFIGURABLE_PANEL_ID, new UseLabelsYesAction());
|
1084 |
cfgActionsManager.addConfigurableAction(CONFIGURABLE_PANEL_ID, new UseLabelsNoAction());
|
1085 |
cfgActionsManager.addConfigurableAction(CONFIGURABLE_PANEL_ID, new UseLabelsBothAction());
|
1086 |
cfgActionsManager.addConfigurableAction(CONFIGURABLE_PANEL_ID, new SelectColumnsAction());
|
1087 |
cfgActionsManager.addConfigurableAction(CONFIGURABLE_PANEL_ID, new CalculatedColumnsAction());
|
1088 |
cfgActionsManager.addConfigurableAction(CONFIGURABLE_PANEL_ID, new GroupByAction());
|
1089 |
cfgActionsManager.addConfigurableAction(CONFIGURABLE_PANEL_ID, new OrderByAction());
|
1090 |
} |
1091 |
} |