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 |
package org.gvsig.export.app.extension; |
---|---|
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.FeatureStore; |
9 |
import org.gvsig.fmap.dal.swing.AbstractDALActionFactory; |
10 |
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 |
import org.gvsig.fmap.dal.swing.DALActionFactory.DALActionContext; |
18 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
19 |
|
20 |
/**
|
21 |
*
|
22 |
* @author jjdelcerro
|
23 |
*/
|
24 |
public class FeatureStoreSearchExportAction |
25 |
extends AbstractAction |
26 |
{ |
27 |
|
28 |
public static class FeatureStoreSearchExportActionFactory extends AbstractDALActionFactory { |
29 |
|
30 |
public static final String ACTION_NAME = "Export"; |
31 |
|
32 |
public FeatureStoreSearchExportActionFactory() {
|
33 |
super(ACTION_NAME);
|
34 |
} |
35 |
|
36 |
@Override
|
37 |
public Action createAction(DALActionContext context) { |
38 |
return new FeatureStoreSearchExportAction(context); |
39 |
} |
40 |
|
41 |
public static void selfRegister() { |
42 |
DataSwingManager dalSwingManager = DALSwingLocator.getSwingManager(); |
43 |
dalSwingManager.registerStoreAction(new FeatureStoreSearchExportActionFactory());
|
44 |
} |
45 |
|
46 |
} |
47 |
|
48 |
private static final Logger LOGGER = LoggerFactory.getLogger(FeatureStoreSearchExportAction.class); |
49 |
|
50 |
private final DALActionContext context; |
51 |
|
52 |
public FeatureStoreSearchExportAction(DALActionContext context) {
|
53 |
this.context = context;
|
54 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
55 |
this.putValue(
|
56 |
Action.ACTION_COMMAND_KEY,
|
57 |
FeatureStoreSearchExportActionFactory.ACTION_NAME |
58 |
); |
59 |
this.putValue(
|
60 |
Action.SHORT_DESCRIPTION,
|
61 |
i18n.getTranslation("_Export")
|
62 |
); |
63 |
this.putValue(
|
64 |
Action.SMALL_ICON,
|
65 |
ToolsSwingLocator.getIconThemeManager().getCurrent().get("storeaction-export")
|
66 |
); |
67 |
} |
68 |
|
69 |
@Override
|
70 |
public void actionPerformed(ActionEvent e) { |
71 |
if( !(this.context.getStore() instanceof FeatureStore) ) { |
72 |
return;
|
73 |
} |
74 |
ExportTable exportTable = new ExportTable();
|
75 |
WindowManager.MODE windowMode; |
76 |
try {
|
77 |
windowMode = (WindowManager.MODE) this.context.get("WindowMode"); |
78 |
} catch(Throwable t) { |
79 |
windowMode = null;
|
80 |
} |
81 |
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 |
} |
98 |
|
99 |
|
100 |
} |