use of org.jkiss.dbeaver.ui.properties.PropertyTreeViewer in project dbeaver by serge-rider.
the class AttributeEditPage method createPageContents.
@Override
protected Control createPageContents(Composite parent) {
Composite propsGroup = new Composite(parent, SWT.NONE);
propsGroup.setLayout(new GridLayout(2, false));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
propsGroup.setLayoutData(gd);
//$NON-NLS-2$
final Text nameText = UIUtils.createLabelText(propsGroup, "Name", attribute.getName());
nameText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
if (attribute instanceof DBPNamedObject2) {
((DBPNamedObject2) attribute).setName(nameText.getText());
}
}
});
UIUtils.createControlLabel(propsGroup, "Properties").setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
final PropertyTreeViewer propertyViewer = new PropertyTreeViewer(propsGroup, SWT.BORDER);
gd = new GridData(GridData.FILL_BOTH);
gd.widthHint = 400;
propertyViewer.getControl().setLayoutData(gd);
propertyViewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return true;
}
});
PropertySourceAbstract pc = new PropertySourceEditable(commandContext, attribute, attribute) {
@Override
public void setPropertyValue(@Nullable DBRProgressMonitor monitor, Object editableValue, ObjectPropertyDescriptor prop, Object newValue) throws IllegalArgumentException {
super.setPropertyValue(monitor, editableValue, prop, newValue);
/*
if (prop.getId().equals("dataType")) {
newValue = getPropertyValue(monitor, editableValue, prop);
if (newValue instanceof DBSDataType) {
DBPPropertyDescriptor lengthProp = getProperty("maxLength");
if (lengthProp instanceof ObjectPropertyDescriptor) {
DBPDataKind dataKind = ((DBSDataType) newValue).getDataKind();
if (dataKind == DBPDataKind.STRING) {
setPropertyValue(monitor, editableValue, (ObjectPropertyDescriptor) lengthProp, 100);
} else {
setPropertyValue(monitor, editableValue, (ObjectPropertyDescriptor) lengthProp, null);
}
propertyViewer.update(lengthProp, null);
}
}
}
*/
}
};
pc.collectProperties();
for (DBPPropertyDescriptor prop : pc.getProperties()) {
if (prop instanceof ObjectPropertyDescriptor) {
if (((ObjectPropertyDescriptor) prop).isEditPossible() && !((ObjectPropertyDescriptor) prop).isNameProperty()) {
continue;
}
}
pc.removeProperty(prop);
}
propertyViewer.loadProperties(pc);
return propsGroup;
}
use of org.jkiss.dbeaver.ui.properties.PropertyTreeViewer 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(CoreMessages.dialog_edit_driver_tab_name_advanced_parameters);
paramsTab.setToolTipText(CoreMessages.dialog_edit_driver_tab_tooltip_advanced_parameters);
paramsTab.setControl(paramsGroup);
}
Aggregations