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