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