use of org.jboss.hal.resources.Ids.ITEM in project console by hal.
the class MapperDecoderView method init.
@PostConstruct
void init() {
Metadata metadata = mbuiContext.metadataRegistry().lookup(CONSTANT_PERMISSION_MAPPER_TEMPLATE);
constantPermissionMapperElement = new ResourceElement.Builder(Ids.ELYTRON_CONSTANT_PERMISSION_MAPPER, CONSTANT_PERMISSION_MAPPER, metadata, mbuiContext).column(NAME, (cell, type, row, meta) -> row.getName()).setComplexListAttribute(PERMISSIONS, asList(CLASS_NAME, MODULE), asList(CLASS_NAME, MODULE), modelNode -> build(modelNode.get(CLASS_NAME).asString(), modelNode.get(MODULE).asString())).onCrud(() -> presenter.reload(CONSTANT_PERMISSION_MAPPER, this::updateConstantPermissionMapper)).build();
navigation.insertSecondary("mappers-decoders-permission-mapper-item", build(Ids.ELYTRON_CONSTANT_PERMISSION_MAPPER, ITEM), "mappers-decoders-custom-permission-mapper-item", "Constant Permission Mapper", constantPermissionMapperElement.element());
registerAttachable(constantPermissionMapperElement);
// =========
String mappedId = "mappers-decoders-mapped-role-mapper";
Metadata mappedMetadata = mbuiContext.metadataRegistry().lookup(MAPPED_ROLE_MAPPER_TEMPLATE);
LabelBuilder labelBuilder = new LabelBuilder();
String title = labelBuilder.label(MAPPED_ROLE_MAPPER);
mappedRoleMapperTable = new ModelNodeTable.Builder<NamedNode>(build(mappedId, TABLE), mappedMetadata).button(mbuiContext.tableButtonFactory().add(MAPPED_ROLE_MAPPER_TEMPLATE, table -> presenter.addMappedRoleMapper())).button(mbuiContext.tableButtonFactory().remove(title, MAPPED_ROLE_MAPPER_TEMPLATE, table -> table.selectedRow().getName(), () -> presenter.reload())).column(NAME, (cell, type, row, meta) -> row.getName()).build();
mappedRoleMapperForm = new ModelNodeForm.Builder<NamedNode>(build(mappedId, FORM), mappedMetadata).customFormItem(ROLE_MAP, desc -> new RoleMapListItem(ROLE_MAP, labelBuilder.label(ROLE_MAP))).onSave((form, changedValues) -> {
String name = form.getModel().getName();
ResourceAddress address = MAPPED_ROLE_MAPPER_TEMPLATE.resolve(mbuiContext.statementContext(), name);
saveForm(title, name, address, changedValues, mappedMetadata);
}).build();
HTMLElement mappedSection = section().add(h(1).textContent(Names.SIMPLE_PERMISSION_MAPPER)).add(p().textContent(metadata.getDescription().getDescription())).add(mappedRoleMapperTable).add(mappedRoleMapperForm).element();
registerAttachable(mappedRoleMapperTable, mappedRoleMapperForm);
navigation.insertSecondary("mappers-decoders-role-mappers", build(mappedId, ITEM), null, title, mappedSection);
// =========
Metadata spmMetadata = mbuiContext.metadataRegistry().lookup(AddressTemplates.SIMPLE_PERMISSION_MAPPER_TEMPLATE);
simplePermissionMapperElement = new SimplePermissionMapperElement(spmMetadata, mbuiContext.tableButtonFactory());
navigation.insertSecondary("mappers-decoders-permission-mapper-item", build(Ids.ELYTRON_SIMPLE_PERMISSION_MAPPER, ITEM), "mappers-decoders-simple-permission-mapper-item", "Simple Permission Mapper", simplePermissionMapperElement.element());
registerAttachable(simplePermissionMapperElement);
}
Aggregations