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;
}
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;
}
Aggregations