use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class ConnectionPageNetworkHandler method updateProfileList.
private void updateProfileList() {
DBPConnectionConfiguration cfg = site.getActiveDataSource().getConnectionConfiguration();
String profileId = cfg.getConfigProfileName();
activeProfile = CommonUtils.isEmpty(profileId) ? null : site.getProject().getDataSourceRegistry().getNetworkProfile(profileId);
// Refresh profile list
profileCombo.removeAll();
profileCombo.add("");
for (DBWNetworkProfile profile : site.getProject().getDataSourceRegistry().getNetworkProfiles()) {
profileCombo.add(profile.getProfileName());
if (CommonUtils.equalObjects(profileId, profile.getProfileName())) {
profileCombo.select(profileCombo.getItemCount() - 1);
}
}
// Update settings from profile
if (activeProfile != null) {
}
// Update page controls
handlerConfiguration = cfg.getHandler(handlerDescriptor.getId());
if (handlerConfiguration == null) {
handlerConfiguration = new DBWHandlerConfiguration(handlerDescriptor, site.getActiveDataSource());
}
useHandlerCheck.setSelection(handlerConfiguration.isEnabled());
configurator.loadSettings(handlerConfiguration);
enableHandlerContent();
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class ConnectionPageNetworkHandler method setConnectionConfigProfile.
private void setConnectionConfigProfile(String profileName) {
activeProfile = CommonUtils.isEmpty(profileName) ? null : site.getProject().getDataSourceRegistry().getNetworkProfile(profileName);
DBPDataSourceContainer dataSource = site.getActiveDataSource();
DBPConnectionConfiguration cfg = dataSource.getConnectionConfiguration();
String oldProfileId = cfg.getConfigProfileName();
saveSettings(site.getActiveDataSource());
if (activeProfile != null) {
cfg.setConfigProfile(activeProfile);
handlerConfiguration = cfg.getHandler(handlerDescriptor.getId());
if (handlerConfiguration == null) {
handlerConfiguration = new DBWHandlerConfiguration(handlerDescriptor, dataSource);
}
} else {
cfg.setConfigProfile(null);
}
site.firePropertyChange(this, PROP_CONFIG_PROFILE, oldProfileId, activeProfile == null ? null : activeProfile.getProfileName());
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
the class ConnectionPageNetworkHandler method createControl.
@Override
public void createControl(Composite parent) {
try {
String implName = handlerDescriptor.getHandlerType().getImplName();
UIPropertyConfiguratorDescriptor configDescriptor = UIPropertyConfiguratorRegistry.getInstance().getDescriptor(implName);
if (configDescriptor == null) {
return;
}
configurator = configDescriptor.createConfigurator();
} catch (DBException e) {
log.error("Can't create network configurator '" + handlerDescriptor.getId() + "'", e);
return;
}
DBPDataSourceContainer dataSource = site.getActiveDataSource();
DBPConnectionConfiguration connectionConfiguration = dataSource.getConnectionConfiguration();
handlerConfiguration = connectionConfiguration.getHandler(handlerDescriptor.getId());
if (handlerConfiguration == null) {
handlerConfiguration = new DBWHandlerConfiguration(handlerDescriptor, dataSource);
connectionConfiguration.updateHandler(handlerConfiguration);
}
Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite buttonsGroup = UIUtils.createComposite(composite, 5);
buttonsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
useHandlerCheck = UIUtils.createCheckbox(buttonsGroup, NLS.bind(CoreMessages.dialog_tunnel_checkbox_use_handler, handlerDescriptor.getLabel()), false);
useHandlerCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
handlerConfiguration.setEnabled(useHandlerCheck.getSelection());
enableHandlerContent();
}
});
UIUtils.createEmptyLabel(buttonsGroup, 1, 1).setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
profileCombo = UIUtils.createLabelCombo(buttonsGroup, "Profile", SWT.READ_ONLY | SWT.DROP_DOWN);
GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
gd.widthHint = 200;
profileCombo.setLayoutData(gd);
profileCombo.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setConnectionConfigProfile(profileCombo.getText());
}
});
ToolBar editToolbar = new ToolBar(buttonsGroup, SWT.HORIZONTAL);
ToolItem editItem = new ToolItem(editToolbar, SWT.PUSH);
editItem.setImage(DBeaverIcons.getImage(UIIcon.EDIT));
editItem.setToolTipText("Edit profiles");
editItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
PreferenceDialog preferenceDialog = PreferencesUtil.createPropertyDialogOn(getShell(), site.getProject().getEclipseProject(), PrefPageProjectNetworkProfiles.PAGE_ID, null, null);
if (preferenceDialog != null) {
if (preferenceDialog.open() == IDialogConstants.OK_ID) {
setConnectionConfigProfile(profileCombo.getText());
}
}
}
});
handlerComposite = UIUtils.createComposite(composite, 1);
handlerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
configurator.createControl(handlerComposite, this::updatePageCompletion);
configurator.loadSettings(handlerConfiguration);
useHandlerCheck.setSelection(handlerConfiguration.isEnabled());
enableHandlerContent();
updateProfileList();
if (activeProfile != null) {
DBWHandlerConfiguration profileConfig = activeProfile.getConfiguration(handlerDescriptor);
if (profileConfig != null) {
configurator.loadSettings(profileConfig);
}
}
setControl(composite);
}
use of org.jkiss.dbeaver.model.connection.DBPConnectionConfiguration in project dbeaver by dbeaver.
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 dbeaver.
the class ConnectionPageGeneral method saveSettings.
@Override
public void saveSettings(DBPDataSourceContainer dataSource) {
if (dataSourceDescriptor != null && !activated) {
// No changes anyway
return;
}
final DBPConnectionConfiguration confConfig = dataSource.getConnectionConfiguration();
String name = connectionNameChanged ? connectionNameText.getText() : generateConnectionName(getWizard().getPageSettings());
dataSource.setName(name);
dataSource.setFolder(dataSourceFolder);
if (connectionTypeCombo.getSelectionIndex() >= 0) {
confConfig.setConnectionType(connectionTypeCombo.getItem(connectionTypeCombo.getSelectionIndex()));
}
DataSourceDescriptor dsDescriptor = (DataSourceDescriptor) dataSource;
final String description = descriptionText.getText();
if (description.isEmpty()) {
dsDescriptor.setDescription(null);
} else {
dsDescriptor.setDescription(description);
}
if (this.navigatorSettings == null) {
this.navigatorSettings = new DataSourceNavigatorSettings(getWizard().getSelectedNavigatorSettings());
}
dsDescriptor.setNavigatorSettings(this.navigatorSettings);
dsDescriptor.setConnectionReadOnly(this.readOnlyConnection.getSelection());
dsDescriptor.setModifyPermissions(this.accessRestrictions);
for (FilterInfo filterInfo : filters) {
if (filterInfo.filter != null) {
dataSource.setObjectFilter(filterInfo.type, null, filterInfo.filter);
}
}
}
Aggregations