use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class ConnectionPageGeneral method activatePage.
@Override
public void activatePage() {
if (this.navigatorSettings == null) {
this.navigatorSettings = new DataSourceNavigatorSettings(getWizard().getSelectedNavigatorSettings());
}
if (connectionNameText != null) {
if (dataSourceDescriptor != null && !CommonUtils.isEmpty(dataSourceDescriptor.getName())) {
connectionNameText.setText(dataSourceDescriptor.getName());
connectionNameChanged = true;
} else {
ConnectionPageSettings settings = wizard.getPageSettings();
if (CommonUtils.isEmpty(connectionNameText.getText()) || !connectionNameChanged) {
String newName = generateConnectionName(settings);
if (newName != null) {
connectionNameText.setText(newName);
}
connectionNameChanged = false;
}
}
}
if (dataSourceDescriptor != null) {
if (!activated) {
// Get settings from data source descriptor
final DBPConnectionConfiguration conConfig = dataSourceDescriptor.getConnectionConfiguration();
connectionTypeCombo.select(conConfig.getConnectionType());
updateNavigatorSettingsPreset();
dataSourceFolder = dataSourceDescriptor.getFolder();
if (dataSourceDescriptor.getFolder() == null) {
connectionFolderCombo.select(0);
} else {
connectionFolderCombo.select(connectionFolders.indexOf(dataSourceFolder));
}
if (dataSourceDescriptor.getDescription() != null) {
descriptionText.setText(dataSourceDescriptor.getDescription());
}
readOnlyConnection.setSelection(dataSourceDescriptor.isConnectionReadOnly());
activated = true;
}
} else {
// Default settings
connectionTypeCombo.select(0);
if (dataSourceFolder != null) {
connectionFolderCombo.select(connectionFolders.indexOf(dataSourceFolder));
} else {
connectionFolderCombo.select(0);
}
readOnlyConnection.setSelection(false);
}
long features = getWizard().getSelectedDriver().getDataSourceProvider().getFeatures();
for (FilterInfo filterInfo : filters) {
if (DBSCatalog.class.isAssignableFrom(filterInfo.type)) {
enableFilter(filterInfo, (features & DBPDataSourceProvider.FEATURE_CATALOGS) != 0);
} else if (DBSSchema.class.isAssignableFrom(filterInfo.type)) {
enableFilter(filterInfo, (features & DBPDataSourceProvider.FEATURE_SCHEMAS) != 0);
} else {
enableFilter(filterInfo, true);
}
}
filtersGroup.layout();
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
the class DataSourceDescriptorManager method createNewObject.
@Override
public DataSourceDescriptor createNewObject(DBRProgressMonitor monitor, DBECommandContext commandContext, Object container, Object copyFrom, Map<String, Object> options) {
if (copyFrom != null) {
DataSourceDescriptor dsTpl = (DataSourceDescriptor) copyFrom;
DBPDataSourceRegistry registry;
DBPDataSourceFolder folder = null;
if (container instanceof DataSourceRegistry) {
registry = (DBPDataSourceRegistry) container;
} else if (container instanceof DBPProject) {
registry = ((DBPProject) container).getDataSourceRegistry();
} else if (container instanceof DBPDataSourceFolder) {
folder = (DBPDataSourceFolder) container;
registry = folder.getDataSourceRegistry();
} else {
registry = dsTpl.getRegistry();
}
DataSourceDescriptor dataSource = new DataSourceDescriptor(registry, DataSourceDescriptor.generateNewId(dsTpl.getDriver()), dsTpl.getDriver(), new DBPConnectionConfiguration(dsTpl.getConnectionConfiguration()));
dataSource.copyFrom(dsTpl);
if (folder != null) {
dataSource.setFolder(folder);
} else if (dsTpl.getRegistry() == registry) {
// Copy folder only if we copy in the same project
dataSource.setFolder(dsTpl.getFolder());
}
// Generate new name
String origName = dsTpl.getName();
String newName = origName;
for (int i = 0; ; i++) {
if (registry.findDataSourceByName(newName) == null) {
break;
}
newName = origName + " " + (i + 1);
}
dataSource.setName(newName);
registry.addDataSource(dataSource);
} else {
UIUtils.asyncExec(() -> NewConnectionDialog.openNewConnectionDialog(UIUtils.getActiveWorkbenchWindow()));
}
return null;
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by serge-rider.
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 serge-rider.
the class MySQLConnectionPage 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 (serverTimezoneCombo != null) {
String serverTimeZone = serverTimezoneCombo.getText();
if (CommonUtils.isEmpty(serverTimeZone) || serverTimeZone.equals(MySQLUIMessages.dialog_connection_auto_detect)) {
connectionInfo.removeProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE);
} else {
connectionInfo.setProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE, serverTimeZone);
}
}
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 DataSourceDescriptorManager method createNewObject.
@Override
public DataSourceDescriptor createNewObject(DBRProgressMonitor monitor, DBECommandContext commandContext, Object container, Object copyFrom, Map<String, Object> options) {
if (copyFrom != null) {
DataSourceDescriptor dsTpl = (DataSourceDescriptor) copyFrom;
DBPDataSourceRegistry registry;
DBPDataSourceFolder folder = null;
if (container instanceof DataSourceRegistry) {
registry = (DBPDataSourceRegistry) container;
} else if (container instanceof DBPProject) {
registry = ((DBPProject) container).getDataSourceRegistry();
} else if (container instanceof DBPDataSourceFolder) {
folder = (DBPDataSourceFolder) container;
registry = folder.getDataSourceRegistry();
} else {
registry = dsTpl.getRegistry();
}
DataSourceDescriptor dataSource = new DataSourceDescriptor(registry, DataSourceDescriptor.generateNewId(dsTpl.getDriver()), dsTpl.getDriver(), new DBPConnectionConfiguration(dsTpl.getConnectionConfiguration()));
dataSource.copyFrom(dsTpl);
if (folder != null) {
dataSource.setFolder(folder);
} else if (dsTpl.getRegistry() == registry) {
// Copy folder only if we copy in the same project
dataSource.setFolder(dsTpl.getFolder());
}
// Generate new name
String origName = dsTpl.getName();
String newName = origName;
for (int i = 0; ; i++) {
if (registry.findDataSourceByName(newName) == null) {
break;
}
newName = origName + " " + (i + 1);
}
dataSource.setName(newName);
registry.addDataSource(dataSource);
} else {
UIUtils.asyncExec(() -> NewConnectionDialog.openNewConnectionDialog(UIUtils.getActiveWorkbenchWindow()));
}
return null;
}
Aggregations