Revision 47607 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.xml2db/org.gvsig.xml2db.swing/org.gvsig.xml2db.swing.impl/src/main/java/org/gvsig/xml2db/swing/impl/copyxml2db/CopyXml2dbPanel.java
CopyXml2dbPanel.java | ||
---|---|---|
40 | 40 |
import org.cresques.cts.IProjection; |
41 | 41 |
import org.gvsig.fmap.dal.DALLocator; |
42 | 42 |
import org.gvsig.fmap.dal.DataManager; |
43 |
import org.gvsig.fmap.dal.store.h2.H2SpatialUtils;
|
|
43 |
import org.gvsig.fmap.dal.PersonalDatabaseServerExplorerFactory;
|
|
44 | 44 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorerParameters; |
45 | 45 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
46 | 46 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
... | ... | |
66 | 66 |
import org.gvsig.xml2db.swing.Xml2dbPanel; |
67 | 67 |
import org.gvsig.xml2db.swing.impl.Task; |
68 | 68 |
import org.gvsig.xml2db.swing.impl.Xml2dbSwingCommons; |
69 |
import static org.gvsig.xml2db.swing.impl.Xml2dbSwingCommons.getPersonalDatabaseServerExplorersComboModel; |
|
69 | 70 |
import org.slf4j.Logger; |
70 | 71 |
import org.slf4j.LoggerFactory; |
71 | 72 |
|
... | ... | |
187 | 188 |
doDetectProjection(); |
188 | 189 |
}); |
189 | 190 |
|
191 |
this.cboDatabaseType.setModel(getPersonalDatabaseServerExplorersComboModel()); |
|
192 |
|
|
190 | 193 |
this.pickerDbfile = toolsSwingManager.createFilePickerController( |
191 | 194 |
this.txtDatabaseFile, |
192 | 195 |
this.btnDataBaseFile |
... | ... | |
254 | 257 |
} |
255 | 258 |
return; |
256 | 259 |
} |
260 |
PersonalDatabaseServerExplorerFactory explorerFactory = this.getExplorerFactory(); |
|
261 |
|
|
257 | 262 |
this.pickerXMLFile.setEnabled(true); |
258 | 263 |
this.pickerCharset.setEnabled(true); |
259 | 264 |
this.pickerProjection.setEnabled(true); |
... | ... | |
284 | 289 |
} |
285 | 290 |
return; |
286 | 291 |
} |
287 |
if( H2SpatialUtils.existsH2db(dbfile) && !this.chkOverwriteDatabase.isSelected() ) {
|
|
292 |
if( explorerFactory.existsdb(dbfile) && !this.chkOverwriteDatabase.isSelected() ) {
|
|
288 | 293 |
this.message(i18n.getTranslation("_Database_file_already_exists"), JOptionPane.WARNING_MESSAGE); |
289 | 294 |
if( this.dialog!=null ) { |
290 | 295 |
this.dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false); |
... | ... | |
345 | 350 |
boolean registerConnection = this.chkRegisterConnection.isSelected(); |
346 | 351 |
boolean connectToRepository = this.chkConnectToRepository.isSelected(); |
347 | 352 |
|
353 |
PersonalDatabaseServerExplorerFactory explorerFactory = this.getExplorerFactory(); |
|
354 |
|
|
348 | 355 |
Xml2dbManager manager = Xml2dbLocator.getXml2dbManager(); |
349 | 356 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
350 | 357 |
|
351 |
if( H2SpatialUtils.existsH2db(dbfile) ) {
|
|
358 |
if( explorerFactory.existsdb(dbfile) ) {
|
|
352 | 359 |
if( !this.chkOverwriteDatabase.isSelected() ) { |
353 | 360 |
message(i18n.getTranslation("_Database_file_already_exists"), JOptionPane.WARNING_MESSAGE); |
354 | 361 |
return; |
... | ... | |
368 | 375 |
@Override |
369 | 376 |
protected void task(SimpleTaskStatus taskStatus) throws Throwable{ |
370 | 377 |
try { |
371 |
if( H2SpatialUtils.existsH2db(dbfile) ) {
|
|
378 |
if( explorerFactory.existsdb(dbfile) ) {
|
|
372 | 379 |
taskStatus.message(i18n.getTranslation("_Removing_existing_database")); |
373 |
H2SpatialUtils.server_stop();
|
|
374 |
H2SpatialUtils.removeH2db(dbfile);
|
|
375 |
H2SpatialUtils.server_start();
|
|
380 |
explorerFactory.serverStop();
|
|
381 |
explorerFactory.removedb(dbfile);
|
|
382 |
explorerFactory.serverStart();
|
|
376 | 383 |
} |
377 | 384 |
XMLInfo xmlinfo = manager.extractStructure(xmlfile, charset, userproj, locale, tablesPrefix, taskStatus); |
378 | 385 |
if( xmlinfo==null ) { |
... | ... | |
390 | 397 |
if( xmlinfo.getCharset()!=null && charset==null ) { |
391 | 398 |
pickerCharset.set(xmlinfo.getCharset()); |
392 | 399 |
} |
393 |
JDBCServerExplorerParameters params = manager.createDatabase(dbfile, xmlinfo, taskStatus); |
|
400 |
JDBCServerExplorerParameters params = manager.createDatabase(explorerFactory.getName(), dbfile, xmlinfo, taskStatus);
|
|
394 | 401 |
if( params == null ) { |
395 | 402 |
throw new RuntimeException("Can't copy xml to database"); |
396 | 403 |
} |
... | ... | |
503 | 510 |
public ImageIcon loadImage(String imageName) { |
504 | 511 |
return ToolsSwingUtils.loadImage(this, imageName); |
505 | 512 |
} |
506 |
|
|
507 |
|
|
508 |
|
|
513 |
|
|
514 |
private PersonalDatabaseServerExplorerFactory getExplorerFactory() { |
|
515 |
return (PersonalDatabaseServerExplorerFactory) this.cboDatabaseType.getSelectedItem(); |
|
516 |
} |
|
509 | 517 |
} |
Also available in: Unified diff