Search in sources :

Example 1 with IComponentNodeModelBuilder

use of org.jowidgets.workbench.toolkit.api.IComponentNodeModelBuilder 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();
}
Also used : IEntityApplicationNode(org.jowidgets.cap.common.api.entity.IEntityApplicationNode) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) IComponentNodeModelBuilder(org.jowidgets.workbench.toolkit.api.IComponentNodeModelBuilder) IComponentNodeModelBuilder(org.jowidgets.workbench.toolkit.api.IComponentNodeModelBuilder) ComponentNodeModelBuilder(org.jowidgets.workbench.tools.ComponentNodeModelBuilder)

Aggregations

IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)1 IEntityApplicationNode (org.jowidgets.cap.common.api.entity.IEntityApplicationNode)1 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)1 IComponentNodeModelBuilder (org.jowidgets.workbench.toolkit.api.IComponentNodeModelBuilder)1 ComponentNodeModelBuilder (org.jowidgets.workbench.tools.ComponentNodeModelBuilder)1