Search in sources :

Example 1 with IEntityService

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

the class BeanRelationTreeImpl method createCopyAction.

private IAction createCopyAction(final IBeanRelationNodeModel<Object, Object> relationNodeModel) {
    if (!defaultCopyAction) {
        return null;
    }
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final Object childEntityId = relationNodeModel.getChildEntityId();
    ICopyActionBuilder<Object> builder = actionFactory.copyActionBuilder(relationNodeModel);
    builder.setMultiSelectionPolicy(false);
    if (!autoKeyBinding) {
        builder.setAccelerator(null);
    }
    // Create the string content with help the the node renderer
    builder.setTransferableFactory(createCopyTransferableFactory(relationNodeModel));
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final IBeanDtoDescriptor descriptor = entityService.getDescriptor(childEntityId);
        if (descriptor != null) {
            builder.setEntityLabelPlural(descriptor.getLabelPlural().get());
            builder.setEntityLabelSingular(descriptor.getLabelSingular().get());
        }
    }
    if (menuInterceptor != null) {
        builder = menuInterceptor.copyActionBuilder(relationNodeModel, builder);
    }
    if (builder != null) {
        return builder.build();
    } else {
        return null;
    }
}
Also used : IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Example 2 with IEntityService

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

the class BeanRelationTreeImpl method createDeleterAction.

private IAction createDeleterAction(final IBeanRelationNodeModel<Object, Object> relationNodeModel) {
    if (!defaultDeleterAction) {
        return null;
    }
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
        final Object childEntityId = relationNodeModel.getChildEntityId();
        final IBeanServicesProvider beanServices = entityService.getBeanServices(childEntityId);
        if (beanServices != null) {
            final IDeleterService deleterService = beanServices.deleterService();
            if (deleterService != null) {
                IDeleterActionBuilder<Object> builder = actionFactory.deleterActionBuilder(relationNodeModel);
                builder.setDeleterService(deleterService);
                builder.setMultiSelectionPolicy(false);
                if (autoKeyBinding) {
                    builder.setAccelerator(VirtualKey.DELETE, Modifier.ALT);
                } else {
                    builder.setAccelerator(null);
                }
                final IBeanDtoDescriptor descriptor = entityService.getDescriptor(childEntityId);
                if (descriptor != null) {
                    builder.setEntityLabelPlural(descriptor.getLabelPlural().get());
                    builder.setEntityLabelSingular(descriptor.getLabelSingular().get());
                    final Object icon = descriptor.getDeleteIconDescriptor();
                    if (icon != null) {
                        final IImageConstant imageConstant = ImageResolver.resolve(icon);
                        if (imageConstant != null) {
                            builder.setIcon(imageConstant);
                        }
                    }
                }
                if (menuInterceptor != null) {
                    builder = menuInterceptor.deleterActionBuilder(relationNodeModel, builder);
                }
                if (builder != null) {
                    return builder.build();
                }
            }
        }
    }
    return null;
}
Also used : IImageConstant(org.jowidgets.common.image.IImageConstant) IBeanServicesProvider(org.jowidgets.cap.common.api.service.IBeanServicesProvider) IDeleterService(org.jowidgets.cap.common.api.service.IDeleterService) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Example 3 with IEntityService

use of org.jowidgets.cap.common.api.service.IEntityService 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 4 with IEntityService

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

the class CachedEntityServiceImplTest method createOriginalEntityService.

private IEntityService createOriginalEntityService() {
    final IEntityService result = Mockito.mock(IEntityService.class);
    Mockito.when(result.getEntityInfos()).thenReturn(ENTITY_INFOS);
    Mockito.when(result.getEntityInfo(ENTITY_ID_1)).thenReturn(ENTITY_1_INFO);
    Mockito.when(result.getDescriptor(Mockito.eq(ENTITY_ID_1))).thenReturn(ENTITY_1_BEAN_DTO_DESCRIPTOR);
    Mockito.when(result.getBeanServices(Mockito.eq(ENTITY_ID_1))).thenReturn(ENTITY_1_SERVICES);
    Mockito.when(result.getEntityLinks(Mockito.eq(ENTITY_ID_1))).thenReturn(ENTITY_1_LINKS);
    return result;
}
Also used : IEntityService(org.jowidgets.cap.common.api.service.IEntityService)

Example 5 with IEntityService

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

the class BeanRelationTreeModelBuilderImpl method addChildRelations.

@SuppressWarnings({ "unchecked", "rawtypes" })
private void addChildRelations(final IEntityTypeId<?> entityTypeId, final IBeanRelationNodeModelBluePrint bluePrint) {
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final IBeanDtoDescriptor dtoDescriptor = entityService.getDescriptor(entityTypeId.getEntityId());
        if (dtoDescriptor != null) {
            bluePrint.setText("<" + dtoDescriptor.getLabelPlural().get() + ">");
        }
        final List<IEntityLinkDescriptor> links = entityService.getEntityLinks(entityTypeId.getEntityId());
        if (links != null) {
            for (final IEntityLinkDescriptor link : links) {
                final Object linkedTypeId = link.getLinkedEntityId();
                final IBeanDtoDescriptor linkedDtoDescr = entityService.getDescriptor(linkedTypeId);
                if (linkedDtoDescr != null && linkedDtoDescr.getBeanType() != null) {
                    bluePrint.addChildRelation(linkedTypeId, linkedDtoDescr.getBeanType());
                } else {
                    bluePrint.addChildRelation(linkedTypeId, IBeanDto.class);
                }
            }
        }
    }
}
Also used : IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) IEntityLinkDescriptor(org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor)

Aggregations

IEntityService (org.jowidgets.cap.common.api.service.IEntityService)11 IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)8 IEntityLinkDescriptor (org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor)3 ICapActionFactory (org.jowidgets.cap.ui.api.command.ICapActionFactory)3 IImageConstant (org.jowidgets.common.image.IImageConstant)2 IAction (org.jowidgets.api.command.IAction)1 IActionItemModel (org.jowidgets.api.model.item.IActionItemModel)1 IMenuItemModel (org.jowidgets.api.model.item.IMenuItemModel)1 IMenuModel (org.jowidgets.api.model.item.IMenuModel)1 IProperty (org.jowidgets.cap.common.api.bean.IProperty)1 IEntityApplicationNode (org.jowidgets.cap.common.api.entity.IEntityApplicationNode)1 IEntityApplicationNodeBuilder (org.jowidgets.cap.common.api.entity.IEntityApplicationNodeBuilder)1 IBeanServicesProvider (org.jowidgets.cap.common.api.service.IBeanServicesProvider)1 IDeleterService (org.jowidgets.cap.common.api.service.IDeleterService)1 IMessage (org.jowidgets.i18n.api.IMessage)1 MenuModel (org.jowidgets.tools.model.item.MenuModel)1 IComponentNodeModelBuilder (org.jowidgets.workbench.toolkit.api.IComponentNodeModelBuilder)1 ComponentNodeModelBuilder (org.jowidgets.workbench.tools.ComponentNodeModelBuilder)1