-
Notifications
You must be signed in to change notification settings - Fork 1
Swing SQL Console
AndreasWBartels edited this page Dec 6, 2021
·
6 revisions
<dependency>
<groupId>net.anwiba.commons</groupId>
<artifactId>anwiba-commons-swing-database-console</artifactId>
<version>1.1.158</version>
</dependency>
try {
final IDataBaseConnectionDescription description = getConnectionDescription();
if (this.dialogs.containsKey(description)) {
this.dialogs.get(description).toFront();
return;
}
final IObjectModel<Connection> connectionModel = new ObjectModel<>(
this.databaseConnector.connectWritable(description));
final IBooleanModel isConnectedModel = new BooleanModel(!connectionModel.get().isClosed());
final IBooleanModel isDisconnectedModel = new BooleanModel(connectionModel.get().isClosed());
new ConfigurableDialogLauncher()
.setPreferences(this.preferences.node("sql").node("console")) //$NON-NLS-1$//$NON-NLS-2$
.setMessagePanelDisabled()
.setModelessModality()
.setDialogType(DialogType.NONE)
.setDialogIcon(net.anwiba.commons.swing.icons.GuiIcons.GROOVY_CONSOLE_ICON)
.setTitle(MessageFormat.format(LayerManagerMessages.sql_console_t0, description.getUrl()))
.setResizeable()
.setContentPaneFactory(
new SqlConsoleContentPaneFactory(
this.processManager,
this.databaseConnector,
this.databaseFacadeProvider,
description,
getSchema(description),
this.dataBaseTableCellValueToStringConverterProvider,
isConnectedModel,
connectionModel,
isDisconnectedModel))
.addBeforeShowExecutable(d -> this.dialogs.put(description, d))
.addOnCloseExecutable(() -> {
try {
this.dialogs.remove(description);
connectionModel.get().close();
} catch (final SQLException exception) {
logger.log(ILevel.DEBUG, "Couldn't close connection", exception); //$NON-NLS-1$
}
})
.setProgressDialogEnabled()
.launch(null);
} catch (final SQLException | IllegalArgumentException exception) {
new MessageDialogLauncher()
.title(LayerManagerMessages.sql_console)
.text(LayerManagerMessages.could_not_open_sql_console)
.description(exception.getMessage())
.throwable(exception)
.error()
.launch(component);
}