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 / actions / SelectionAddAction.java @ 44263
History | View | Annotate | Download (2.42 KB)
1 |
package org.gvsig.fmap.dal.swing.impl.searchpanel.actions; |
---|---|
2 |
|
3 |
import java.awt.event.ActionEvent; |
4 |
import javax.swing.AbstractAction; |
5 |
import javax.swing.Action; |
6 |
import org.gvsig.expressionevaluator.Expression; |
7 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
8 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
9 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
10 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
11 |
import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel; |
12 |
import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel.ActionFactory; |
13 |
import org.gvsig.tools.ToolsLocator; |
14 |
import org.gvsig.tools.i18n.I18nManager; |
15 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
16 |
import org.slf4j.Logger; |
17 |
import org.slf4j.LoggerFactory; |
18 |
|
19 |
/**
|
20 |
*
|
21 |
* @author jjdelcerro
|
22 |
*/
|
23 |
@SuppressWarnings("UseSpecificCatch") |
24 |
public class SelectionAddAction |
25 |
extends AbstractAction |
26 |
{ |
27 |
|
28 |
public static class SelectionAddActionFactory implements ActionFactory { |
29 |
|
30 |
@Override
|
31 |
public String getName() { |
32 |
return "SelectionAdd"; |
33 |
} |
34 |
|
35 |
@Override
|
36 |
public Action createAction(FeatureStoreSearchPanel panel) { |
37 |
return new SelectionAddAction(panel); |
38 |
} |
39 |
|
40 |
} |
41 |
|
42 |
private static final Logger LOGGER = LoggerFactory.getLogger(SelectionAddAction.class); |
43 |
|
44 |
private final FeatureStoreSearchPanel searchPanel; |
45 |
|
46 |
public SelectionAddAction(FeatureStoreSearchPanel searchPanel) {
|
47 |
this.searchPanel = searchPanel;
|
48 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
49 |
this.putValue(
|
50 |
Action.SHORT_DESCRIPTION,
|
51 |
i18n.getTranslation("_Add_to_selection")
|
52 |
); |
53 |
this.putValue(
|
54 |
Action.SMALL_ICON,
|
55 |
ToolsSwingLocator.getIconThemeManager().getCurrent().get("search-action-select-add")
|
56 |
); |
57 |
} |
58 |
|
59 |
@Override
|
60 |
public void actionPerformed(ActionEvent e) { |
61 |
try {
|
62 |
FeatureStore store = this.searchPanel.getStore();
|
63 |
FeatureSelection currentSelection = store.getFeatureSelection(); |
64 |
|
65 |
Expression filter = this.searchPanel.getCurrentSearch(); |
66 |
FeatureQuery query = store.createFeatureQuery(); |
67 |
query.setFilter(filter); |
68 |
FeatureSet selection = store.getFeatureSet(query); |
69 |
currentSelection.select(selection); |
70 |
} catch (Exception ex) { |
71 |
LOGGER.warn("Can't build selecction.", ex);
|
72 |
} |
73 |
} |
74 |
|
75 |
} |