use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.
the class PrefPageProjectNetworkProfiles method enableHandlerContent.
private void enableHandlerContent(NetworkHandlerDescriptor descriptor) {
HandlerBlock handlerBlock = configurations.get(descriptor);
DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(selectedProfile);
handlerBlock.useHandlerCheck.setSelection(handlerConfiguration != null && handlerConfiguration.isEnabled());
if (handlerConfiguration != null && handlerConfiguration.isEnabled()) {
if (handlerBlock.blockEnableState != null) {
handlerBlock.blockEnableState.restore();
handlerBlock.blockEnableState = null;
}
} else if (handlerBlock.blockEnableState == null) {
handlerBlock.blockEnableState = ControlEnableState.disable(handlerBlock.blockControl);
}
}
use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.
the class PrefPageProjectNetworkProfiles method createHandlerTab.
private void createHandlerTab(final NetworkHandlerDescriptor descriptor) {
IObjectPropertyConfigurator<DBWHandlerConfiguration> configurator;
try {
String implName = descriptor.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 '" + descriptor.getId() + "'", e);
return;
}
allHandlers.add(descriptor);
TabItem tabItem = new TabItem(handlersFolder, SWT.NONE);
tabItem.setText(descriptor.getLabel());
tabItem.setToolTipText(descriptor.getDescription());
tabItem.setData(descriptor);
Composite composite = new Composite(handlersFolder, SWT.NONE);
tabItem.setControl(composite);
composite.setLayout(new GridLayout(1, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
final Button useHandlerCheck = UIUtils.createCheckbox(composite, NLS.bind(CoreMessages.dialog_tunnel_checkbox_use_handler, descriptor.getLabel()), false);
useHandlerCheck.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (selectedProfile == null) {
useHandlerCheck.setSelection(false);
UIUtils.showMessageBox(getShell(), "No profile", "Select existing profile or create a new one", SWT.ICON_INFORMATION);
return;
}
HandlerBlock handlerBlock = configurations.get(descriptor);
DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(selectedProfile);
if (handlerConfiguration == null) {
handlerConfiguration = new DBWHandlerConfiguration(descriptor, null);
handlerBlock.loadedConfigs.put(selectedProfile, handlerConfiguration);
}
handlerConfiguration.setEnabled(useHandlerCheck.getSelection());
enableHandlerContent(descriptor);
}
});
Composite handlerComposite = UIUtils.createPlaceholder(composite, 1);
configurations.put(descriptor, new HandlerBlock(configurator, handlerComposite, useHandlerCheck));
handlerComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
configurator.createControl(handlerComposite, this::updateApplyButton);
enableHandlerContent(descriptor);
}
use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.
the class PrefPageProjectNetworkProfiles method saveHandlerSettings.
/**
* Saves state of UI controls to handler configuration
*/
private void saveHandlerSettings() {
if (selectedProfile == null) {
return;
}
for (TabItem handlerTab : handlersFolder.getItems()) {
NetworkHandlerDescriptor handler = (NetworkHandlerDescriptor) handlerTab.getData();
HandlerBlock handlerBlock = configurations.get(handler);
DBWHandlerConfiguration handlerConfiguration = handlerBlock.loadedConfigs.get(selectedProfile);
if (handlerBlock.useHandlerCheck.getSelection()) {
if (handlerConfiguration == null) {
handlerConfiguration = new DBWHandlerConfiguration(handler, null);
}
handlerConfiguration.setProperties(Collections.emptyMap());
handlerBlock.configurator.saveSettings(handlerConfiguration);
}
}
}
use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.
the class SQLServerDataSource method getAllConnectionProperties.
@Override
protected Properties getAllConnectionProperties(@NotNull DBRProgressMonitor monitor, JDBCExecutionContext context, String purpose, DBPConnectionConfiguration connectionInfo) throws DBCException {
Properties properties = super.getAllConnectionProperties(monitor, context, purpose, connectionInfo);
if (!getContainer().getPreferenceStore().getBoolean(ModelPreferences.META_CLIENT_NAME_DISABLE)) {
// App name
properties.put(SQLServerUtils.isDriverJtds(getContainer().getDriver()) ? SQLServerConstants.APPNAME_CLIENT_PROPERTY : SQLServerConstants.APPLICATION_NAME_CLIENT_PROPERTY, CommonUtils.truncateString(DBUtils.getClientApplicationName(getContainer(), context, purpose), 64));
}
fillConnectionProperties(connectionInfo, properties);
SQLServerAuthentication authSchema = SQLServerUtils.detectAuthSchema(connectionInfo);
authSchema.getInitializer().initializeAuthentication(connectionInfo, properties);
final DBWHandlerConfiguration sslConfig = getContainer().getActualConnectionConfiguration().getHandler(SQLServerConstants.HANDLER_SSL);
if (sslConfig != null && sslConfig.isEnabled()) {
initSSL(monitor, properties, sslConfig);
}
return properties;
}
use of org.jkiss.dbeaver.model.net.DBWHandlerConfiguration in project dbeaver by serge-rider.
the class MySQLDataSource method getInternalConnectionProperties.
@Override
protected Map<String, String> getInternalConnectionProperties(DBRProgressMonitor monitor, DBPDriver driver, JDBCExecutionContext context, String purpose, DBPConnectionConfiguration connectionInfo) throws DBCException {
Map<String, String> props = new LinkedHashMap<>(MySQLDataSourceProvider.getConnectionsProps());
final DBWHandlerConfiguration sslConfig = getContainer().getActualConnectionConfiguration().getHandler(MySQLConstants.HANDLER_SSL);
if (sslConfig != null && sslConfig.isEnabled()) {
try {
initSSL(monitor, props, sslConfig);
} catch (Exception e) {
throw new DBCException("Error configuring SSL certificates", e);
}
} else {
// Newer MySQL servers/connectors requires explicit SSL disable
props.put("useSSL", "false");
}
String serverTZ = connectionInfo.getProviderProperty(MySQLConstants.PROP_SERVER_TIMEZONE);
if (CommonUtils.isEmpty(serverTZ) && inServerTimezoneHandle) /*&& getContainer().getDriver().getId().equals(MySQLConstants.DRIVER_ID_MYSQL8)*/
{
serverTZ = "UTC";
}
if (!CommonUtils.isEmpty(serverTZ)) {
props.put("serverTimezone", serverTZ);
}
if (!isMariaDB()) {
// Hacking different MySQL drivers zeroDateTimeBehavior property (#4103)
String zeroDateTimeBehavior = connectionInfo.getProperty(MySQLConstants.PROP_ZERO_DATETIME_BEHAVIOR);
if (zeroDateTimeBehavior == null) {
try {
Driver driverInstance = (Driver) driver.getDriverInstance(monitor);
if (driverInstance != null) {
if (driverInstance.getMajorVersion() >= 8) {
props.put(MySQLConstants.PROP_ZERO_DATETIME_BEHAVIOR, "CONVERT_TO_NULL");
} else {
props.put(MySQLConstants.PROP_ZERO_DATETIME_BEHAVIOR, "convertToNull");
}
}
} catch (Exception e) {
log.debug("Error setting MySQL " + MySQLConstants.PROP_ZERO_DATETIME_BEHAVIOR + " property default");
}
}
}
return props;
}
Aggregations