Search in sources :

Example 11 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.

the class PostgreFDWConfigWizardPageConfig method refreshFDWProperties.

private void refreshFDWProperties() {
    {
        // Fill options
        DBPDataSourceContainer targetDataSource = getWizard().getSelectedDataSource();
        PostgreFDWConfigWizard.FDWInfo selectedFDW = getWizard().getSelectedFDW();
        PropertySourceCustom propertySource = getWizard().getFdwPropertySource();
        propertySource.setDefValueResolver(targetDataSource.getVariablesResolver(false));
        propertySource.removeAll();
        if (selectedFDW != null && selectedFDW.fdwDescriptor != null) {
            propertySource.addProperties(selectedFDW.fdwDescriptor.getProperties());
        } else if (selectedFDW != null) {
            // Add some default props
            propertySource.addProperty(new PropertyDescriptor(null, "host", "host", "Remote database host", false, String.class, "${host}", null));
            propertySource.addProperty(new PropertyDescriptor(null, "port", "port", "Remote database port", false, String.class, "${port}", null));
            propertySource.addProperty(new PropertyDescriptor(null, "dbname", "dbname", "Remote database name", false, String.class, "${database}", null));
        }
        propsEditor.loadProperties(propertySource);
    }
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) PropertyDescriptor(org.jkiss.dbeaver.model.impl.PropertyDescriptor) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer)

Example 12 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.

the class TransformerSettingsDialog method loadTransformerSettings.

private void loadTransformerSettings(Collection<? extends DBPPropertyDescriptor> properties) {
    DBVTransformSettings settings = currentAttribute == null ? null : DBVUtils.getTransformSettings(currentAttribute, false);
    Map<String, Object> transformOptions = settings == null ? null : settings.getTransformOptions();
    if (transformOptions == null) {
        transformOptions = Collections.emptyMap();
    }
    propertySource = new PropertySourceCustom(properties, transformOptions);
    propertiesEditor.loadProperties(propertySource);
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) DBVTransformSettings(org.jkiss.dbeaver.model.virtual.DBVTransformSettings)

Example 13 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.

the class MockDataSettings method loadFrom.

public void loadFrom(IDialogSettings dialogSettings) {
    removeOldData = dialogSettings.getBoolean(PROP_REMOVE_OLD_DATA);
    try {
        rowsNumber = dialogSettings.getInt(PROP_ROWS_NUMBER);
    } catch (NumberFormatException e) {
    // do nothing
    }
    // load selected generators
    selectedAttribute = dialogSettings.get(KEY_SELECTED_ATTRIBUTE);
    VoidProgressMonitor voidProgressMonitor = new VoidProgressMonitor();
    IDialogSettings tableSection = UIUtils.getSettingsSection(dialogSettings, entity.getName());
    for (Map.Entry<String, AttributeGeneratorProperties> entry : attributeGenerators.entrySet()) {
        String attributeName = entry.getKey();
        IDialogSettings attributeSection = UIUtils.getSettingsSection(tableSection, attributeName);
        String selectedGeneratorId = attributeSection.get(KEY_SELECTED_GENERATOR);
        if (selectedGeneratorId != null) {
            AttributeGeneratorProperties attrGeneratorProperties = entry.getValue();
            attrGeneratorProperties.setSelectedGeneratorId(selectedGeneratorId);
            attrGeneratorProperties.setPresetId(attributeSection.get(KEY_PRESET_ID));
            PropertySourceCustom generatorPropertySource = attrGeneratorProperties.getGeneratorPropertySource(selectedGeneratorId);
            IDialogSettings generatorSection = UIUtils.getSettingsSection(attributeSection, KEY_GENERATOR_SECTION);
            if (generatorPropertySource != null) {
                Map<Object, Object> properties = generatorPropertySource.getPropertiesWithDefaults();
                for (Map.Entry<Object, Object> propEntry : properties.entrySet()) {
                    String key = (String) propEntry.getKey();
                    Object savedValue = UIUtils.getSectionValueWithType(generatorSection, key);
                    if (key.equals("nulls") && savedValue instanceof Boolean) {
                        // skip incorrect type TODO can be removed in the future
                        continue;
                    }
                    generatorPropertySource.setPropertyValue(voidProgressMonitor, propEntry.getKey(), savedValue);
                }
            }
        }
    }
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) VoidProgressMonitor(org.jkiss.dbeaver.model.runtime.VoidProgressMonitor)

