Revision 44263 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/ExportTableExtension.java
ExportTableExtension.java | ||
---|---|---|
23 | 23 |
*/ |
24 | 24 |
package org.gvsig.export.app.extension; |
25 | 25 |
|
26 |
import java.awt.Dimension; |
|
27 |
import javax.swing.JComponent; |
|
28 |
import javax.swing.JOptionPane; |
|
26 |
import javax.swing.Action; |
|
29 | 27 |
import org.gvsig.andami.IconThemeHelper; |
30 | 28 |
import org.gvsig.andami.plugins.Extension; |
31 | 29 |
import org.gvsig.app.ApplicationLocator; |
32 | 30 |
import org.gvsig.app.ApplicationManager; |
33 |
import org.gvsig.app.project.Project; |
|
34 |
import org.gvsig.app.project.ProjectManager; |
|
35 | 31 |
import org.gvsig.app.project.documents.table.TableDocument; |
36 | 32 |
import org.gvsig.app.project.documents.table.TableManager; |
37 |
import org.gvsig.export.ExportLocator; |
|
38 |
import org.gvsig.export.ExportManager; |
|
39 |
import org.gvsig.export.ExportProcess; |
|
40 |
import org.gvsig.export.Filter; |
|
41 |
import org.gvsig.export.spi.ExportServiceFactory; |
|
42 |
import org.gvsig.export.swing.ExportFinishListenerAdapter; |
|
43 |
import org.gvsig.export.swing.ExportSwingLocator; |
|
44 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
45 |
import org.gvsig.tools.ToolsLocator; |
|
46 |
import org.gvsig.tools.i18n.I18nManager; |
|
47 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
48 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
49 |
import org.gvsig.export.swing.ExportSwingManager; |
|
50 |
import org.gvsig.export.swing.JExportProcessPanel; |
|
51 |
import org.gvsig.fmap.dal.DALLocator; |
|
52 |
import org.gvsig.fmap.dal.DataManager; |
|
53 |
import org.gvsig.fmap.dal.OpenDataStoreParameters; |
|
33 |
import org.gvsig.export.app.extension.FeatureStoreSearchExportAction.FeatureStoreSearchExportActionFactory; |
|
34 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
35 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
36 |
import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel; |
|
54 | 37 |
|
55 | 38 |
/** |
56 | 39 |
* @author gvSIG Team |
... | ... | |
67 | 50 |
@Override |
68 | 51 |
public void postInitialize() { |
69 | 52 |
super.postInitialize(); |
53 |
FeatureStoreSearchExportActionFactory.selfRegister(); |
|
70 | 54 |
} |
71 |
|
|
55 |
|
|
72 | 56 |
@Override |
73 | 57 |
public void execute(String actionCommand) { |
74 | 58 |
ApplicationManager application = ApplicationLocator.getManager(); |
... | ... | |
76 | 60 |
if( tableDoc == null ) { |
77 | 61 |
return; |
78 | 62 |
} |
79 |
showExport(tableDoc.getStore()); |
|
63 |
ExportTable exportTable = new ExportTable(); |
|
64 |
exportTable.showExport(tableDoc.getStore(), null); |
|
80 | 65 |
} |
81 | 66 |
|
82 |
private void showExport(FeatureStore featureStore) { |
|
83 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
84 |
ExportManager manager = ExportLocator.getManager(); |
|
85 |
ExportSwingManager swingManager = ExportSwingLocator.getSwingManager(); |
|
86 |
|
|
87 |
final ExportProcess process = manager.createProcess(); |
|
88 |
process.setSourceFeatureStore(featureStore); |
|
89 |
process.setContextProjection(null); |
|
90 |
process.setSourceProjection(null); |
|
91 |
process.setSourceTransformation(null); |
|
92 |
|
|
93 |
JExportProcessPanel panel = swingManager.createJExportProcessPanel( |
|
94 |
process, |
|
95 |
new Filter<ExportServiceFactory>() { |
|
96 |
@Override |
|
97 |
public boolean apply(ExportServiceFactory factory) { |
|
98 |
return factory.hasTabularSupport(); |
|
99 |
} |
|
100 |
} |
|
101 |
); |
|
102 |
panel.addFinishListener(new ExportFinishListenerAdapter() { |
|
103 |
@Override |
|
104 |
public void finished(JExportProcessPanel exportPanel) { |
|
105 |
doAddTable(process); |
|
106 |
} |
|
107 |
}); |
|
108 |
JComponent component = panel.asJComponent(); |
|
109 |
component.setPreferredSize(new Dimension(component.getPreferredSize().width, 530)); |
|
110 |
|
|
111 |
WindowManager winmgr = ToolsSwingLocator.getWindowManager(); |
|
112 |
winmgr.showWindow( |
|
113 |
panel.asJComponent(), |
|
114 |
i18n.getTranslation("_Export_to"), |
|
115 |
WindowManager.MODE.WINDOW |
|
116 |
); |
|
117 |
} |
|
118 |
|
|
119 |
private void doAddTable(ExportProcess process) { |
|
120 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
121 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
122 |
|
|
123 |
int n = application.confirmDialog( |
|
124 |
i18n.getTranslation("_Add_new_table_to_current_project"), |
|
125 |
i18n.getTranslation("_Export"), |
|
126 |
JOptionPane.YES_NO_OPTION, |
|
127 |
JOptionPane.QUESTION_MESSAGE, |
|
128 |
"AddExportedTableToProject" |
|
129 |
); |
|
130 |
if( n != JOptionPane.YES_OPTION ) { |
|
131 |
return; |
|
132 |
} |
|
133 |
try { |
|
134 |
DataManager dataManager = DALLocator.getDataManager(); |
|
135 |
ProjectManager projectManager = application.getProjectManager(); |
|
136 |
Project project = application.getCurrentProject(); |
|
137 |
for (OpenDataStoreParameters params : process.getTargetOpenStoreParameters()) { |
|
138 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
|
139 |
params.getDataStoreName(), |
|
140 |
params |
|
141 |
); |
|
142 |
TableDocument tableDocument = (TableDocument) projectManager.createDocument( |
|
143 |
TableManager.TYPENAME, |
|
144 |
store.getName() |
|
145 |
); |
|
146 |
tableDocument.setStore(store); |
|
147 |
project.addDocument(tableDocument); |
|
148 |
} |
|
149 |
application.messageDialog( |
|
150 |
i18n.getTranslation("_Table_added_to_project"), |
|
151 |
null, |
|
152 |
i18n.getTranslation("_Export"), |
|
153 |
JOptionPane.QUESTION_MESSAGE, |
|
154 |
"ExportedTableAddedToProject" |
|
155 |
); |
|
156 |
} catch (Exception ex) { |
|
157 |
logger.warn("Can't add exported layer to view",ex); |
|
158 |
application.messageDialog( |
|
159 |
i18n.getTranslation("_Cant_add_exported_table_to_project"), |
|
160 |
null, |
|
161 |
i18n.getTranslation("_Export"), |
|
162 |
JOptionPane.WARNING_MESSAGE, |
|
163 |
"CantAddExportedTableToProject" |
|
164 |
); |
|
165 |
} |
|
166 |
} |
|
167 |
|
|
168 | 67 |
@Override |
169 | 68 |
public boolean isEnabled() { |
170 | 69 |
return true; |
Also available in: Unified diff