Search in sources :

Example 1 with IEntityLinkDescriptor

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

the class BeanRelationTreeDetailImpl method addTableActions.

private void addTableActions(final IBeanRelationNodeModel<Object, Object> relationNode, final boolean hasDeleterAction, final IBeanTable<Object> table) {
    final IEntityLinkDescriptor link = getLinkDescriptor(relationNode);
    int addedActions = 0;
    if (link != null && link.getLinkCreatorService() != null) {
        final IAction linkCreatorAction = createLinkCreatorAction(relationNode, table, link);
        if (linkCreatorAction != null) {
            table.getCellPopMenu().addAction(linkCreatorAction);
            table.getTablePopupMenu().addAction(linkCreatorAction);
            addedActions++;
        }
    }
    if (hasCopyAction) {
        final IAction copyAction = createCopyAction(table);
        if (copyAction != null) {
            table.getCellPopMenu().addAction(copyAction);
            addedActions++;
        }
    }
    if (hasPasteAction && link != null && link.getLinkCreatorService() != null) {
        final IAction pasteLinkAction = createPasteLinkAction(relationNode, table, link);
        if (pasteLinkAction != null) {
            table.getCellPopMenu().addAction(pasteLinkAction);
            table.getTablePopupMenu().addAction(pasteLinkAction);
            addedActions++;
        }
    }
    if (addedActions >= 2) {
        table.getCellPopMenu().addSeparator();
    }
    if (link != null && link.getLinkDeleterService() != null) {
        final IAction linkDeleterAction = createLinkDeleterAction(relationNode, table, link);
        if (linkDeleterAction != null) {
            table.getCellPopMenu().addAction(linkDeleterAction);
        }
    }
    if (hasDeleterAction) {
        table.getCellPopMenu().addAction(createDeleterAction(table, relationNode));
    }
}
Also used : IAction(org.jowidgets.api.command.IAction) IEntityLinkDescriptor(org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor) IBeanRelationTreeDetailBluePrint(org.jowidgets.cap.ui.api.widgets.IBeanRelationTreeDetailBluePrint) IBeanTableBluePrint(org.jowidgets.cap.ui.api.widgets.IBeanTableBluePrint)

Example 2 with IEntityLinkDescriptor

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

Example 3 with IEntityLinkDescriptor

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

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

IEntityLinkDescriptor (org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor)4 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)3 IAction (org.jowidgets.api.command.IAction)2 IActionItemModel (org.jowidgets.api.model.item.IActionItemModel)1 IMenuItemModel (org.jowidgets.api.model.item.IMenuItemModel)1 IMenuModel (org.jowidgets.api.model.item.IMenuModel)1 IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)1 IBeanRelationTreeDetailBluePrint (org.jowidgets.cap.ui.api.widgets.IBeanRelationTreeDetailBluePrint)1 IBeanTableBluePrint (org.jowidgets.cap.ui.api.widgets.IBeanTableBluePrint)1 MenuModel (org.jowidgets.tools.model.item.MenuModel)1