use of org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor in project jo-client-platform by jo-source.
the class EntityComponentNodesFactoryImpl method createNodeFromEntity.
private IComponentNodeModel createNodeFromEntity(final IEntityApplicationNode applicationNode) {
final IComponentNodeModelBuilder builder = new ComponentNodeModelBuilder();
final Object entityId = applicationNode.getEntityId();
String label = applicationNode.getLabel().get();
Object iconDescriptor = applicationNode.getIconDescriptor();
if (entityId == null) {
builder.setId(label);
} else {
// TODO MG the id of workbench parts should be an object
builder.setId(entityId.toString());
final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
final IBeanDtoDescriptor beanDtoDescriptor = entityService.getDescriptor(entityId);
if (beanDtoDescriptor != null) {
if (EmptyCheck.isEmpty(label)) {
label = beanDtoDescriptor.getLabelPlural().get();
}
if (iconDescriptor == null) {
iconDescriptor = beanDtoDescriptor.getIconDescriptor();
}
}
builder.setComponentFactory(CapUiToolkit.workbenchToolkit().entityComponentFactory().create(applicationNode));
}
builder.setLabel(label);
builder.setTooltip(applicationNode.getDescription().get());
if (iconDescriptor != null) {
builder.setIcon(ImageResolver.resolve(iconDescriptor));
}
for (final IEntityApplicationNode childNode : applicationNode.getChildren()) {
builder.addChild(createNodeFromEntity(childNode));
}
return builder.build();
}
use of org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor 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;
}
use of org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor in project jo-client-platform by jo-source.
the class BeanRelationTreeImpl method createCopyAction.
private IAction createCopyAction(final IBeanRelationNodeModel<Object, Object> relationNodeModel) {
if (!defaultCopyAction) {
return null;
}
final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
final Object childEntityId = relationNodeModel.getChildEntityId();
ICopyActionBuilder<Object> builder = actionFactory.copyActionBuilder(relationNodeModel);
builder.setMultiSelectionPolicy(false);
if (!autoKeyBinding) {
builder.setAccelerator(null);
}
// Create the string content with help the the node renderer
builder.setTransferableFactory(createCopyTransferableFactory(relationNodeModel));
final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
if (entityService != null) {
final IBeanDtoDescriptor descriptor = entityService.getDescriptor(childEntityId);
if (descriptor != null) {
builder.setEntityLabelPlural(descriptor.getLabelPlural().get());
builder.setEntityLabelSingular(descriptor.getLabelSingular().get());
}
}
if (menuInterceptor != null) {
builder = menuInterceptor.copyActionBuilder(relationNodeModel, builder);
}
if (builder != null) {
return builder.build();
} else {
return null;
}
}
use of org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor 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.bean.IBeanDtoDescriptor 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;
}
Aggregations