use of org.apache.cayenne.modeler.dialog.db.DbActionOptionsDialog in project cayenne by apache.
the class MigrateAction method performAction.
public void performAction(ActionEvent e) {
DataSourceWizard connectWizard = getDataSourceWizard("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.DbActionOptionsDialog in project cayenne by apache.
the class MigrateAction method loaderOptionDialog.
protected DbActionOptionsDialog loaderOptionDialog(DataSourceWizard connectWizard) {
// use this catalog as the default...
List<String> catalogs;
List<String> schemas;
String currentCatalog;
String currentSchema = null;
try (Connection connection = connectWizard.getDataSource().getConnection()) {
catalogs = getCatalogs(connectWizard, connection);
schemas = getSchemas(connection);
if (catalogs.isEmpty() && schemas.isEmpty()) {
return null;
}
currentCatalog = connection.getCatalog();
try {
currentSchema = connection.getSchema();
} catch (Throwable th) {
LOGGER.warn("Error getting schema.", th);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(Application.getFrame(), ex.getMessage(), "Error loading schemas dialog", JOptionPane.ERROR_MESSAGE);
return null;
}
DbActionOptionsDialog optionsDialog = getStartDialog(catalogs, schemas, currentCatalog, currentSchema);
optionsDialog.setVisible(true);
while ((optionsDialog.getChoice() != DbActionOptionsDialog.CANCEL)) {
if (optionsDialog.getChoice() == DbActionOptionsDialog.SELECT) {
return optionsDialog;
}
optionsDialog = createDialog(catalogs, schemas, currentCatalog, currentSchema, optionsDialog.getChoice());
optionsDialog.setVisible(true);
}
return null;
}
Aggregations