Example 14 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.

the class MockDataSettings method saveTo.

void saveTo(IDialogSettings dialogSettings) {
    dialogSettings.put(PROP_REMOVE_OLD_DATA, removeOldData);
    dialogSettings.put(PROP_ROWS_NUMBER, rowsNumber);
    // save selected generators
    dialogSettings.put(KEY_SELECTED_ATTRIBUTE, selectedAttribute);
    IDialogSettings tableSection = UIUtils.getSettingsSection(dialogSettings, entity.getName());
    for (Map.Entry<String, AttributeGeneratorProperties> attrEntry : attributeGenerators.entrySet()) {
        String attributeName = attrEntry.getKey();
        AttributeGeneratorProperties attrGeneratorProperties = attrEntry.getValue();
        IDialogSettings attributeSection = UIUtils.getSettingsSection(tableSection, attributeName);
        String selectedGeneratorId = attrGeneratorProperties.getSelectedGeneratorId();
        attributeSection.put(KEY_SELECTED_GENERATOR, selectedGeneratorId);
        attributeSection.put(KEY_PRESET_ID, attrGeneratorProperties.getPresetId());
        IDialogSettings generatorSection = UIUtils.getSettingsSection(attributeSection, KEY_GENERATOR_SECTION);
        if (selectedGeneratorId != null) {
            PropertySourceCustom generatorPropertySource = attrGeneratorProperties.getGeneratorPropertySource(selectedGeneratorId);
            if (generatorPropertySource != null) {
                Map<Object, Object> properties = generatorPropertySource.getPropertiesWithDefaults();
                for (Map.Entry<Object, Object> propEntry : properties.entrySet()) {
                    UIUtils.putSectionValueWithType(generatorSection, (String) propEntry.getKey(), propEntry.getValue());
                }
            }
        }
    }
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings)

Example 15 with PropertySourceCustom

use of org.jkiss.dbeaver.runtime.properties.PropertySourceCustom in project dbeaver by dbeaver.

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;
    }
    updatePageCompletion();
}
Also used : PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) DataTransferProcessorDescriptor(org.jkiss.dbeaver.registry.transfer.DataTransferProcessorDescriptor)

Aggregations

PropertySourceCustom (org.jkiss.dbeaver.runtime.properties.PropertySourceCustom)22 DataFormatterDescriptor (org.jkiss.dbeaver.registry.formatter.DataFormatterDescriptor)4 DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)4 DataTransferProcessorDescriptor (org.jkiss.dbeaver.registry.transfer.DataTransferProcessorDescriptor)3 StreamConsumerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings)3 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 PostgreForeignTableManager (org.jkiss.dbeaver.ext.postgresql.edit.PostgreForeignTableManager)2 PostgreTableColumnManager (org.jkiss.dbeaver.ext.postgresql.edit.PostgreTableColumnManager)2 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)2 DBECommandContext (org.jkiss.dbeaver.model.edit.DBECommandContext)2 DBEPersistAction (org.jkiss.dbeaver.model.edit.DBEPersistAction)2 PropertyDescriptor (org.jkiss.dbeaver.model.impl.PropertyDescriptor)2 SQLDatabasePersistAction (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistAction)2 SQLDatabasePersistActionComment (org.jkiss.dbeaver.model.impl.edit.SQLDatabasePersistActionComment)2 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)2 DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)2 DBSEntity (org.jkiss.dbeaver.model.struct.DBSEntity)2 DBSEntityAttribute (org.jkiss.dbeaver.model.struct.DBSEntityAttribute)2 DBVTransformSettings (org.jkiss.dbeaver.model.virtual.DBVTransformSettings)2