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;
}
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 + "'");
}
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;
}
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;
}
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;
}
}
Aggregations