Search in sources :

Example 1 with ITEM

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);
}
Also used : ResourceElement(org.jboss.hal.core.mbui.ResourceElement) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Elements.section(org.jboss.gwt.elemento.core.Elements.section) MbuiElement(org.jboss.hal.spi.MbuiElement) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Arrays.asList(java.util.Arrays.asList) ITEM(org.jboss.hal.resources.Ids.ITEM) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) Ids.build(org.jboss.hal.resources.Ids.build) Table(org.jboss.hal.ballroom.table.Table) Ids(org.jboss.hal.resources.Ids) FORM(org.jboss.hal.resources.Ids.FORM) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) MAPPED_ROLE_MAPPER_TEMPLATE(org.jboss.hal.client.configuration.subsystem.elytron.AddressTemplates.MAPPED_ROLE_MAPPER_TEMPLATE) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) PostConstruct(javax.annotation.PostConstruct) MbuiView(org.jboss.hal.spi.MbuiView) ResourceElement(org.jboss.hal.core.mbui.ResourceElement) NamedNode(org.jboss.hal.dmr.NamedNode) CONSTANT_PERMISSION_MAPPER_TEMPLATE(org.jboss.hal.client.configuration.subsystem.elytron.AddressTemplates.CONSTANT_PERMISSION_MAPPER_TEMPLATE) Form(org.jboss.hal.ballroom.form.Form) HTMLElement(elemental2.dom.HTMLElement) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) NamedNode(org.jboss.hal.dmr.NamedNode) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) PostConstruct(javax.annotation.PostConstruct)

Aggregations

HTMLElement (elemental2.dom.HTMLElement)1 Arrays.asList (java.util.Arrays.asList)1 List (java.util.List)1 PostConstruct (javax.annotation.PostConstruct)1 Elements.h (org.jboss.gwt.elemento.core.Elements.h)1 Elements.p (org.jboss.gwt.elemento.core.Elements.p)1 Elements.section (org.jboss.gwt.elemento.core.Elements.section)1 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)1 VerticalNavigation (org.jboss.hal.ballroom.VerticalNavigation)1 Form (org.jboss.hal.ballroom.form.Form)1 Table (org.jboss.hal.ballroom.table.Table)1 CONSTANT_PERMISSION_MAPPER_TEMPLATE (org.jboss.hal.client.configuration.subsystem.elytron.AddressTemplates.CONSTANT_PERMISSION_MAPPER_TEMPLATE)1 MAPPED_ROLE_MAPPER_TEMPLATE (org.jboss.hal.client.configuration.subsystem.elytron.AddressTemplates.MAPPED_ROLE_MAPPER_TEMPLATE)1 MbuiContext (org.jboss.hal.core.mbui.MbuiContext)1 MbuiViewImpl (org.jboss.hal.core.mbui.MbuiViewImpl)1 ResourceElement (org.jboss.hal.core.mbui.ResourceElement)1 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)1 ModelNodeTable (org.jboss.hal.core.mbui.table.ModelNodeTable)1 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)1 NamedNode (org.jboss.hal.dmr.NamedNode)1