Search in sources :

Example 6 with ICapActionFactory

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

the class BeanTableCopyActionBuilderFactory method createBuilder.

static <BEAN_TYPE> ICopyActionBuilder<BEAN_TYPE> createBuilder(final IBeanTable<BEAN_TYPE> table) {
    final IBeanTableModel<BEAN_TYPE> model = table.getModel();
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final ICopyActionBuilder<BEAN_TYPE> builder = actionFactory.copyActionBuilder(model);
    builder.setEntityLabelSingular(model.getEntityLabelSingular());
    builder.setEntityLabelPlural(model.getEntityLabelPlural());
    return builder;
}
Also used : ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Example 7 with ICapActionFactory

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

the class BeanTableCreatorActionBuilderFactory method createBuilder.

static <BEAN_TYPE> ICreatorActionBuilder<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 ICreatorActionBuilder<BEAN_TYPE> builder = actionFactory.creatorActionBuilder(model.getEntityId(), model.getBeanType(), wrappedModel);
    builder.setBeanPropertyValidators(model.getBeanPropertyValidators());
    builder.setEntityLabelSingular(model.getEntityLabelSingular());
    builder.setParentBeansProvider(new IProvider<List<IBeanKey>>() {

        @Override
        public List<IBeanKey> get() {
            return model.getParentBeanKeys();
        }
    });
    final ICreatorService creatorService = model.getCreatorService();
    if (creatorService != null) {
        builder.setCreatorService(creatorService);
    }
    // Bean form must have all attributes because a later pluged layouter may use them
    final IBeanFormBluePrint<BEAN_TYPE> beanFormBp = CapUiToolkit.bluePrintFactory().beanForm(model.getEntityId(), model.getAttributes());
    builder.setAttributes(model.getAttributes());
    builder.setBeanForm(beanFormBp);
    builder.addExecutionInterceptor(new ExecutionInterceptorAdapter<List<IBeanDto>>() {

        @Override
        public void beforeExecution(final IExecutionContext executionContext, final IVetoable continueExecution) {
            final int pageCount = model.getPageCount();
            if (pageCount > 0 && !model.isPageCreated(pageCount - 1)) {
                model.loadPage(pageCount - 1);
            }
        }
    });
    return builder;
}
Also used : IExecutionContext(org.jowidgets.api.command.IExecutionContext) IVetoable(org.jowidgets.common.types.IVetoable) ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory) List(java.util.List) ICreatorService(org.jowidgets.cap.common.api.service.ICreatorService)

Example 8 with ICapActionFactory

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

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

the class BeanTableEditActionBuilderFactory method createBuilder.

static <BEAN_TYPE> IEditActionBuilder<BEAN_TYPE> createBuilder(final IBeanTableModel<BEAN_TYPE> model) {
    final Object entityId = model.getEntityId();
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final IEditActionBuilder<BEAN_TYPE> builder = actionFactory.editActionBuilder(entityId, model, model);
    builder.setEntityLabelSingular(model.getEntityLabelSingular());
    final IBeanFormBluePrint<BEAN_TYPE> beanFormBp;
    if (entityId != null) {
        beanFormBp = CapUiToolkit.bluePrintFactory().beanForm(model.getEntityId(), model.getAttributes(MetaAttributesFilter.getInstance()));
    } else {
        beanFormBp = CapUiToolkit.bluePrintFactory().beanForm(model.getAttributes(MetaAttributesFilter.getInstance()));
    }
    builder.setBeanForm(beanFormBp);
    return builder;
}
Also used : ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Example 10 with ICapActionFactory

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

the class BeanRelationTreeImpl method createPasteLinkAction.

private IAction createPasteLinkAction(final IBeanRelationNodeModel<Object, Object> relationNodeModel, final IEntityLinkDescriptor link) {
    if (!defaultLinkPasteAction) {
        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) {
            IPasteLinkActionBuilder<Object, Object, Object> builder = actionFactory.pasteLinkActionBuilder(source, link, this);
            builder.setLinkedModel(relationNodeModel);
            if (!autoKeyBinding) {
                builder.setAccelerator(null);
            }
            if (menuInterceptor != null) {
                builder = menuInterceptor.pasteLinkActionBuilder(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)

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