use of org.jkiss.dbeaver.model.connection.DataSourceVariableResolver in project dbeaver by dbeaver.
the class ConnectionPageAbstract method loadSettings.
@Override
public void loadSettings() {
DBPDriver driver = site.getDriver();
if (driver != null && driverText != null) {
driverText.setText(CommonUtils.toString(driver.getFullName()));
}
DataSourceDescriptor dataSource = (DataSourceDescriptor) getSite().getActiveDataSource();
if (savePasswordCheck != null) {
if (dataSource != null) {
savePasswordCheck.setSelection(dataSource.isSavePassword());
} else {
savePasswordCheck.setSelection(true);
}
}
if (variablesHintLabel != null) {
if (dataSource != null) {
variablesHintLabel.setResolver(new DataSourceVariableResolver(dataSource, dataSource.getConnectionConfiguration()));
} else {
variablesHintLabel.setResolver(null);
}
}
}
use of org.jkiss.dbeaver.model.connection.DataSourceVariableResolver in project dbeaver by serge-rider.
the class SSHTunnelConfiguratorUI method loadSettings.
@Override
public void loadSettings(DBWHandlerConfiguration configuration) {
hostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(DBWHandlerConfiguration.PROP_HOST)));
int portString = configuration.getIntProperty(DBWHandlerConfiguration.PROP_PORT);
if (portString != 0) {
portText.setSelection(portString);
} else {
portText.setSelection(SSHConstants.DEFAULT_SSH_PORT);
}
userNameText.setText(CommonUtils.notEmpty(configuration.getUserName()));
SSHConstants.AuthType authType = SSHConstants.AuthType.PASSWORD;
String authTypeName = configuration.getStringProperty(SSHConstants.PROP_AUTH_TYPE);
if (!CommonUtils.isEmpty(authTypeName)) {
authType = SSHConstants.AuthType.valueOf(authTypeName);
}
if (SSHConstants.AuthType.PASSWORD.equals(authType)) {
authMethodCombo.select(0);
} else if (SSHConstants.AuthType.PUBLIC_KEY.equals(authType)) {
authMethodCombo.select(1);
} else {
authMethodCombo.select(2);
}
privateKeyText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_KEY_PATH)));
passwordText.setText(CommonUtils.notEmpty(configuration.getPassword()));
savePasswordCheckbox.setSelection(configuration.isSavePassword());
String implType = configuration.getStringProperty(SSHConstants.PROP_IMPLEMENTATION);
if (CommonUtils.isEmpty(implType)) {
tunnelImplCombo.select(0);
} else {
SSHImplementationDescriptor desc = SSHImplementationRegistry.getInstance().getDescriptor(implType);
if (desc != null) {
tunnelImplCombo.setText(desc.getLabel());
} else {
tunnelImplCombo.select(0);
}
}
localHostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_LOCAL_HOST)));
int lpValue = configuration.getIntProperty(SSHConstants.PROP_LOCAL_PORT);
if (lpValue != 0) {
localPortSpinner.setSelection(lpValue);
}
remoteHostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_REMOTE_HOST)));
int rpValue = configuration.getIntProperty(SSHConstants.PROP_REMOTE_PORT);
if (rpValue != 0) {
remotePortSpinner.setSelection(rpValue);
}
int kaValue = configuration.getIntProperty(SSHConstants.PROP_ALIVE_INTERVAL);
if (kaValue != 0) {
keepAliveText.setSelection(kaValue);
}
int timeoutValue = configuration.getIntProperty(SSHConstants.PROP_CONNECT_TIMEOUT);
if (timeoutValue != 0) {
tunnelTimeout.setSelection(timeoutValue);
}
updateAuthMethodVisibility();
savedConfiguration = new DBWHandlerConfiguration(configuration);
DBPDataSourceContainer dataSource = savedConfiguration.getDataSource();
if (dataSource != null) {
variablesHintLabel.setResolver(new DataSourceVariableResolver(dataSource, dataSource.getConnectionConfiguration()));
}
}
use of org.jkiss.dbeaver.model.connection.DataSourceVariableResolver in project dbeaver by serge-rider.
the class ConnectionPageAbstract method loadSettings.
@Override
public void loadSettings() {
DBPDriver driver = site.getDriver();
if (driver != null && driverText != null) {
driverText.setText(CommonUtils.toString(driver.getFullName()));
}
DataSourceDescriptor dataSource = (DataSourceDescriptor) getSite().getActiveDataSource();
if (savePasswordCheck != null) {
if (dataSource != null) {
savePasswordCheck.setSelection(dataSource.isSavePassword());
} else {
savePasswordCheck.setSelection(true);
}
}
if (variablesHintLabel != null) {
if (dataSource != null) {
variablesHintLabel.setResolver(new DataSourceVariableResolver(dataSource, dataSource.getConnectionConfiguration()));
} else {
variablesHintLabel.setResolver(null);
}
}
}
use of org.jkiss.dbeaver.model.connection.DataSourceVariableResolver in project dbeaver by dbeaver.
the class SSHTunnelConfiguratorUI method testTunnelConnection.
private void testTunnelConnection() {
DBWHandlerConfiguration configuration = new DBWHandlerConfiguration(savedConfiguration);
configuration.setProperties(Collections.emptyMap());
saveSettings(configuration);
DBPDataSourceContainer dataSource = configuration.getDataSource();
if (dataSource != null) {
configuration.resolveDynamicVariables(new DataSourceVariableResolver(dataSource, dataSource.getConnectionConfiguration()));
} else {
configuration.resolveDynamicVariables(SystemVariablesResolver.INSTANCE);
}
try {
final String[] tunnelVersions = new String[2];
UIUtils.runInProgressDialog(monitor -> {
monitor.beginTask("Instantiate SSH tunnel", 2);
SSHTunnelImpl tunnel = new SSHTunnelImpl();
DBPConnectionConfiguration connectionConfig = new DBPConnectionConfiguration();
connectionConfig.setHostName("localhost");
connectionConfig.setHostPort(configuration.getStringProperty(DBWHandlerConfiguration.PROP_PORT));
try {
monitor.subTask("Initialize tunnel");
tunnel.initializeHandler(monitor, DBWorkbench.getPlatform(), configuration, connectionConfig);
monitor.worked(1);
// Get info
tunnelVersions[0] = tunnel.getImplementation().getClientVersion();
tunnelVersions[1] = tunnel.getImplementation().getServerVersion();
// Close it
monitor.subTask("Close tunnel");
tunnel.closeTunnel(monitor);
monitor.worked(1);
} catch (Exception e) {
throw new InvocationTargetException(e);
}
monitor.done();
});
MessageDialog.openInformation(hostText.getShell(), ModelMessages.dialog_connection_wizard_start_connection_monitor_success, "Connected!\n\nClient version: " + tunnelVersions[0] + "\nServer version: " + tunnelVersions[1]);
} catch (InvocationTargetException ex) {
DBWorkbench.getPlatformUI().showError(CoreMessages.dialog_connection_wizard_start_dialog_error_title, null, GeneralUtils.makeExceptionStatus(ex.getTargetException()));
}
}
use of org.jkiss.dbeaver.model.connection.DataSourceVariableResolver in project dbeaver by dbeaver.
the class SSHTunnelConfiguratorUI method loadSettings.
@Override
public void loadSettings(DBWHandlerConfiguration configuration) {
hostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(DBWHandlerConfiguration.PROP_HOST)));
int portString = configuration.getIntProperty(DBWHandlerConfiguration.PROP_PORT);
if (portString != 0) {
portText.setSelection(portString);
} else {
portText.setSelection(SSHConstants.DEFAULT_SSH_PORT);
}
userNameText.setText(CommonUtils.notEmpty(configuration.getUserName()));
SSHConstants.AuthType authType = SSHConstants.AuthType.PASSWORD;
String authTypeName = configuration.getStringProperty(SSHConstants.PROP_AUTH_TYPE);
if (!CommonUtils.isEmpty(authTypeName)) {
authType = SSHConstants.AuthType.valueOf(authTypeName);
}
if (SSHConstants.AuthType.PASSWORD.equals(authType)) {
authMethodCombo.select(0);
} else if (SSHConstants.AuthType.PUBLIC_KEY.equals(authType)) {
authMethodCombo.select(1);
} else {
authMethodCombo.select(2);
}
privateKeyText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_KEY_PATH)));
passwordText.setText(CommonUtils.notEmpty(configuration.getPassword()));
savePasswordCheckbox.setSelection(configuration.isSavePassword());
String implType = configuration.getStringProperty(SSHConstants.PROP_IMPLEMENTATION);
if (CommonUtils.isEmpty(implType)) {
tunnelImplCombo.select(0);
} else {
SSHImplementationDescriptor desc = SSHImplementationRegistry.getInstance().getDescriptor(implType);
if (desc != null) {
tunnelImplCombo.setText(desc.getLabel());
} else {
tunnelImplCombo.select(0);
}
}
localHostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_LOCAL_HOST)));
int lpValue = configuration.getIntProperty(SSHConstants.PROP_LOCAL_PORT);
if (lpValue != 0) {
localPortSpinner.setSelection(lpValue);
}
remoteHostText.setText(CommonUtils.notEmpty(configuration.getStringProperty(SSHConstants.PROP_REMOTE_HOST)));
int rpValue = configuration.getIntProperty(SSHConstants.PROP_REMOTE_PORT);
if (rpValue != 0) {
remotePortSpinner.setSelection(rpValue);
}
int kaValue = configuration.getIntProperty(SSHConstants.PROP_ALIVE_INTERVAL);
if (kaValue != 0) {
keepAliveText.setSelection(kaValue);
}
int timeoutValue = configuration.getIntProperty(SSHConstants.PROP_CONNECT_TIMEOUT);
if (timeoutValue != 0) {
tunnelTimeout.setSelection(timeoutValue);
}
updateAuthMethodVisibility();
savedConfiguration = new DBWHandlerConfiguration(configuration);
DBPDataSourceContainer dataSource = savedConfiguration.getDataSource();
if (dataSource != null) {
variablesHintLabel.setResolver(new DataSourceVariableResolver(dataSource, dataSource.getConnectionConfiguration()));
}
}
Aggregations