Search in sources :

Example 1 with DBDAttributeTransformerDescriptor

use of org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor in project dbeaver by serge-rider.

the class TransformerSettingsDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    Composite composite = super.createDialogArea(parent);
    final DBPDataSource dataSource = viewer.getDataContainer() == null ? null : viewer.getDataContainer().getDataSource();
    Collection<? extends DBPPropertyDescriptor> properties = Collections.emptyList();
    final DBDAttributeTransformerDescriptor transformer;
    if (dataSource != null && !CommonUtils.isEmpty(settings.getCustomTransformer())) {
        transformer = dataSource.getContainer().getPlatform().getValueHandlerRegistry().getTransformer(settings.getCustomTransformer());
        if (transformer != null) {
            properties = transformer.getProperties();
        }
    } else {
        transformer = null;
    }
    if (transformer != null) {
        final Composite placeholder = UIUtils.createControlGroup(composite, "Transformer", 2, GridData.FILL_HORIZONTAL, -1);
        UIUtils.createLabelText(placeholder, "Name", transformer.getName(), SWT.READ_ONLY);
        Label infoLabel = UIUtils.createControlLabel(placeholder, "Info");
        infoLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
        final Text infoText = new Text(placeholder, SWT.READ_ONLY | SWT.WRAP);
        if (transformer.getDescription() != null) {
            infoText.setText(transformer.getDescription());
        }
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.widthHint = 300;
        infoText.setLayoutData(gd);
    }
    Map<String, String> transformOptions = settings.getTransformOptions();
    if (transformOptions == null) {
        transformOptions = Collections.emptyMap();
    }
    propertiesEditor = new PropertyTreeViewer(composite, SWT.BORDER);
    propertySource = new PropertySourceCustom(properties, transformOptions);
    propertiesEditor.loadProperties(propertySource);
    propertiesEditor.getControl().setFocus();
    return parent;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) PropertySourceCustom(org.jkiss.dbeaver.runtime.properties.PropertySourceCustom) PropertyTreeViewer(org.jkiss.dbeaver.ui.properties.PropertyTreeViewer) DBDAttributeTransformerDescriptor(org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) DBPDataSource(org.jkiss.dbeaver.model.DBPDataSource)

Example 2 with DBDAttributeTransformerDescriptor

use of org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor in project dbeaver by serge-rider.

the class DBVTransformSettings method filterTransformers.

public boolean filterTransformers(List<? extends DBDAttributeTransformerDescriptor> descriptors) {
    if (!hasValuableData()) {
        return false;
    }
    for (int i = 0; i < descriptors.size(); ) {
        final DBDAttributeTransformerDescriptor descriptor = descriptors.get(i);
        boolean valid;
        if (descriptor.isCustom()) {
            valid = descriptor.getId().equals(customTransformer);
        } else {
            if (descriptor.isApplicableByDefault()) {
                valid = (excludedTransformers == null || !excludedTransformers.contains(descriptor.getId()));
            } else {
                valid = includedTransformers != null && includedTransformers.contains(descriptor.getId());
            }
        }
        if (!valid) {
            descriptors.remove(i);
        } else {
            i++;
        }
    }
    return true;
}
Also used : DBDAttributeTransformerDescriptor(org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor)

Aggregations

DBDAttributeTransformerDescriptor (org.jkiss.dbeaver.model.data.DBDAttributeTransformerDescriptor)2 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 Text (org.eclipse.swt.widgets.Text)1 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)1 PropertySourceCustom (org.jkiss.dbeaver.runtime.properties.PropertySourceCustom)1 PropertyTreeViewer (org.jkiss.dbeaver.ui.properties.PropertyTreeViewer)1