use of org.jowidgets.workbench.tools.ComponentNodeModelBuilder in project jo-client-platform by jo-source.
the class EntityComponentNodesFactoryImpl method createNodeFromEntity.
private IComponentNodeModel createNodeFromEntity(final IEntityApplicationNode applicationNode) {
final IComponentNodeModelBuilder builder = new ComponentNodeModelBuilder();
final Object entityId = applicationNode.getEntityId();
String label = applicationNode.getLabel().get();
Object iconDescriptor = applicationNode.getIconDescriptor();
if (entityId == null) {
builder.setId(label);
} else {
// TODO MG the id of workbench parts should be an object
builder.setId(entityId.toString());
final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
final IBeanDtoDescriptor beanDtoDescriptor = entityService.getDescriptor(entityId);
if (beanDtoDescriptor != null) {
if (EmptyCheck.isEmpty(label)) {
label = beanDtoDescriptor.getLabelPlural().get();
}
if (iconDescriptor == null) {
iconDescriptor = beanDtoDescriptor.getIconDescriptor();
}
}
builder.setComponentFactory(CapUiToolkit.workbenchToolkit().entityComponentFactory().create(applicationNode));
}
builder.setLabel(label);
builder.setTooltip(applicationNode.getDescription().get());
if (iconDescriptor != null) {
builder.setIcon(ImageResolver.resolve(iconDescriptor));
}
for (final IEntityApplicationNode childNode : applicationNode.getChildren()) {
builder.addChild(createNodeFromEntity(childNode));
}
return builder.build();
}
Aggregations