Search in sources :

Example 1 with ICapActionFactory

use of org.jowidgets.cap.ui.api.command.ICapActionFactory in project jo-client-platform by jo-source.

the class BeanRelationTreeImpl method createLinkCreatorAction.

private IAction createLinkCreatorAction(final IBeanRelationNodeModel<Object, Object> relationNodeModel, final IEntityLinkDescriptor link) {
    if (!defaultLinkCreatorAction) {
        return null;
    }
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final IBeanSelectionProvider<Object> source = new ImutableSingleBeanSelectionProvider<Object>(relationNodeModel.getParentBean(), relationNodeModel.getParentEntityId(), relationNodeModel.getParentBeanTypeId(), relationNodeModel.getParentBeanType());
    try {
        if (link.getLinkCreatorService() != null) {
            ILinkCreatorActionBuilder<Object, Object, Object> builder = actionFactory.linkCreatorActionBuilder(source, link);
            builder.setLinkedModel(relationNodeModel);
            if (autoKeyBinding) {
                builder.setAccelerator(VirtualKey.N, Modifier.CTRL);
            } else {
                builder.setAccelerator(null);
            }
            if (menuInterceptor != null) {
                builder = menuInterceptor.linkCreatorActionBuilder(relationNodeModel, builder);
            }
            if (builder != null) {
                return builder.build();
            }
        }
    } catch (final Exception e) {
    }
    return null;
}
Also used : ImutableSingleBeanSelectionProvider(org.jowidgets.cap.ui.tools.bean.ImutableSingleBeanSelectionProvider) ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Example 2 with ICapActionFactory

use of org.jowidgets.cap.ui.api.command.ICapActionFactory 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;
}
Also used : IImageConstant(org.jowidgets.common.image.IImageConstant) IBeanServicesProvider(org.jowidgets.cap.common.api.service.IBeanServicesProvider) IDeleterService(org.jowidgets.cap.common.api.service.IDeleterService) 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 3 with ICapActionFactory

use of org.jowidgets.cap.ui.api.command.ICapActionFactory in project jo-client-platform by jo-source.

the class BeanRelationTreeImpl method createLinkDeleterAction.

private IAction createLinkDeleterAction(final IBeanRelationNodeModel<Object, Object> relationNodeModel, final IEntityLinkDescriptor link) {
    if (!defaultLinkDeleterAction) {
        return null;
    }
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final IBeanSelectionProvider<Object> source = new ImutableSingleBeanSelectionProvider<Object>(relationNodeModel.getParentBean(), relationNodeModel.getParentEntityId(), relationNodeModel.getParentBeanTypeId(), relationNodeModel.getParentBeanType());
    try {
        if (link.getLinkDeleterService() != null) {
            ILinkDeleterActionBuilder<Object, Object> builder = actionFactory.linkDeleterActionBuilder(source, relationNodeModel, link);
            builder.setLinkedMultiSelection(treeMultiSelection);
            if (autoKeyBinding) {
                builder.setAccelerator(VirtualKey.DELETE);
            } else {
                builder.setAccelerator(null);
            }
            if (menuInterceptor != null) {
                builder = menuInterceptor.linkDeleterActionBuilder(relationNodeModel, builder);
            }
            if (builder != null) {
                return builder.build();
            }
        }
    } catch (final Exception e) {
    }
    return null;
}
Also used : ImutableSingleBeanSelectionProvider(org.jowidgets.cap.ui.tools.bean.ImutableSingleBeanSelectionProvider) ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Example 4 with ICapActionFactory

use of org.jowidgets.cap.ui.api.command.ICapActionFactory 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;
    }
}
Also used : 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 5 with ICapActionFactory

use of org.jowidgets.cap.ui.api.command.ICapActionFactory in project jo-client-platform by jo-source.

the class BeanTablePasteBeansActionBuilderFactory method createBuilder.

static <BEAN_TYPE> IPasteBeansActionBuilder<BEAN_TYPE> createBuilder(final IBeanTable<BEAN_TYPE> table) {
    final IBeanTableModel<BEAN_TYPE> model = table.getModel();
    final IBeanListModel<BEAN_TYPE> wrappedModel = new ScrollToEndAtAddTableModel<BEAN_TYPE>(table);
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final IPasteBeansActionBuilder<BEAN_TYPE> builder = actionFactory.pasteBeansActionBuilder(model.getBeanTypeId(), model.getBeanType(), wrappedModel, table);
    builder.setEntityLabelPlural(model.getEntityLabelPlural());
    builder.setAttributes(model.getAttributes());
    return builder;
}
Also used : ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Aggregations

ICapActionFactory (org.jowidgets.cap.ui.api.command.ICapActionFactory)10 IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)3 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)3 ImutableSingleBeanSelectionProvider (org.jowidgets.cap.ui.tools.bean.ImutableSingleBeanSelectionProvider)3 IImageConstant (org.jowidgets.common.image.IImageConstant)2 List (java.util.List)1 IExecutionContext (org.jowidgets.api.command.IExecutionContext)1 IBeanServicesProvider (org.jowidgets.cap.common.api.service.IBeanServicesProvider)1 ICreatorService (org.jowidgets.cap.common.api.service.ICreatorService)1 IDeleterService (org.jowidgets.cap.common.api.service.IDeleterService)1 IVetoable (org.jowidgets.common.types.IVetoable)1