use of org.jkiss.dbeaver.runtime.properties.IPropertySourceEditable in project dbeaver by serge-rider.
the class PropertyTreeViewer method loadTreeNodes.
private Map<String, TreeNode> loadTreeNodes(@Nullable DBRProgressMonitor monitor, TreeNode parent, DBPPropertySource propertySource) {
Map<String, TreeNode> categories = new LinkedHashMap<>();
final DBPPropertyDescriptor[] props = propertySource.getPropertyDescriptors2();
for (DBPPropertyDescriptor prop : props) {
String categoryName = prop.getCategory();
if (CommonUtils.isEmpty(categoryName)) {
categoryName = CATEGORY_GENERAL;
}
TreeNode category = (parent != null ? parent : categories.get(categoryName));
if (category == null) {
category = new TreeNode(null, propertySource, categoryName);
categories.put(categoryName, category);
}
TreeNode propNode = new TreeNode(category, propertySource, prop);
// Load nested object's properties
if (!(propertySource instanceof IPropertySourceEditable)) {
Class<?> propType = ((DBPPropertyDescriptor) prop).getDataType();
if (propType != null) {
if (DBPObject.class.isAssignableFrom(propType)) {
Object propertyValue = propertySource.getPropertyValue(monitor, prop.getId());
if (propertyValue != null) {
PropertyCollector nestedCollector = new PropertyCollector(propertyValue, true);
if (nestedCollector.collectProperties()) {
categories.putAll(loadTreeNodes(monitor, propNode, nestedCollector));
}
}
} else if (BeanUtils.isCollectionType(propType)) {
Object propertyValue = propertySource.getPropertyValue(monitor, prop.getId());
if (propertyValue != null) {
Collection<?> collection;
if (BeanUtils.isArrayType(propType)) {
collection = Arrays.asList((Object[]) propertyValue);
} else {
collection = (Collection<?>) propertyValue;
}
PropertySourceCollection psc = new PropertySourceCollection(collection);
for (DBPPropertyDescriptor pd : psc.getPropertyDescriptors2()) {
new TreeNode(propNode, psc, pd);
}
}
}
}
}
}
return categories;
}
Aggregations