Revision 44386 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
SelectTableNamePanel.java | ||
---|---|---|
37 | 37 |
import org.apache.commons.lang3.StringUtils; |
38 | 38 |
import org.gvsig.export.jdbc.service.ExportJDBCAttributeNamesTranslator; |
39 | 39 |
import org.gvsig.export.jdbc.service.ExportJDBCParameters; |
40 |
import org.gvsig.export.spi.AttributeNamesTranslator; |
|
41 |
//import org.gvsig.app.ApplicationLocator; |
|
42 |
//import org.gvsig.app.ApplicationManager; |
|
43 | 40 |
import org.gvsig.fmap.dal.DALLocator; |
44 | 41 |
import org.gvsig.fmap.dal.DataManager; |
45 | 42 |
import org.gvsig.fmap.dal.SQLBuilder; |
... | ... | |
64 | 61 |
* @version $Id$ |
65 | 62 |
* |
66 | 63 |
*/ |
67 |
public class SelectTableNamePanel |
|
68 |
extends SelectTableNamePanelLayout |
|
69 |
implements ExportPanel |
|
70 |
{ |
|
64 |
public class SelectTableNamePanel |
|
65 |
extends SelectTableNamePanelLayout |
|
66 |
implements ExportPanel { |
|
71 | 67 |
|
72 | 68 |
private static final Logger logger = LoggerFactory.getLogger(SelectTableNamePanel.class); |
73 | 69 |
|
... | ... | |
84 | 80 |
} |
85 | 81 |
|
86 | 82 |
public TableItem(JDBCStoreParameters params) { |
87 |
this( StringUtils.isEmpty(params.getSchema())?
|
|
88 |
params.getTable() : params.getSchema() + "." + params.getTable(),
|
|
89 |
params); |
|
83 |
this(StringUtils.isEmpty(params.getSchema())
|
|
84 |
? params.getTable() : params.getSchema() + "." + params.getTable(),
|
|
85 |
params);
|
|
90 | 86 |
} |
91 | 87 |
|
92 | 88 |
@Override |
... | ... | |
106 | 102 |
|
107 | 103 |
@SuppressWarnings("OverridableMethodCallInConstructor") |
108 | 104 |
public SelectTableNamePanel( |
109 |
JExportProcessPanel processPanel,
|
|
105 |
JExportProcessPanel processPanel, |
|
110 | 106 |
ExportJDBCParameters parameters |
111 |
) {
|
|
107 |
) { |
|
112 | 108 |
this.processPanel = processPanel; |
113 | 109 |
this.parameters = parameters; |
114 | 110 |
initComponents(); |
... | ... | |
205 | 201 |
return tableParameter.getTable(); |
206 | 202 |
} |
207 | 203 |
|
208 |
|
|
209 | 204 |
@Override |
210 | 205 |
public String getIdPanel() { |
211 | 206 |
return this.getClass().getCanonicalName(); |
... | ... | |
241 | 236 |
); |
242 | 237 |
} |
243 | 238 |
String schema = this.getSchema(); |
244 |
if( sqlbuilder.support_schemas() ) {
|
|
239 |
if (sqlbuilder.support_schemas()) {
|
|
245 | 240 |
if (schema == null) { |
246 | 241 |
throw new ExportPanelValidationException( |
247 | 242 |
i18nManager.getTranslation( |
... | ... | |
251 | 246 |
} |
252 | 247 |
} |
253 | 248 |
if (this.rdoCreateTable.isSelected()) { |
254 |
String tablename_tr = tablename; |
|
255 |
ExportJDBCAttributeNamesTranslator nameTranslator = |
|
256 |
(ExportJDBCAttributeNamesTranslator) this.parameters.getExportAttributes().getNamesTranslator(); |
|
257 |
if( nameTranslator.getTranslateIdentifiersToLowerCase() ) { |
|
258 |
tablename_tr = tablename_tr.toLowerCase(); |
|
259 |
} |
|
260 |
if( nameTranslator.getTranslateHyphens()) { |
|
261 |
tablename_tr = tablename_tr.replace("-", "_"); |
|
262 |
tablename_tr = tablename_tr.replace(".", "_"); |
|
263 |
} |
|
264 |
if( nameTranslator.getRemoveSpacesInIdentifiers() ) { |
|
265 |
tablename_tr = StringUtils.normalizeSpace(tablename_tr).replace(" ", "_"); |
|
266 |
} |
|
267 |
if( !tablename_tr.equals(tablename) ) { |
|
249 |
ExportJDBCAttributeNamesTranslator nameTranslator |
|
250 |
= (ExportJDBCAttributeNamesTranslator) this.parameters.getExportAttributes().getNamesTranslator(); |
|
251 |
String tablename_tr = nameTranslator.getNameSuggestion(tablename); |
|
252 |
if (!tablename_tr.equals(tablename)) { |
|
268 | 253 |
String msg = i18nManager.getTranslation( |
269 | 254 |
"Ha_utilizado_espacios_en_blanco_o_mayusculas_en_el_nombre_de_la_tabla_Desea_que_se_corrija_de_forma_automatica" |
270 | 255 |
); |
271 | 256 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
272 | 257 |
int resp = dialogs.confirmDialog( |
273 |
msg,
|
|
258 |
msg, |
|
274 | 259 |
i18nManager.getTranslation("_Warning"), |
275 |
JOptionPane.YES_NO_OPTION,
|
|
260 |
JOptionPane.YES_NO_OPTION, |
|
276 | 261 |
JOptionPane.WARNING_MESSAGE, |
277 | 262 |
"Exportto_Table_name_with_spaces_or_mixed_case" |
278 | 263 |
); |
279 |
if( resp != JOptionPane.YES_OPTION ) {
|
|
264 |
if (resp != JOptionPane.YES_OPTION) {
|
|
280 | 265 |
msg = i18nManager.getTranslation( |
281 | 266 |
"El_nombre_de_tabla_contiene_caracteres no_validos" |
282 | 267 |
); |
... | ... | |
288 | 273 |
ListModel model = this.lstTables.getModel(); |
289 | 274 |
for (int i = 0; i < model.getSize(); i++) { |
290 | 275 |
TableItem item = (TableItem) model.getElementAt(i); |
291 |
if ( StringUtils.equals(schema,item.getParams().getSchema())
|
|
292 |
&& StringUtils.equals(tablename,item.getParams().getTable())) { |
|
276 |
if (StringUtils.equals(schema, item.getParams().getSchema())
|
|
277 |
&& StringUtils.equals(tablename, item.getParams().getTable())) {
|
|
293 | 278 |
String msg = i18nManager.getTranslation( |
294 | 279 |
"_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", |
295 | 280 |
new String[]{schema, tablename} |
... | ... | |
312 | 297 |
try { |
313 | 298 |
DataManager dataManager = DALLocator.getDataManager(); |
314 | 299 |
JDBCServerExplorer explorer = (JDBCServerExplorer) dataManager.openServerExplorer( |
315 |
explorerParameters.getExplorerName(), |
|
316 |
explorerParameters |
|
300 |
explorerParameters.getExplorerName(),
|
|
301 |
explorerParameters
|
|
317 | 302 |
); |
318 | 303 |
this.sqlbuilder = explorer.createSQLBuilder(); |
319 | 304 |
} catch (Exception ex) { |
320 | 305 |
throw new RuntimeException("Can't retrieve the sqlbuilder", ex); |
321 | 306 |
} |
322 | 307 |
this.fillTablesList(); |
308 |
|
|
309 |
// set values from params |
|
310 |
this.rdoCreateTable.setSelected(this.parameters.canCreatetable()); |
|
311 |
if (this.parameters.canCreatetable() == true) { |
|
312 |
if (this.parameters.getSchema() != null) { |
|
313 |
this.txtSchema.setText(this.parameters.getSchema()); |
|
314 |
this.txtTableName.setText(this.parameters.getTableName()); |
|
315 |
} |
|
316 |
} else { |
|
317 |
String schema = this.parameters.getSchema(); |
|
318 |
if (schema != null) { |
|
319 |
//this.lstTables; |
|
320 |
for (int i = 0; i < this.lstTables.getModel().getSize(); i++) { |
|
321 |
TableItem item = (TableItem) this.lstTables.getModel().getElementAt(i); |
|
322 |
JDBCStoreParameters tableParameter = item.getParams(); |
|
323 |
if (tableParameter.getSchema() == null ? schema == null : tableParameter.getSchema().equals(schema)) { |
|
324 |
this.lstTables.setSelectedIndex(i); |
|
325 |
} |
|
326 |
} |
|
327 |
} |
|
328 |
} |
|
323 | 329 |
} |
324 | 330 |
|
325 | 331 |
@Override |
... | ... | |
385 | 391 |
|
386 | 392 |
@Override |
387 | 393 |
public void run() { |
388 |
if( sqlbuilder.support_schemas() ) {
|
|
394 |
if (sqlbuilder.support_schemas()) {
|
|
389 | 395 |
txtSchema.setText(sqlbuilder.default_schema()); |
390 | 396 |
} else { |
391 | 397 |
txtSchema.setText(""); |
... | ... | |
426 | 432 |
if (status.isCancellationRequested()) { |
427 | 433 |
status.cancel(); |
428 | 434 |
} |
429 |
if (status.isRunning()) {
|
|
435 |
if (status.isRunning()) { |
|
430 | 436 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
431 | 437 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
432 | 438 |
dialogs.messageDialog( |
433 | 439 |
i18nManager.getTranslation("_There_have_been_problems_filling_data_in_panel") |
434 |
+ " (" + getTitlePanel() + ")",
|
|
435 |
null,
|
|
440 |
+ " (" + getTitlePanel() + ")", |
|
441 |
null, |
|
436 | 442 |
i18nManager.getTranslation("_Warning"), |
437 |
JOptionPane.WARNING_MESSAGE,
|
|
443 |
JOptionPane.WARNING_MESSAGE, |
|
438 | 444 |
"ProblemsFillingTableNamePanel" |
439 | 445 |
); |
440 | 446 |
} |
Also available in: Unified diff