Search in sources :

Example 1 with IEntityApplicationNode

use of org.jowidgets.cap.common.api.entity.IEntityApplicationNode 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)

Example 2 with IEntityApplicationNode

use of org.jowidgets.cap.common.api.entity.IEntityApplicationNode in project jo-client-platform by jo-source.

the class EntityComponentNodesFactoryImpl method createNodes.

@Override
public List<IComponentNodeModel> createNodes(final IEntityApplicationService entityApplicationService) {
    Assert.paramNotNull(entityApplicationService, "entityApplicationService");
    final List<IComponentNodeModel> result = new LinkedList<IComponentNodeModel>();
    Collection<IEntityApplicationNode> entities = entityApplicationService.getApplicationNodes();
    for (final IEntityComponentNodesFactoryPlugin plugin : PluginProvider.getPlugins(IEntityComponentNodesFactoryPlugin.ID)) {
        entities = plugin.modify(entities);
    }
    for (final IEntityApplicationNode entityNode : entities) {
        result.add(createNodeFromEntity(entityNode));
    }
    return result;
}
Also used : IEntityApplicationNode(org.jowidgets.cap.common.api.entity.IEntityApplicationNode) IComponentNodeModel(org.jowidgets.workbench.toolkit.api.IComponentNodeModel) IEntityComponentNodesFactoryPlugin(org.jowidgets.cap.ui.api.plugin.IEntityComponentNodesFactoryPlugin) LinkedList(java.util.LinkedList)

Aggregations

IEntityApplicationNode (org.jowidgets.cap.common.api.entity.IEntityApplicationNode)2 LinkedList (java.util.LinkedList)1 IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)1 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)1 IEntityComponentNodesFactoryPlugin (org.jowidgets.cap.ui.api.plugin.IEntityComponentNodesFactoryPlugin)1 IComponentNodeModel (org.jowidgets.workbench.toolkit.api.IComponentNodeModel)1 IComponentNodeModelBuilder (org.jowidgets.workbench.toolkit.api.IComponentNodeModelBuilder)1 ComponentNodeModelBuilder (org.jowidgets.workbench.tools.ComponentNodeModelBuilder)1