use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.
the class PrefPageDataFormat method reloadFormatter.
private void reloadFormatter() {
DataFormatterDescriptor formatterDescriptor = getCurrentFormatter();
if (formatterDescriptor == null) {
return;
}
Map<Object, Object> formatterProps = profileProperties.get(formatterDescriptor.getId());
Map<Object, Object> defaultProps = formatterDescriptor.getSample().getDefaultProperties(localeSelector.getSelectedLocale());
propertySource = new PropertySourceCustom(formatterDescriptor.getProperties(), formatterProps);
propertySource.setDefaultValues(defaultProps);
propertiesControl.loadProperties(propertySource);
reloadSample();
}
use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.
the class StreamConsumerPageSettings method activatePage.
@Override
public void activatePage() {
final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
DataTransferProcessorDescriptor processor = getWizard().getSettings().getProcessor();
propertySource = new PropertySourceCustom(processor.getProperties(), getWizard().getSettings().getProcessorProperties());
propsEditor.loadProperties(propertySource);
switch(settings.getLobExtractType()) {
case SKIP:
lobExtractType.select(EXTRACT_LOB_SKIP);
break;
case FILES:
lobExtractType.select(EXTRACT_LOB_FILES);
break;
case INLINE:
lobExtractType.select(EXTRACT_LOB_INLINE);
break;
}
switch(settings.getLobEncoding()) {
case BASE64:
lobEncodingCombo.select(LOB_ENCODING_BASE64);
break;
case HEX:
lobEncodingCombo.select(LOB_ENCODING_HEX);
break;
case BINARY:
lobEncodingCombo.select(LOB_ENCODING_BINARY);
break;
case NATIVE:
lobEncodingCombo.select(LOB_ENCODING_NATIVE);
break;
}
updatePageCompletion();
}
use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.
the class PostgreFDWConfigWizard method generateScript.
List<DBEPersistAction> generateScript(DBRProgressMonitor monitor) throws DBException {
PostgreDatabase database = getDatabase();
PostgreDataSource curDataSource = database.getDataSource();
List<DBEPersistAction> actions = new ArrayList<>();
PostgreFDWConfigWizard.FDWInfo selectedFDW = getSelectedFDW();
PropertySourceCustom propertySource = getFdwPropertySource();
Map<String, Object> propValues = propertySource.getPropertiesWithDefaults();
String serverId = getFdwServerId();
actions.add(new SQLDatabasePersistActionComment(curDataSource, "CREATE EXTENSION " + selectedFDW.getId()));
{
StringBuilder script = new StringBuilder();
script.append("CREATE SERVER ").append(serverId).append("\n\tFOREIGN DATA WRAPPER ").append(selectedFDW.getId()).append("\n\tOPTIONS(");
boolean firstProp = true;
for (Map.Entry<String, Object> pe : propValues.entrySet()) {
String propName = CommonUtils.toString(pe.getKey());
String propValue = CommonUtils.toString(pe.getValue());
if (CommonUtils.isEmpty(propName) || CommonUtils.isEmpty(propValue)) {
continue;
}
if (!firstProp)
script.append(", ");
script.append(propName).append(" '").append(propValue).append("'");
firstProp = false;
}
script.append(")");
actions.add(new SQLDatabasePersistAction("Create extension", script.toString()));
}
actions.add(new SQLDatabasePersistAction("CREATE USER MAPPING FOR CURRENT_USER SERVER " + serverId));
// Now tables
DBECommandContext commandContext = new SimpleCommandContext(getExecutionContext(), false);
try {
PostgreFDWConfigWizard.FDWInfo fdwInfo = getSelectedFDW();
Map<String, Object> options = new HashMap<>();
options.put(SQLObjectEditor.OPTION_SKIP_CONFIGURATION, true);
PostgreForeignTableManager tableManager = new PostgreForeignTableManager();
PostgreTableColumnManager columnManager = new PostgreTableColumnManager();
for (DBNDatabaseNode tableNode : getSelectedEntities()) {
DBSEntity entity = (DBSEntity) tableNode.getObject();
PostgreTableForeign pgTable = (PostgreTableForeign) tableManager.createNewObject(monitor, commandContext, getSelectedSchema(), null, options);
if (pgTable == null) {
log.error("Internal error while creating new table");
continue;
}
pgTable.setName(entity.getName());
pgTable.setForeignServerName(serverId);
pgTable.setForeignOptions(new String[0]);
for (DBSEntityAttribute attr : CommonUtils.safeCollection(entity.getAttributes(monitor))) {
// Cache data types
PostgreSchema catalogSchema = database.getCatalogSchema(monitor);
if (catalogSchema != null) {
catalogSchema.getDataTypes(monitor);
}
String defTypeName = DBStructUtils.mapTargetDataType(database, attr, true);
String plainTargetTypeName = SQLUtils.stripColumnTypeModifiers(defTypeName);
PostgreDataType dataType = database.getDataType(monitor, plainTargetTypeName);
if (dataType == null) {
log.error("Data type '" + plainTargetTypeName + "' not found. Skip column mapping.");
continue;
}
PostgreTableColumn newColumn = columnManager.createNewObject(monitor, commandContext, pgTable, null, options);
assert newColumn != null;
newColumn.setName(attr.getName());
newColumn.setDataType(dataType);
}
DBEPersistAction[] tableDDL = tableManager.getTableDDL(monitor, pgTable, options);
Collections.addAll(actions, tableDDL);
}
} finally {
commandContext.resetChanges(true);
}
// CREATE SERVER clickhouse_svr FOREIGN DATA WRAPPER clickhousedb_fdw OPTIONS(dbname 'default', driver '/usr/local/lib/odbc/libclickhouseodbc.so', host '46.101.202.143');
return actions;
}
use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.
the class PrefPageDataFormat method reloadFormatter.
private void reloadFormatter() {
DataFormatterDescriptor formatterDescriptor = getCurrentFormatter();
if (formatterDescriptor == null) {
return;
}
Map<String, Object> formatterProps = profileProperties.get(formatterDescriptor.getId());
Map<String, Object> defaultProps = formatterDescriptor.getSample().getDefaultProperties(localeSelector.getSelectedLocale());
propertySource = new PropertySourceCustom(formatterDescriptor.getProperties(), formatterProps);
propertySource.setDefaultValues(defaultProps);
propertiesControl.loadProperties(propertySource);
reloadSample();
}
use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by serge-rider.
the class DriverEditDialog method createParametersTab.
private void createParametersTab(TabFolder group) {
Composite paramsGroup = new Composite(group, SWT.NONE);
paramsGroup.setLayout(new GridLayout(1, false));
parametersEditor = new PropertyTreeViewer(paramsGroup, SWT.BORDER);
driverPropertySource = new PropertySourceCustom(driver.getProviderDescriptor().getDriverProperties(), driver.getDriverParameters());
driverPropertySource.addDefaultValues(driver.getDefaultDriverParameters());
parametersEditor.loadProperties(driverPropertySource);
TabItem paramsTab = new TabItem(group, SWT.NONE);
paramsTab.setText(UIConnectionMessages.dialog_edit_driver_tab_name_advanced_parameters);
paramsTab.setToolTipText(UIConnectionMessages.dialog_edit_driver_tab_tooltip_advanced_parameters);
paramsTab.setControl(paramsGroup);
}
Aggregations