use of org.apache.cayenne.modeler.dialog.db.DataSourceWizard in project cayenne by apache.
the class MigrateAction method performAction.
public void performAction(ActionEvent e) {
DataSourceWizard connectWizard = dataSourceWizardDialog("Migrate DB Schema: Connect to Database");
if (connectWizard == null) {
return;
}
DataMap map = getProjectController().getCurrentDataMap();
if (map == null) {
throw new IllegalStateException("No current DataMap selected.");
}
dialogShown = false;
DbActionOptionsDialog optionsDialog = loaderOptionDialog(connectWizard);
if (dialogShown && optionsDialog == null) {
return;
}
String selectedCatalog = optionsDialog == null ? null : optionsDialog.getSelectedCatalog();
String selectedSchema = optionsDialog == null ? null : optionsDialog.getSelectedSchema();
MergerTokenFactoryProvider mergerTokenFactoryProvider = getApplication().getInjector().getInstance(MergerTokenFactoryProvider.class);
// ... show dialog...
new MergerOptions(getProjectController(), "Migrate DB Schema: Options", connectWizard.getConnectionInfo(), map, selectedCatalog, selectedSchema, mergerTokenFactoryProvider).startupAction();
}
use of org.apache.cayenne.modeler.dialog.db.DataSourceWizard in project cayenne by apache.
the class DBGeneratorOptions method generateSchemaAction.
/**
* Performs configured schema operations via DbGenerator.
*/
public void generateSchemaAction() {
DataSourceWizard connectWizard = new DataSourceWizard(this.getParent(), "Generate DB Schema: Connect to Database");
if (!connectWizard.startupAction()) {
return;
}
this.connectionInfo = connectWizard.getConnectionInfo();
refreshGeneratorAction();
Collection<ValidationResult> failures = new ArrayList<ValidationResult>();
// sanity check...
for (DbGenerator generator : generators) {
if (generator.isEmpty(true)) {
JOptionPane.showMessageDialog(getView(), "Nothing to generate.");
return;
}
try {
generator.runGenerator(connectWizard.getDataSource());
failures.add(generator.getFailures());
} catch (Throwable th) {
reportError("Schema Generation Error", th);
}
}
if (failures.size() == 0) {
JOptionPane.showMessageDialog(getView(), "Schema Generation Complete.");
} else {
new ValidationResultBrowser(this).startupAction("Schema Generation Complete", "Schema generation finished. The following problem(s) were ignored.", failures);
}
}
use of org.apache.cayenne.modeler.dialog.db.DataSourceWizard 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