svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.exportto / org.gvsig.exportto.swing / org.gvsig.exportto.swing.prov / org.gvsig.exportto.swing.prov.jdbc / src / main / java / org / gvsig / export / jdbc / swing / panels / SelectTableNamePanel.java @ 44198
History | View | Annotate | Download (16.4 KB)
1 | 40559 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | 40435 | jjdelcerro | *
|
4 | 40559 | jjdelcerro | * Copyright (C) 2007-2013 gvSIG Association.
|
5 | 40435 | jjdelcerro | *
|
6 | 41486 | jjdelcerro | * This program is free software; you can redistribute it and/or modify it under
|
7 | * the terms of the GNU General Public License as published by the Free Software
|
||
8 | * Foundation; either version 3 of the License, or (at your option) any later
|
||
9 | * version.
|
||
10 | 40435 | jjdelcerro | *
|
11 | 41486 | jjdelcerro | * This program is distributed in the hope that it will be useful, but WITHOUT
|
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
13 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||
14 | * details.
|
||
15 | 40435 | jjdelcerro | *
|
16 | 41486 | jjdelcerro | * You should have received a copy of the GNU General Public License along with
|
17 | * this program; if not, write to the Free Software Foundation, Inc., 51
|
||
18 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
19 | 40435 | jjdelcerro | *
|
20 | 41486 | jjdelcerro | * For any additional information, do not hesitate to contact us at info AT
|
21 | * gvsig.com, or visit our website www.gvsig.com.
|
||
22 | 40435 | jjdelcerro | */
|
23 | 43925 | jjdelcerro | package org.gvsig.export.jdbc.swing.panels; |
24 | 40435 | jjdelcerro | |
25 | 41486 | jjdelcerro | import java.awt.event.ActionEvent; |
26 | import java.awt.event.ActionListener; |
||
27 | import java.util.Iterator; |
||
28 | import java.util.List; |
||
29 | |||
30 | import javax.swing.DefaultListModel; |
||
31 | import javax.swing.JComponent; |
||
32 | 41598 | jjdelcerro | import javax.swing.JOptionPane; |
33 | 41534 | jjdelcerro | import javax.swing.ListModel; |
34 | 41492 | jjdelcerro | import javax.swing.SwingUtilities; |
35 | import javax.swing.event.AncestorEvent; |
||
36 | import javax.swing.event.AncestorListener; |
||
37 | 41486 | jjdelcerro | import org.apache.commons.lang3.StringUtils; |
38 | 43925 | jjdelcerro | import org.gvsig.export.jdbc.service.ExportJDBCParameters; |
39 | 41632 | jjdelcerro | //import org.gvsig.app.ApplicationLocator;
|
40 | //import org.gvsig.app.ApplicationManager;
|
||
41 | 41486 | jjdelcerro | import org.gvsig.fmap.dal.DALLocator; |
42 | import org.gvsig.fmap.dal.DataManager; |
||
43 | 43355 | jjdelcerro | import org.gvsig.fmap.dal.SQLBuilder; |
44 | 41486 | jjdelcerro | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
45 | import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
||
46 | import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
||
47 | import org.gvsig.tools.ToolsLocator; |
||
48 | import org.gvsig.tools.i18n.I18nManager; |
||
49 | 43377 | jjdelcerro | import org.gvsig.tools.swing.api.ToolsSwingLocator; |
50 | import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
||
51 | 41492 | jjdelcerro | import org.gvsig.tools.task.AbstractMonitorableTask; |
52 | import org.gvsig.tools.task.SimpleTaskStatus; |
||
53 | 41486 | jjdelcerro | import org.slf4j.Logger; |
54 | import org.slf4j.LoggerFactory; |
||
55 | 43925 | jjdelcerro | import org.gvsig.export.swing.JExportProcessPanel; |
56 | import org.gvsig.export.swing.spi.ExportPanel; |
||
57 | import org.gvsig.export.swing.spi.ExportPanelValidationException; |
||
58 | 40435 | jjdelcerro | |
59 | /**
|
||
60 | * @author gvSIG Team
|
||
61 | * @version $Id$
|
||
62 | 41486 | jjdelcerro | *
|
63 | 40435 | jjdelcerro | */
|
64 | 43925 | jjdelcerro | public class SelectTableNamePanel |
65 | extends SelectTableNamePanelLayout
|
||
66 | implements ExportPanel
|
||
67 | { |
||
68 | 41534 | jjdelcerro | |
69 | 41486 | jjdelcerro | private static final Logger logger = LoggerFactory.getLogger(SelectTableNamePanel.class); |
70 | 41534 | jjdelcerro | |
71 | 40435 | jjdelcerro | private static final long serialVersionUID = 6269512983586358017L; |
72 | 41534 | jjdelcerro | |
73 | 41486 | jjdelcerro | private static class TableItem { |
74 | 41534 | jjdelcerro | |
75 | 41486 | jjdelcerro | private JDBCStoreParameters params;
|
76 | private String label; |
||
77 | 41534 | jjdelcerro | |
78 | 41486 | jjdelcerro | public TableItem(String label, JDBCStoreParameters params) { |
79 | this.params = params;
|
||
80 | this.label = label;
|
||
81 | } |
||
82 | 41534 | jjdelcerro | |
83 | 41486 | jjdelcerro | public TableItem(JDBCStoreParameters params) {
|
84 | 43355 | jjdelcerro | this( StringUtils.isEmpty(params.getSchema())?
|
85 | params.getTable() : params.getSchema() + "." + params.getTable(),
|
||
86 | params); |
||
87 | 41486 | jjdelcerro | } |
88 | 41534 | jjdelcerro | |
89 | 43031 | jjdelcerro | @Override
|
90 | 41486 | jjdelcerro | public String toString() { |
91 | return this.label; |
||
92 | } |
||
93 | 41534 | jjdelcerro | |
94 | 41486 | jjdelcerro | public JDBCStoreParameters getParams() {
|
95 | return this.params; |
||
96 | } |
||
97 | } |
||
98 | 41534 | jjdelcerro | |
99 | 43925 | jjdelcerro | private FillTablesListTask task = null; |
100 | private SQLBuilder sqlbuilder;
|
||
101 | private final ExportJDBCParameters parameters; |
||
102 | private final JExportProcessPanel processPanel; |
||
103 | |||
104 | 43920 | jjdelcerro | @SuppressWarnings("OverridableMethodCallInConstructor") |
105 | 43925 | jjdelcerro | public SelectTableNamePanel(
|
106 | JExportProcessPanel processPanel, |
||
107 | ExportJDBCParameters parameters |
||
108 | ) { |
||
109 | this.processPanel = processPanel;
|
||
110 | this.parameters = parameters;
|
||
111 | 41488 | jjdelcerro | initComponents(); |
112 | 41492 | jjdelcerro | this.addAncestorListener(new AncestorListener() { |
113 | 41534 | jjdelcerro | |
114 | 43031 | jjdelcerro | @Override
|
115 | 41492 | jjdelcerro | public void ancestorAdded(AncestorEvent ae) { |
116 | } |
||
117 | 41534 | jjdelcerro | |
118 | 43031 | jjdelcerro | @Override
|
119 | 41492 | jjdelcerro | public void ancestorRemoved(AncestorEvent ae) { |
120 | cancelTask(); |
||
121 | } |
||
122 | 41534 | jjdelcerro | |
123 | 43031 | jjdelcerro | @Override
|
124 | 41492 | jjdelcerro | public void ancestorMoved(AncestorEvent ae) { |
125 | } |
||
126 | }); |
||
127 | 41486 | jjdelcerro | } |
128 | 41534 | jjdelcerro | |
129 | 41486 | jjdelcerro | private void initComponents() { |
130 | this.rdoCreateTable.addActionListener(new ActionListener() { |
||
131 | 43031 | jjdelcerro | @Override
|
132 | 41486 | jjdelcerro | public void actionPerformed(ActionEvent e) { |
133 | onChangeRadioSelecion(); |
||
134 | } |
||
135 | }); |
||
136 | this.rdoInsert.addActionListener(new ActionListener() { |
||
137 | 43031 | jjdelcerro | @Override
|
138 | 41486 | jjdelcerro | public void actionPerformed(ActionEvent e) { |
139 | onChangeRadioSelecion(); |
||
140 | } |
||
141 | }); |
||
142 | 41488 | jjdelcerro | this.rdoCreateTable.setSelected(true); |
143 | 41492 | jjdelcerro | this.rdoInsert.setEnabled(false); |
144 | this.lstTables.setEnabled(false); |
||
145 | try {
|
||
146 | 43925 | jjdelcerro | this.txtTableName.setText(this.parameters.getSourceFeatureStore().getName()); |
147 | 41492 | jjdelcerro | } catch (Exception ex) { |
148 | logger.warn("Can't set the default value for the table name", ex);
|
||
149 | } |
||
150 | 41560 | jjdelcerro | |
151 | 41534 | jjdelcerro | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
152 | this.lblHeader.setText(i18nManager.getTranslation("_Indique_donde_desea_insertar_los_datos")); |
||
153 | this.lblWarningUseExistingTable.setText(
|
||
154 | 41560 | jjdelcerro | "<html>\n"
|
155 | + i18nManager.getTranslation("_Los_datos_se_insertaran_usando_los_nombres_de_columna_que_coincidan_con_la_tabla_origen_dejandose_al_valor_por_defecto_para_los_que_no_haya_valores_en_la_tabla_origen")
|
||
156 | + "\n</html>"
|
||
157 | 41534 | jjdelcerro | ); |
158 | this.rdoInsert.setText(i18nManager.getTranslation("_Insertar_registros_en_una_tabla_existente")); |
||
159 | this.lblSelectTableName.setText(i18nManager.getTranslation("_Seleccione_la_tabla_a_usar")); |
||
160 | this.rdoCreateTable.setText(i18nManager.getTranslation("_Crear_una_tabla_nueva")); |
||
161 | this.lblSchema.setText(i18nManager.getTranslation("_Indique_el_esquema_en_el_que_desea_crear_la_tabla")); |
||
162 | this.lblTableName.setText(i18nManager.getTranslation("_Indique_el_nombre_de_la_tabla")); |
||
163 | 41486 | jjdelcerro | } |
164 | 41534 | jjdelcerro | |
165 | 41492 | jjdelcerro | private void cancelTask() { |
166 | 41534 | jjdelcerro | if (task != null) { |
167 | 41492 | jjdelcerro | task.cancelRequest(); |
168 | task.getSimpleTaskStatus().remove(); |
||
169 | task = null;
|
||
170 | 41534 | jjdelcerro | } |
171 | 41492 | jjdelcerro | } |
172 | 41534 | jjdelcerro | |
173 | 41486 | jjdelcerro | public boolean canCreateTable() { |
174 | return this.rdoCreateTable.isSelected(); |
||
175 | } |
||
176 | 41534 | jjdelcerro | |
177 | 41486 | jjdelcerro | public String getSchema() { |
178 | 41534 | jjdelcerro | if (this.canCreateTable()) { |
179 | 41486 | jjdelcerro | return StringUtils.defaultIfBlank(this.txtSchema.getText(), null); |
180 | } |
||
181 | 41509 | jjdelcerro | TableItem item = (TableItem) this.lstTables.getSelectedValue();
|
182 | JDBCStoreParameters tableParameter = item.getParams(); |
||
183 | 41534 | jjdelcerro | if (tableParameter == null) { |
184 | 41486 | jjdelcerro | return null; |
185 | } |
||
186 | 41509 | jjdelcerro | return tableParameter.getSchema();
|
187 | 41486 | jjdelcerro | } |
188 | 41534 | jjdelcerro | |
189 | 41486 | jjdelcerro | public String getTableName() { |
190 | 41534 | jjdelcerro | if (this.canCreateTable()) { |
191 | 41492 | jjdelcerro | return StringUtils.defaultIfBlank(this.txtTableName.getText(), null); |
192 | 41486 | jjdelcerro | } |
193 | 41509 | jjdelcerro | TableItem item = (TableItem) this.lstTables.getSelectedValue();
|
194 | 41560 | jjdelcerro | if (item == null) { |
195 | return null; |
||
196 | } |
||
197 | 41509 | jjdelcerro | JDBCStoreParameters tableParameter = item.getParams(); |
198 | 41534 | jjdelcerro | |
199 | if (tableParameter == null) { |
||
200 | 41486 | jjdelcerro | return null; |
201 | } |
||
202 | 41509 | jjdelcerro | return tableParameter.getTable();
|
203 | 41486 | jjdelcerro | } |
204 | 41534 | jjdelcerro | |
205 | 43925 | jjdelcerro | |
206 | 43031 | jjdelcerro | @Override
|
207 | 43925 | jjdelcerro | public String getIdPanel() { |
208 | return this.getClass().getCanonicalName(); |
||
209 | } |
||
210 | |||
211 | @Override
|
||
212 | public String getTitlePanel() { |
||
213 | 41486 | jjdelcerro | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
214 | 41534 | jjdelcerro | return i18nManager.getTranslation("_Tablename"); |
215 | 40435 | jjdelcerro | } |
216 | 41534 | jjdelcerro | |
217 | 43031 | jjdelcerro | @Override
|
218 | 43968 | jjdelcerro | public void previousPanel() { |
219 | |||
220 | } |
||
221 | |||
222 | @Override
|
||
223 | public void nextPanel() { |
||
224 | 43925 | jjdelcerro | this.parameters.setSchema(this.getSchema()); |
225 | this.parameters.setTableName(this.getTableName()); |
||
226 | this.parameters.setCanCreatetable(this.canCreateTable()); |
||
227 | } |
||
228 | |||
229 | @Override
|
||
230 | public boolean validatePanel() throws ExportPanelValidationException { |
||
231 | 41534 | jjdelcerro | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
232 | String tablename = this.getTableName(); |
||
233 | 41560 | jjdelcerro | if (tablename == null) { |
234 | 43925 | jjdelcerro | throw new ExportPanelValidationException( |
235 | 41560 | jjdelcerro | i18nManager.getTranslation( |
236 | "_The_name_of_table_cannot_be_empty"
|
||
237 | ) |
||
238 | 41534 | jjdelcerro | ); |
239 | 40435 | jjdelcerro | } |
240 | 41534 | jjdelcerro | String schema = this.getSchema(); |
241 | 44198 | jjdelcerro | if( sqlbuilder.support_schemas() ) {
|
242 | 43355 | jjdelcerro | if (schema == null) { |
243 | 43925 | jjdelcerro | throw new ExportPanelValidationException( |
244 | 43355 | jjdelcerro | i18nManager.getTranslation( |
245 | "_The_name_of_schema_cannot_be_empty"
|
||
246 | ) |
||
247 | ); |
||
248 | } |
||
249 | 41486 | jjdelcerro | } |
250 | 41560 | jjdelcerro | if (this.rdoCreateTable.isSelected()) { |
251 | 41598 | jjdelcerro | String tablename_tr = tablename;
|
252 | 43925 | jjdelcerro | if( this.parameters.getTranslateIdentifiersToLowerCase() ) { |
253 | 41598 | jjdelcerro | tablename_tr = tablename_tr.toLowerCase(); |
254 | } |
||
255 | 43925 | jjdelcerro | if( this.parameters.getTranslateHyphens()) { |
256 | 43377 | jjdelcerro | tablename_tr = tablename_tr.replace("-", "_"); |
257 | 43637 | jjdelcerro | tablename_tr = tablename_tr.replace(".", "_"); |
258 | 43377 | jjdelcerro | } |
259 | 43925 | jjdelcerro | if( this.parameters.getRemoveSpacesInIdentifiers() ) { |
260 | 41598 | jjdelcerro | tablename_tr = StringUtils.normalizeSpace(tablename_tr).replace(" ", "_"); |
261 | } |
||
262 | if( !tablename_tr.equals(tablename) ) {
|
||
263 | String msg = i18nManager.getTranslation(
|
||
264 | "Ha_utilizado_espacios_en_blanco_o_mayusculas_en_el_nombre_de_la_tabla_Desea_que_se_corrija_de_forma_automatica"
|
||
265 | ); |
||
266 | 43377 | jjdelcerro | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
267 | int resp = dialogs.confirmDialog(
|
||
268 | 43031 | jjdelcerro | msg, |
269 | 41598 | jjdelcerro | i18nManager.getTranslation("_Warning"),
|
270 | JOptionPane.YES_NO_OPTION,
|
||
271 | 43377 | jjdelcerro | JOptionPane.WARNING_MESSAGE,
|
272 | "Exportto_Table_name_with_spaces_or_mixed_case"
|
||
273 | 41598 | jjdelcerro | ); |
274 | if( resp != JOptionPane.YES_OPTION ) { |
||
275 | msg = i18nManager.getTranslation( |
||
276 | "El_nombre_de_tabla_contiene_caracteres no_validos"
|
||
277 | ); |
||
278 | 43925 | jjdelcerro | throw new ExportPanelValidationException(msg); |
279 | 41598 | jjdelcerro | } |
280 | tablename = tablename_tr; |
||
281 | this.txtTableName.setText(tablename);
|
||
282 | } |
||
283 | 41560 | jjdelcerro | ListModel model = this.lstTables.getModel(); |
284 | for (int i = 0; i < model.getSize(); i++) { |
||
285 | TableItem item = (TableItem) model.getElementAt(i); |
||
286 | 43355 | jjdelcerro | if ( StringUtils.equals(schema,item.getParams().getSchema())
|
287 | && StringUtils.equals(tablename,item.getParams().getTable())) { |
||
288 | 41560 | jjdelcerro | String msg = i18nManager.getTranslation(
|
289 | "_La_tabla_{0}_{1}_ya_existe_en_la_base_de_datos_Seleccione_la_opcion_de_insertar_registros_en_una_tabla_existente_para_a?adir_los_datos_a_esta_o_indique_otro_nombre",
|
||
290 | new String[]{schema, tablename} |
||
291 | ); |
||
292 | 43925 | jjdelcerro | throw new ExportPanelValidationException(msg); |
293 | 41560 | jjdelcerro | } |
294 | 41534 | jjdelcerro | } |
295 | } |
||
296 | 40435 | jjdelcerro | return true; |
297 | } |
||
298 | 41534 | jjdelcerro | |
299 | 43031 | jjdelcerro | @Override
|
300 | 41488 | jjdelcerro | public void enterPanel() { |
301 | 43925 | jjdelcerro | JDBCServerExplorerParameters explorerParameters = parameters.getExplorerParameters(); |
302 | if (explorerParameters == null) { |
||
303 | this.processPanel.setButtonEnabled(JExportProcessPanel.BUTTON_NEXT, false); |
||
304 | return;
|
||
305 | 43355 | jjdelcerro | } |
306 | 43925 | jjdelcerro | this.processPanel.setButtonEnabled(JExportProcessPanel.BUTTON_NEXT, true); |
307 | try {
|
||
308 | DataManager dataManager = DALLocator.getDataManager(); |
||
309 | JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer( |
||
310 | explorerParameters.getExplorerName(), |
||
311 | explorerParameters |
||
312 | ); |
||
313 | this.sqlbuilder = explorer.createSQLBuilder();
|
||
314 | } catch (Exception ex) { |
||
315 | throw new RuntimeException("Can't retrieve the sqlbuilder", ex); |
||
316 | } |
||
317 | 41488 | jjdelcerro | this.fillTablesList();
|
318 | } |
||
319 | 41534 | jjdelcerro | |
320 | 43031 | jjdelcerro | @Override
|
321 | 41486 | jjdelcerro | public JComponent asJComponent() { |
322 | return this; |
||
323 | } |
||
324 | 41534 | jjdelcerro | |
325 | 41486 | jjdelcerro | public void onChangeRadioSelecion() { |
326 | 41534 | jjdelcerro | if (this.rdoCreateTable.isSelected()) { |
327 | 41486 | jjdelcerro | this.txtSchema.setEnabled(true); |
328 | this.txtTableName.setEnabled(true); |
||
329 | this.lstTables.setEnabled(false); |
||
330 | } else {
|
||
331 | this.txtSchema.setEnabled(false); |
||
332 | this.txtTableName.setEnabled(false); |
||
333 | this.lstTables.setEnabled(true); |
||
334 | } |
||
335 | } |
||
336 | 41534 | jjdelcerro | |
337 | 41486 | jjdelcerro | private void fillTablesList() { |
338 | 41534 | jjdelcerro | |
339 | 43925 | jjdelcerro | JDBCServerExplorerParameters explorerParameters = this.parameters.getExplorerParameters();
|
340 | 41534 | jjdelcerro | if (explorerParameters == null) { |
341 | 41486 | jjdelcerro | return;
|
342 | } |
||
343 | 41492 | jjdelcerro | cancelTask(); |
344 | this.task = new FillTablesListTask(); |
||
345 | task.setDaemon(true);
|
||
346 | task.start(); |
||
347 | } |
||
348 | 41534 | jjdelcerro | |
349 | 41492 | jjdelcerro | private class FillTablesListTask extends AbstractMonitorableTask { |
350 | 41534 | jjdelcerro | |
351 | 41492 | jjdelcerro | public FillTablesListTask() {
|
352 | super("Export"); |
||
353 | } |
||
354 | 41534 | jjdelcerro | |
355 | 43031 | jjdelcerro | @Override
|
356 | 41492 | jjdelcerro | protected SimpleTaskStatus getSimpleTaskStatus() {
|
357 | return (SimpleTaskStatus) this.getTaskStatus(); |
||
358 | } |
||
359 | 41534 | jjdelcerro | |
360 | 43031 | jjdelcerro | @Override
|
361 | 41492 | jjdelcerro | public void run() { |
362 | 41534 | jjdelcerro | |
363 | 43925 | jjdelcerro | JDBCServerExplorerParameters explorerParameters = parameters.getExplorerParameters(); |
364 | if (parameters.getExplorerParameters() == null) { |
||
365 | 41492 | jjdelcerro | return;
|
366 | 41486 | jjdelcerro | } |
367 | 41492 | jjdelcerro | final SimpleTaskStatus status = this.getSimpleTaskStatus(); |
368 | try {
|
||
369 | status.setAutoremove(true);
|
||
370 | 41534 | jjdelcerro | |
371 | 41492 | jjdelcerro | DataManager dataManager = DALLocator.getDataManager(); |
372 | 41534 | jjdelcerro | |
373 | 41492 | jjdelcerro | this.getSimpleTaskStatus().message("Connecting server"); |
374 | explorerParameters.setShowInformationDBTables(false);
|
||
375 | 43020 | jjdelcerro | final JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer(
|
376 | 41492 | jjdelcerro | explorerParameters.getExplorerName(), |
377 | explorerParameters |
||
378 | ); |
||
379 | 43031 | jjdelcerro | SwingUtilities.invokeAndWait(new Runnable() { |
380 | 41534 | jjdelcerro | |
381 | 43031 | jjdelcerro | @Override
|
382 | public void run() { |
||
383 | 44198 | jjdelcerro | if( sqlbuilder.support_schemas() ) {
|
384 | 43355 | jjdelcerro | txtSchema.setText(sqlbuilder.default_schema()); |
385 | } else {
|
||
386 | txtSchema.setText("");
|
||
387 | txtSchema.setEnabled(false);
|
||
388 | } |
||
389 | 43031 | jjdelcerro | } |
390 | }); |
||
391 | |||
392 | 41492 | jjdelcerro | this.getSimpleTaskStatus().message("Retrieving tables"); |
393 | final List<JDBCStoreParameters> tables = explorer.list(); |
||
394 | 41534 | jjdelcerro | |
395 | 41492 | jjdelcerro | this.getSimpleTaskStatus().message("Add tables"); |
396 | 41534 | jjdelcerro | |
397 | 41492 | jjdelcerro | SwingUtilities.invokeAndWait(new Runnable() { |
398 | 43031 | jjdelcerro | @Override
|
399 | 41492 | jjdelcerro | public void run() { |
400 | DefaultListModel lmodel = new DefaultListModel(); |
||
401 | Iterator<JDBCStoreParameters> it = tables.iterator();
|
||
402 | 41534 | jjdelcerro | while (it.hasNext()) {
|
403 | if (status.isCancelled()) {
|
||
404 | 41492 | jjdelcerro | status.cancel(); |
405 | break;
|
||
406 | } |
||
407 | JDBCStoreParameters table = it.next(); |
||
408 | lmodel.addElement(new TableItem(table));
|
||
409 | } |
||
410 | lstTables.setModel(lmodel); |
||
411 | 41509 | jjdelcerro | //lstTables.setEnabled(true);
|
412 | 41492 | jjdelcerro | rdoInsert.setEnabled(true);
|
413 | } |
||
414 | }); |
||
415 | 41534 | jjdelcerro | |
416 | 41492 | jjdelcerro | status.message("finish");
|
417 | status.terminate(); |
||
418 | 41534 | jjdelcerro | |
419 | 41492 | jjdelcerro | } catch (final Exception ex) { |
420 | logger.warn("Fail to fill tables list", ex);
|
||
421 | 41534 | jjdelcerro | if (status.isCancellationRequested()) {
|
422 | 41492 | jjdelcerro | status.cancel(); |
423 | } |
||
424 | 43925 | jjdelcerro | if (status.isRunning()) {
|
425 | I18nManager i18nManager = ToolsLocator.getI18nManager(); |
||
426 | ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
||
427 | dialogs.messageDialog( |
||
428 | i18nManager.getTranslation("_There_have_been_problems_filling_data_in_panel")
|
||
429 | + " (" + getTitlePanel() + ")", |
||
430 | null,
|
||
431 | i18nManager.getTranslation("_Warning"),
|
||
432 | JOptionPane.WARNING_MESSAGE,
|
||
433 | "ProblemsFillingTableNamePanel"
|
||
434 | ); |
||
435 | } |
||
436 | 41534 | jjdelcerro | |
437 | 41492 | jjdelcerro | } finally {
|
438 | status.terminate(); |
||
439 | status.remove(); |
||
440 | } |
||
441 | 41534 | jjdelcerro | |
442 | 41486 | jjdelcerro | } |
443 | 41534 | jjdelcerro | |
444 | 41486 | jjdelcerro | } |
445 | 41534 | jjdelcerro | |
446 | 40435 | jjdelcerro | } |