use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class SQLServerConnectionPage method loadSettings.
@Override
public void loadSettings() {
super.loadSettings();
boolean isDriverAzure = isSqlServer() && isDriverAzure();
// Load values from new connection info
DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
if (hostText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostName())) {
hostText.setText(connectionInfo.getHostName());
} else {
hostText.setText(isDriverAzure ? SQLServerConstants.DEFAULT_HOST_AZURE : SQLServerConstants.DEFAULT_HOST);
}
}
if (portText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
portText.setText(String.valueOf(connectionInfo.getHostPort()));
} else if (site.getDriver().getDefaultPort() != null) {
portText.setText(site.getDriver().getDefaultPort());
} else {
portText.setText("");
}
}
if (dbText != null) {
String databaseName = connectionInfo.getDatabaseName();
if (getSite().isNew() && CommonUtils.isEmpty(databaseName)) {
databaseName = CommonUtils.notEmpty(site.getDriver().getDefaultDatabase());
}
dbText.setText(CommonUtils.notEmpty(databaseName));
}
if (userNameText != null) {
if (site.isNew() && CommonUtils.isEmpty(connectionInfo.getUserName())) {
userNameText.setText(CommonUtils.notEmpty(site.getDriver().getDefaultUser()));
} else {
userNameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
}
}
if (passwordText != null) {
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
}
if (authCombo != null) {
authCombo.select(ArrayUtils.indexOf(authSchemas, SQLServerUtils.detectAuthSchema(connectionInfo)));
updateSecurityControls();
}
/*
if (windowsAuthenticationButton != null) {
windowsAuthenticationButton.setSelection(SQLServerUtils.isWindowsAuth(connectionInfo));
enableTexts();
}
if (adpAuthenticationButton != null) {
adpAuthenticationButton.setSelection(SQLServerUtils.isActiveDirectoryAuth(connectionInfo));
}
*/
showAllSchemas.setSelection(CommonUtils.toBoolean(connectionInfo.getProviderProperty(SQLServerConstants.PROP_SHOW_ALL_SCHEMAS)));
activated = true;
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class PostgreConnectionPageAdvanced method saveSettings.
@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
DBPConnectionConfiguration connectionCfg = dataSource.getConnectionConfiguration();
connectionCfg.setProviderProperty(PostgreConstants.PROP_SHOW_NON_DEFAULT_DB, String.valueOf(showNonDefault.getSelection()));
connectionCfg.setProviderProperty(PostgreConstants.PROP_SHOW_TEMPLATES_DB, String.valueOf(showTemplates.getSelection()));
connectionCfg.setProviderProperty(PostgreConstants.PROP_SHOW_UNAVAILABLE_DB, String.valueOf(showUnavailable.getSelection()));
connectionCfg.setProviderProperty(PostgreConstants.PROP_DD_PLAIN_STRING, String.valueOf(ddPlainBehaviorCombo.getSelectionIndex() == 0));
connectionCfg.setProviderProperty(PostgreConstants.PROP_DD_TAG_STRING, String.valueOf(ddTagBehaviorCombo.getSelectionIndex() == 0));
saveConnectionURL(connectionCfg);
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class PostgreToolWizardPageSettings method createSecurityGroup.
public void createSecurityGroup(Composite parent) {
try {
final SecuredPasswordEncrypter encrypter = new SecuredPasswordEncrypter();
final DBPConnectionConfiguration connectionInfo = wizard.getSettings().getDataSourceContainer().getActualConnectionConfiguration();
final String authProperty = DBConstants.INTERNAL_PROP_PREFIX + "-auth-" + wizard.getObjectsName() + "@";
String authUser = null;
String authPassword = null;
{
String authValue = connectionInfo.getProviderProperty(authProperty);
if (authValue != null) {
String authCredentials = encrypter.decrypt(authValue);
int divPos = authCredentials.indexOf(':');
if (divPos != -1) {
authUser = authCredentials.substring(0, divPos);
authPassword = authCredentials.substring(divPos + 1);
}
}
}
final boolean savePassword = authUser != null;
Group securityGroup = UIUtils.createControlGroup(parent, PostgreMessages.wizard_backup_page_setting_group_security, 2, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
Label infoLabel = new Label(securityGroup, SWT.NONE);
infoLabel.setText(NLS.bind(PostgreMessages.wizard_backup_page_setting_group_security_label_info, connectionInfo.getUserName(), wizard.getObjectsName()));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
infoLabel.setLayoutData(gd);
Button authButton = new Button(securityGroup, SWT.PUSH);
authButton.setText(PostgreMessages.wizard_backup_page_setting_group_security_btn_authentication);
authButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BaseAuthDialog authDialog = new BaseAuthDialog(getShell(), PostgreMessages.wizard_backup_page_setting_group_security_btn_authentication, false, true);
authDialog.setUserName(wizard.getSettings().getToolUserName());
authDialog.setUserPassword(wizard.getSettings().getToolUserPassword());
authDialog.setSavePassword(savePassword);
authDialog.setSavePasswordText(PostgreMessages.wizard_backup_page_setting_authentication_save_password);
authDialog.setSavePasswordToolTipText(PostgreMessages.wizard_backup_page_setting_authentication_save_password_tip);
if (authDialog.open() == IDialogConstants.OK_ID) {
wizard.getSettings().setToolUserName(authDialog.getUserName());
wizard.getSettings().setToolUserPassword(authDialog.getUserPassword());
}
}
});
Button resetButton = new Button(securityGroup, SWT.PUSH);
resetButton.setText(PostgreMessages.wizard_backup_page_setting_group_security_btn_reset_default);
resetButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
connectionInfo.getProviderProperties().remove(authProperty);
wizard.getSettings().setToolUserName(null);
wizard.getSettings().setToolUserPassword(null);
}
});
} catch (EncryptionException e) {
// Never be here
}
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class PostgreConnectionPage method saveSettings.
@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
DBPConnectionConfiguration connectionInfo = dataSource.getConnectionConfiguration();
if (hostText != null) {
connectionInfo.setHostName(hostText.getText().trim());
}
if (portText != null) {
connectionInfo.setHostPort(portText.getText().trim());
}
if (dbText != null) {
connectionInfo.setDatabaseName(dbText.getText().trim());
}
if (roleText != null) {
connectionInfo.setProviderProperty(PostgreConstants.PROP_CHOSEN_ROLE, roleText.getText().trim());
}
if (homesSelector != null) {
connectionInfo.setClientHomeId(homesSelector.getSelectedHome());
}
super.saveSettings(dataSource);
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class GenericConnectionPage method loadSettings.
@Override
public void loadSettings() {
super.loadSettings();
// Load values from new connection info
DBPConnectionConfiguration connectionInfo = site.getActiveDataSource().getConnectionConfiguration();
this.parseSampleURL(site.getDriver());
if (!isCustom) {
if (hostText != null) {
if (!CommonUtils.isEmpty(connectionInfo.getHostName())) {
hostText.setText(CommonUtils.notEmpty(connectionInfo.getHostName()));
} else {
// $NON-NLS-1$
hostText.setText("localhost");
}
}
if (portText != null) {
if (site.isNew() && CommonUtils.isEmpty(connectionInfo.getHostPort())) {
portText.setText(CommonUtils.notEmpty(site.getDriver().getDefaultPort()));
} else if (!CommonUtils.isEmpty(connectionInfo.getHostPort())) {
portText.setText(connectionInfo.getHostPort());
}
}
if (serverText != null) {
if (site.isNew() && CommonUtils.isEmpty(connectionInfo.getServerName())) {
serverText.setText(CommonUtils.notEmpty(site.getDriver().getDefaultServer()));
} else {
serverText.setText(CommonUtils.notEmpty(connectionInfo.getServerName()));
}
}
if (dbText != null) {
if (site.isNew() && CommonUtils.isEmpty(connectionInfo.getDatabaseName())) {
dbText.setText(CommonUtils.notEmpty(site.getDriver().getDefaultDatabase()));
} else {
dbText.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
}
}
if (pathText != null) {
pathText.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
}
} else {
// $NON-NLS-1$
hostText.setText("");
// $NON-NLS-1$
portText.setText("");
// $NON-NLS-1$
serverText.setText("");
// $NON-NLS-1$
dbText.setText("");
// $NON-NLS-1$
pathText.setText("");
}
if (urlText != null) {
if (CommonUtils.isEmpty(connectionInfo.getUrl())) {
try {
saveSettings(site.getActiveDataSource());
} catch (Exception e) {
setMessage(e.getMessage());
}
}
if (connectionInfo.getUrl() != null) {
urlText.setText(CommonUtils.notEmpty(connectionInfo.getUrl()));
} else {
// $NON-NLS-1$
urlText.setText("");
}
}
activated = true;
UIUtils.asyncExec(() -> {
// Set first control
if (CommonUtils.isEmpty(site.getDriver().getSampleURL())) {
urlText.setFocus();
} else if (hostText != null && hostText.isVisible()) {
hostText.setFocus();
} else if (serverText != null && serverText.isVisible()) {
serverText.setFocus();
} else if (dbText != null && dbText.isVisible()) {
dbText.setFocus();
} else if (pathText != null && pathText.isVisible()) {
pathText.setFocus();
}
});
}
Aggregations