use of org.apache.cayenne.modeler.dialog.db.load.DbLoaderContext in project cayenne by apache.
the class ReverseEngineeringAction method performAction.
/**
* Connects to DB and delegates processing to DbLoaderController, starting it asynchronously.
*/
@Override
public void performAction(ActionEvent event) {
final DbLoaderContext context = new DbLoaderContext();
final DataSourceWizard connectWizard = dataSourceWizardDialog("Reengineer DB Schema: Connect to Database");
if (connectWizard == null) {
return;
}
context.setProjectController(getProjectController());
try {
context.setConnection(connectWizard.getDataSource().getConnection());
} catch (SQLException ex) {
JOptionPane.showMessageDialog(Application.getFrame(), ex.getMessage(), "Error loading schemas dialog", JOptionPane.ERROR_MESSAGE);
return;
}
final DbLoaderOptionsDialog loaderOptionsDialog = loaderOptionDialog(connectWizard);
if (!context.buildConfig(connectWizard, loaderOptionsDialog)) {
try {
context.getConnection().close();
} catch (SQLException ignored) {
}
return;
}
runLoaderInThread(context, new Runnable() {
@Override
public void run() {
application.getUndoManager().discardAllEdits();
try {
context.getConnection().close();
} catch (SQLException ignored) {
}
}
});
}
Aggregations