svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.exportto.app / org.gvsig.exportto.app.mainplugin / src / main / java / org / gvsig / export / app / extension / FeatureStoreSearchExportAction.java @ 47422
History | View | Annotate | Download (3.23 KB)
1 | 44263 | jjdelcerro | package org.gvsig.export.app.extension; |
---|---|---|---|
2 | |||
3 | import java.awt.event.ActionEvent; |
||
4 | import javax.swing.AbstractAction; |
||
5 | import javax.swing.Action; |
||
6 | 47419 | fdiaz | import org.gvsig.expressionevaluator.Expression; |
7 | import org.gvsig.fmap.dal.feature.FeatureQuery; |
||
8 | 44281 | jjdelcerro | import org.gvsig.fmap.dal.feature.FeatureStore; |
9 | import org.gvsig.fmap.dal.swing.AbstractDALActionFactory; |
||
10 | 44263 | jjdelcerro | import org.gvsig.fmap.dal.swing.DALSwingLocator; |
11 | import org.gvsig.fmap.dal.swing.DataSwingManager; |
||
12 | import org.gvsig.tools.ToolsLocator; |
||
13 | import org.gvsig.tools.i18n.I18nManager; |
||
14 | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
||
15 | import org.slf4j.Logger; |
||
16 | import org.slf4j.LoggerFactory; |
||
17 | 44281 | jjdelcerro | import org.gvsig.fmap.dal.swing.DALActionFactory.DALActionContext; |
18 | 46814 | jjdelcerro | import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
19 | 44263 | jjdelcerro | |
20 | /**
|
||
21 | *
|
||
22 | * @author jjdelcerro
|
||
23 | */
|
||
24 | public class FeatureStoreSearchExportAction |
||
25 | extends AbstractAction |
||
26 | { |
||
27 | |||
28 | 44281 | jjdelcerro | public static class FeatureStoreSearchExportActionFactory extends AbstractDALActionFactory { |
29 | 44263 | jjdelcerro | |
30 | 44281 | jjdelcerro | public static final String ACTION_NAME = "Export"; |
31 | |||
32 | public FeatureStoreSearchExportActionFactory() {
|
||
33 | super(ACTION_NAME);
|
||
34 | 44263 | jjdelcerro | } |
35 | 44281 | jjdelcerro | |
36 | 44263 | jjdelcerro | @Override
|
37 | 44281 | jjdelcerro | public Action createAction(DALActionContext context) { |
38 | return new FeatureStoreSearchExportAction(context); |
||
39 | 44263 | jjdelcerro | } |
40 | |||
41 | public static void selfRegister() { |
||
42 | DataSwingManager dalSwingManager = DALSwingLocator.getSwingManager(); |
||
43 | 44281 | jjdelcerro | dalSwingManager.registerStoreAction(new FeatureStoreSearchExportActionFactory());
|
44 | 44263 | jjdelcerro | } |
45 | |||
46 | } |
||
47 | |||
48 | private static final Logger LOGGER = LoggerFactory.getLogger(FeatureStoreSearchExportAction.class); |
||
49 | |||
50 | 44281 | jjdelcerro | private final DALActionContext context; |
51 | 44263 | jjdelcerro | |
52 | 44281 | jjdelcerro | public FeatureStoreSearchExportAction(DALActionContext context) {
|
53 | this.context = context;
|
||
54 | 44263 | jjdelcerro | I18nManager i18n = ToolsLocator.getI18nManager(); |
55 | this.putValue(
|
||
56 | 44281 | jjdelcerro | Action.ACTION_COMMAND_KEY,
|
57 | FeatureStoreSearchExportActionFactory.ACTION_NAME |
||
58 | ); |
||
59 | this.putValue(
|
||
60 | 44263 | jjdelcerro | Action.SHORT_DESCRIPTION,
|
61 | i18n.getTranslation("_Export")
|
||
62 | ); |
||
63 | this.putValue(
|
||
64 | Action.SMALL_ICON,
|
||
65 | 47422 | jjdelcerro | ToolsSwingLocator.getIconThemeManager().getCurrent().get("storeaction-export")
|
66 | 44263 | jjdelcerro | ); |
67 | } |
||
68 | |||
69 | @Override
|
||
70 | public void actionPerformed(ActionEvent e) { |
||
71 | 44281 | jjdelcerro | if( !(this.context.getStore() instanceof FeatureStore) ) { |
72 | return;
|
||
73 | 46104 | omartinez | } |
74 | 44263 | jjdelcerro | ExportTable exportTable = new ExportTable();
|
75 | 46814 | jjdelcerro | WindowManager.MODE windowMode; |
76 | try {
|
||
77 | windowMode = (WindowManager.MODE) this.context.get("WindowMode"); |
||
78 | } catch(Throwable t) { |
||
79 | windowMode = null;
|
||
80 | } |
||
81 | 47419 | fdiaz | FeatureStore store = (FeatureStore) this.context.getStore();
|
82 | Expression filterForSelecteds = this.context.getFilterForSelecteds(); |
||
83 | if(filterForSelecteds == null){ |
||
84 | exportTable.showExport( |
||
85 | store, |
||
86 | this.context.getQuery(),
|
||
87 | windowMode |
||
88 | ); |
||
89 | } else {
|
||
90 | FeatureQuery query = store.createFeatureQuery(filterForSelecteds); |
||
91 | exportTable.showExport( |
||
92 | store, |
||
93 | query, |
||
94 | windowMode |
||
95 | ); |
||
96 | } |
||
97 | 44263 | jjdelcerro | } |
98 | |||
99 | |||
100 | } |