Search in sources :

Example 6 with IEntityService

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

the class BeanTableDeleterActionBuilderFactory method createBuilder.

static <BEAN_TYPE> IDeleterActionBuilder<BEAN_TYPE> createBuilder(final IBeanTable<BEAN_TYPE> table) {
    final IBeanTableModel<BEAN_TYPE> model = table.getModel();
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final IDeleterActionBuilder<BEAN_TYPE> builder = actionFactory.deleterActionBuilder(model);
    builder.setEntityLabelSingular(model.getEntityLabelSingular());
    builder.setEntityLabelPlural(model.getEntityLabelPlural());
    builder.setDeleterService(model.getDeleterService());
    final Object entityId = model.getEntityId();
    if (entityId != null) {
        final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
        if (entityService != null) {
            final IBeanDtoDescriptor descriptor = entityService.getDescriptor(entityId);
            if (descriptor != null) {
                final Object icon = descriptor.getDeleteIconDescriptor();
                if (icon != null) {
                    final IImageConstant imageConstant = ImageResolver.resolve(icon);
                    if (imageConstant != null) {
                        builder.setIcon(imageConstant);
                    }
                }
            }
        }
    }
    return builder;
}
Also used : IImageConstant(org.jowidgets.common.image.IImageConstant) 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 7 with IEntityService

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

the class AttributeToolkitImpl method createAttributes.

@Override
public List<IAttribute<Object>> createAttributes(final Object entityID, final IAttributeCollectionModifier attributeCollectionModifier) {
    Assert.paramNotNull(entityID, "entityID");
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final IBeanDtoDescriptor descriptor = entityService.getDescriptor(entityID);
        if (descriptor != null) {
            final List<IProperty> properties = descriptor.getProperties();
            if (properties != null) {
                return createAttributes(properties, attributeCollectionModifier);
            }
        }
    }
    throw new IllegalArgumentException("Could not retrieve properties for entityId '" + entityID + "'");
}
Also used : IProperty(org.jowidgets.cap.common.api.bean.IProperty) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)

Example 8 with IEntityService

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

the class MoveOrderedBeanActionBuilderImpl method setEntityLabels.

@Override
public IMoveOrderedBeanActionBuilder<BEAN_TYPE> setEntityLabels(final Object entityId) {
    checkExhausted();
    if (entityId != null) {
        final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
        if (entityService != null) {
            final IBeanDtoDescriptor descriptor = entityService.getDescriptor(entityId);
            if (descriptor != null) {
                final IMessage labelSingular = descriptor.getLabelSingular();
                if (labelSingular != null && !EmptyCheck.isEmpty(labelSingular.get())) {
                    setEntityLabelSingular(labelSingular.get());
                }
                final IMessage labelPlural = descriptor.getLabelPlural();
                if (labelPlural != null && !EmptyCheck.isEmpty(labelPlural.get())) {
                    setEntityLabelPlural(labelPlural.get());
                }
            }
        }
    }
    return this;
}
Also used : IMessage(org.jowidgets.i18n.api.IMessage) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)

Example 9 with IEntityService

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

the class BeanRelationTreeDetailImpl method getLinkDescriptor.

private IEntityLinkDescriptor getLinkDescriptor(final IBeanRelationNodeModel<Object, Object> relationNode) {
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    final List<IEntityLinkDescriptor> links = entityService.getEntityLinks(relationNode.getParentEntityId());
    if (links != null) {
        for (final IEntityLinkDescriptor link : links) {
            if (link.getLinkedEntityId().equals(relationNode.getChildEntityId())) {
                return link;
            }
        }
    }
    return null;
}
Also used : IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IEntityLinkDescriptor(org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor)

Example 10 with IEntityService

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

the class BeanRelationTreeImpl method createNodeMenus.

private IMenuModel createNodeMenus(final IBeanRelationNodeModel<Object, Object> relationNodeModel, final IMenuModel relationMenu, final IAction createAction) {
    final IMenuModel result = new MenuModel();
    boolean needSeparator = false;
    final IAction copyAction = createCopyAction(relationNodeModel);
    if (copyAction != null && createAction == null) {
        result.addAction(copyAction);
        needSeparator = true;
    }
    if (relationMenu.getChildren().size() > 0) {
        for (final IMenuItemModel item : relationMenu.getChildren()) {
            result.addItem(item);
            if (copyAction != null && createAction != null && item instanceof IActionItemModel) {
                final IAction action = ((IActionItemModel) item).getAction();
                if (NullCompatibleEquivalence.equals(createAction, action)) {
                    result.addAction(copyAction);
                }
            }
        }
        needSeparator = true;
    }
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final Object childEntityId = relationNodeModel.getChildEntityId();
        if (relationNodeModel.getParentEntityId() != null && relationNodeModel.getParentBean() != null) {
            final List<IEntityLinkDescriptor> links = entityService.getEntityLinks(relationNodeModel.getParentEntityId());
            for (final IEntityLinkDescriptor link : links) {
                if (childEntityId.equals(link.getLinkedEntityId())) {
                    final IAction linkDeleterAction = createLinkDeleterAction(relationNodeModel, link);
                    if (linkDeleterAction != null) {
                        if (needSeparator) {
                            result.addSeparator();
                            needSeparator = false;
                        }
                        result.addAction(linkDeleterAction);
                    }
                }
            }
        }
        final IAction deleterAction = createDeleterAction(relationNodeModel);
        if (deleterAction != null) {
            if (needSeparator) {
                result.addSeparator();
                needSeparator = false;
            }
            result.addAction(deleterAction);
        }
    }
    if (menuInterceptor != null) {
        return menuInterceptor.nodeMenu(relationNodeModel, result);
    } else {
        return result;
    }
}
Also used : IMenuModel(org.jowidgets.api.model.item.IMenuModel) IAction(org.jowidgets.api.command.IAction) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IEntityLinkDescriptor(org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor) IMenuModel(org.jowidgets.api.model.item.IMenuModel) MenuModel(org.jowidgets.tools.model.item.MenuModel) IMenuItemModel(org.jowidgets.api.model.item.IMenuItemModel) IActionItemModel(org.jowidgets.api.model.item.IActionItemModel)

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