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