Search in sources :

Example 1 with IBeanServicesProvider

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

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

the class JpaEntityService method addServicesProviderAndDescriptor.

private void addServicesProviderAndDescriptor(final EntityServiceBuilder entityServiceBuilder, final Class<? extends IBean> beanInterface, final Class<? extends IBean> beanType) {
    final IBeanDtoDescriptor descriptor = createDescriptor(beanInterface);
    final IBeanServicesProvider servicesProvider = createServicesProvider(beanInterface, beanType, descriptor);
    entityServiceBuilder.add(beanInterface, descriptor, servicesProvider);
}
Also used : IBeanServicesProvider(org.jowidgets.cap.common.api.service.IBeanServicesProvider) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)

Aggregations

IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)2 IBeanServicesProvider (org.jowidgets.cap.common.api.service.IBeanServicesProvider)2 IDeleterService (org.jowidgets.cap.common.api.service.IDeleterService)1 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)1 ICapActionFactory (org.jowidgets.cap.ui.api.command.ICapActionFactory)1 IImageConstant (org.jowidgets.common.image.IImageConstant)1