Search in sources :

Example 1 with IVetoable

use of org.jowidgets.common.types.IVetoable 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)

Aggregations

List (java.util.List)1 IExecutionContext (org.jowidgets.api.command.IExecutionContext)1 ICreatorService (org.jowidgets.cap.common.api.service.ICreatorService)1 ICapActionFactory (org.jowidgets.cap.ui.api.command.ICapActionFactory)1 IVetoable (org.jowidgets.common.types.IVetoable)1