use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class GenericConnectionPage method createEmbeddedDatabase.
private void createEmbeddedDatabase() {
String paramCreate = CommonUtils.toString(site.getDriver().getDriverParameter(GenericConstants.PARAM_CREATE_URL_PARAM));
DataSourceDescriptor dataSource = (DataSourceDescriptor) site.getActiveDataSource();
final DataSourceDescriptor testDataSource = new DataSourceDescriptor(site.getDataSourceRegistry(), dataSource.getId(), dataSource.getDriver(), new DBPConnectionConfiguration(dataSource.getConnectionConfiguration()));
saveSettings(testDataSource);
DBPConnectionConfiguration cfg = testDataSource.getConnectionConfiguration();
cfg.setDatabaseName(cfg.getDatabaseName() + paramCreate);
String databaseName = cfg.getDatabaseName();
testDataSource.setName(databaseName);
if (!UIUtils.confirmAction(getShell(), "Create Database", "Are you sure you want to create database '" + databaseName + "'?")) {
testDataSource.dispose();
return;
}
try {
site.getRunnableContext().run(true, true, monitor -> {
try {
createEmbeddedDatabase(monitor, testDataSource);
} catch (DBException e1) {
throw new InvocationTargetException(e1);
}
});
MessageDialog.openInformation(getShell(), "Database Create", "Database '" + databaseName + "' created!");
} catch (InvocationTargetException e1) {
DBWorkbench.getPlatformUI().showError("Create database", "Error creating database", e1.getTargetException());
} catch (InterruptedException e1) {
// Just ignore
}
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class MySQLWizardPageSettings method createSecurityGroup.
public void createSecurityGroup(Composite parent) {
final DBPConnectionConfiguration connectionInfo = wizard.getSettings().getDataSourceContainer().getActualConnectionConfiguration();
if (connectionInfo != null) {
Group securityGroup = UIUtils.createControlGroup(parent, MySQLUIMessages.tools_db_export_wizard_page_settings_security_group, 3, GridData.HORIZONTAL_ALIGN_BEGINNING, 0);
Label infoLabel = new Label(securityGroup, SWT.NONE);
infoLabel.setText(NLS.bind(MySQLUIMessages.tools_db_export_wizard_page_settings_security_label_info, connectionInfo.getUserName()));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 3;
infoLabel.setLayoutData(gd);
Button authButton = new Button(securityGroup, SWT.PUSH);
authButton.setText(MySQLUIMessages.tools_db_export_wizard_page_settings_security_button_auth);
authButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
BaseAuthDialog authDialog = new BaseAuthDialog(getShell(), MySQLUIMessages.tools_db_export_wizard_page_settings_auth_title, false, true);
authDialog.setUserName(wizard.getSettings().getToolUserName());
authDialog.setUserPassword(wizard.getSettings().getToolUserPassword());
authDialog.setSavePassword(true);
authDialog.setSavePasswordText(MySQLUIMessages.tools_db_export_wizard_page_settings_auth_save_password_checkbox);
authDialog.setSavePasswordToolTipText(MySQLUIMessages.tools_db_export_wizard_page_settings_auth_save_password_checkbox_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(MySQLUIMessages.tools_db_export_wizard_page_settings_security_button_reset);
resetButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
wizard.getSettings().setToolUserName(null);
wizard.getSettings().setToolUserPassword(null);
}
});
if (wizard.getSettings() instanceof MySQLNativeCredentialsSettings) {
MySQLNativeCredentialsSettings settings = (MySQLNativeCredentialsSettings) wizard.getSettings();
Button overrideCredentials = UIUtils.createCheckbox(securityGroup, MySQLUIMessages.tools_db_export_wizard_page_settings_security_checkbox_override_host_credentials, settings.isOverrideCredentials());
overrideCredentials.setToolTipText(MySQLUIMessages.tools_db_export_wizard_page_settings_security_checkbox_override_host_credentials_tip);
overrideCredentials.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
settings.setOverrideCredentials(overrideCredentials.getSelection());
}
});
}
}
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class WMIConnectionPage method loadSettings.
@Override
public void loadSettings() {
// Load values from new connection info
DBPDataSourceContainer activeDataSource = site.getActiveDataSource();
DBPConnectionConfiguration connectionInfo = activeDataSource.getConnectionConfiguration();
if (connectionInfo.getHostName() == null) {
connectionInfo.setHostName(DEFAULT_HOST);
}
if (connectionInfo.getDatabaseName() == null) {
connectionInfo.setDatabaseName(DEFAULT_NAMESPACE);
}
if (hostText != null) {
hostText.setText(CommonUtils.notEmpty(connectionInfo.getHostName()));
}
if (domainText != null) {
domainText.setText(CommonUtils.notEmpty(connectionInfo.getServerName()));
}
if (namespaceCombo != null) {
namespaceCombo.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
}
super.loadSettings();
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class DB2ConnectionPage 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 (usernameText != null) {
connectionInfo.setUserName(usernameText.getText().trim());
}
if (passwordText != null) {
connectionInfo.setUserPassword(passwordText.getText());
}
super.saveSettings(dataSource);
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class MySQLConnectionPage method loadSettings.
@Override
public void loadSettings() {
super.loadSettings();
DBPDriver driver = getSite().getDriver();
if (!activated) {
// There is a bug in Eclipse which leads to SWTException after wizard image change
if (driver != null && driver.getId().equalsIgnoreCase(MySQLConstants.DRIVER_ID_MARIA_DB)) {
setImageDescriptor(MARIADB_LOGO_IMG);
} else {
setImageDescriptor(MYSQL_LOGO_IMG);
}
}
// 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(MySQLConstants.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) {
dbText.setText(CommonUtils.notEmpty(connectionInfo.getDatabaseName()));
}
if (usernameText != null) {
usernameText.setText(CommonUtils.notEmpty(connectionInfo.getUserName()));
}
if (passwordText != null) {
passwordText.setText(CommonUtils.notEmpty(connectionInfo.getUserPassword()));
}
homesSelector.populateHomes(site.getDriver(), connectionInfo.getClientHomeId());
activated = true;
}
Aggregations