Search in sources :

Example 1 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class LoggingProfileView method init.

@PostConstruct
@SuppressWarnings("Duplicates")
void init() {
    Constants constants = mbuiContext.resources().constants();
    noRootLogger = new EmptyState.Builder(Ids.LOGGING_PROFILE + "-root-logger-empty", constants.noRootLogger()).description(constants.noRootLoggerDescription()).icon(fontAwesome("sitemap")).primaryAction(constants.add(), this::addRootLogger).build();
    noRootLogger.element().classList.add(marginTopLarge);
    // hack which relies on the element hierarchy given in the template. will break if you change that hierarchy.
    rootLoggerForm.element().parentNode.appendChild(noRootLogger.element());
    rootLoggerVisibility(false);
    // --------------------------- json formatter
    AddressTemplate jsonTemplate = LOGGING_PROFILE_TEMPLATE.append(JSON_FORMATTER_TEMPLATE.lastName() + EQ_WILDCARD);
    LabelBuilder labelBuilder = new LabelBuilder();
    Metadata jsonMetadata = mbuiContext.metadataRegistry().lookup(jsonTemplate);
    Metadata jsonKeyOverridesMetadata = jsonMetadata.forComplexAttribute(KEY_OVERRIDES);
    String jsonLabel = labelBuilder.label(jsonTemplate.lastName());
    jsonFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, TABLE), jsonMetadata).button(constants.add(), table -> crud().add(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, ADD), Names.JSON_FORMATTER, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), (name, address) -> presenter.reload()), Constraint.executable(jsonTemplate, ADD)).button(constants.remove(), table -> crud().remove(Names.JSON_FORMATTER, table.selectedRow().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), () -> presenter.reload()), Constraint.executable(jsonTemplate, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
    jsonFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, JSON, FORMATTER, FORM), jsonMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(jsonLabel, form.getModel().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(jsonLabel, jsonFormatterTable.selectedRow().getName(), jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), form, jsonMetadata, () -> presenter.reload())).build();
    jsonKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, KEY_OVERRIDES, FORM), jsonKeyOverridesMetadata).singleton(() -> {
        StatementContext jsonStatementContext = new SelectionAwareStatementContext(mbuiContext.statementContext(), () -> jsonFormatterTable.hasSelection() ? jsonFormatterTable.selectedRow().getName() : null);
        ResourceAddress address = jsonTemplate.resolve(jsonStatementContext, presenter.getLoggingProfile());
        return new Operation.Builder(address, READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
    }, () -> presenter.addComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()))).onSave((form, changedValues) -> presenter.saveComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues)).prepareReset(form -> presenter.resetComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()), jsonKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, jsonTemplate.replaceWildcards(presenter.getLoggingProfile()))).build();
    Tabs jsonTabs = new Tabs(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, TAB_CONTAINER));
    jsonTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, ATTRIBUTES, TAB), constants.attributes(), jsonFormatterForm.element());
    jsonTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, JSON, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, jsonKeyOverridesForm.element());
    HTMLElement jsonSection = section().add(h(1).textContent(Names.JSON_FORMATTER)).add(p().textContent(jsonMetadata.getDescription().getDescription())).add(jsonFormatterTable).add(jsonTabs).element();
    registerAttachable(jsonFormatterTable, jsonFormatterForm, jsonKeyOverridesForm);
    navigation.insertSecondary("logging-profile-formatter-item", Ids.build(LOGGING_PROFILE, FORMATTER, JSON, Ids.ITEM), null, Names.JSON_FORMATTER, jsonSection);
    // --------------------------- xml formatter
    AddressTemplate xmlTemplate = LOGGING_PROFILE_TEMPLATE.append(XML_FORMATTER_TEMPLATE.lastName() + EQ_WILDCARD);
    Metadata xmlMetadata = mbuiContext.metadataRegistry().lookup(xmlTemplate);
    Metadata xmlKeyOverridesMetadata = xmlMetadata.forComplexAttribute(KEY_OVERRIDES);
    String xmlLabel = labelBuilder.label(xmlTemplate.lastName());
    xmlFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, XML, FORMATTER, TABLE), xmlMetadata).button(constants.add(), table -> crud().add(Ids.build(LOGGING_PROFILE, XML, FORMATTER, ADD), Names.XML_FORMATTER, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), (name, address) -> presenter.reload()), Constraint.executable(xmlTemplate, ADD)).button(constants.remove(), table -> crud().remove(Names.XML_FORMATTER, table.selectedRow().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), () -> presenter.reload()), Constraint.executable(xmlTemplate, REMOVE)).column(NAME, (cell, type, row, meta) -> row.getName()).build();
    xmlFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING_PROFILE, XML, FORMATTER, FORM), xmlMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(xmlLabel, form.getModel().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(xmlLabel, xmlFormatterTable.selectedRow().getName(), xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), form, xmlMetadata, () -> presenter.reload())).build();
    xmlKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING_PROFILE, FORMATTER, XML, KEY_OVERRIDES, FORM), xmlKeyOverridesMetadata).singleton(() -> {
        StatementContext xmlStatementContext = new SelectionAwareStatementContext(mbuiContext.statementContext(), () -> xmlFormatterTable.hasSelection() ? xmlFormatterTable.selectedRow().getName() : null);
        ResourceAddress address = xmlTemplate.resolve(xmlStatementContext, presenter.getLoggingProfile());
        return new Operation.Builder(address, READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
    }, () -> presenter.addComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()))).onSave((form, changedValues) -> presenter.saveComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), changedValues)).prepareReset(form -> presenter.resetComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()), xmlKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, xmlTemplate.replaceWildcards(presenter.getLoggingProfile()))).build();
    Tabs xmlTabs = new Tabs(Ids.build(LOGGING_PROFILE, FORMATTER, XML, TAB_CONTAINER));
    xmlTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, XML, ATTRIBUTES, TAB), constants.attributes(), xmlFormatterForm.element());
    xmlTabs.add(Ids.build(LOGGING_PROFILE, FORMATTER, XML, KEY_OVERRIDES, TAB), Names.KEY_OVERRIDES, xmlKeyOverridesForm.element());
    HTMLElement xmlSection = section().add(h(1).textContent(Names.XML_FORMATTER)).add(p().textContent(xmlMetadata.getDescription().getDescription())).add(xmlFormatterTable).add(xmlTabs).element();
    registerAttachable(xmlFormatterTable, xmlFormatterForm, xmlKeyOverridesForm);
    navigation.insertSecondary("logging-profile-formatter-item", Ids.build(LOGGING_PROFILE, FORMATTER, XML, Ids.ITEM), null, Names.XML_FORMATTER, xmlSection);
}
Also used : AddressTemplate(org.jboss.hal.meta.AddressTemplate) Constraint(org.jboss.hal.meta.security.Constraint) StatementContext(org.jboss.hal.meta.StatementContext) LOGGING_PROFILE_TEMPLATE(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates.LOGGING_PROFILE_TEMPLATE) TAB_CONTAINER(org.jboss.hal.resources.Ids.TAB_CONTAINER) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) Elements.p(org.jboss.gwt.elemento.core.Elements.p) HTMLElement(elemental2.dom.HTMLElement) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) CrudOperations(org.jboss.hal.core.CrudOperations) Table(org.jboss.hal.ballroom.table.Table) Collections.emptyList(java.util.Collections.emptyList) SuggestHandler(org.jboss.hal.ballroom.form.SuggestHandler) FORM(org.jboss.hal.resources.Ids.FORM) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) PostConstruct(javax.annotation.PostConstruct) JSON_FORMATTER_TEMPLATE(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates.JSON_FORMATTER_TEMPLATE) CSS.fontAwesome(org.jboss.hal.resources.CSS.fontAwesome) ModelNode(org.jboss.hal.dmr.ModelNode) FileFormItem(org.jboss.hal.core.ui.FileFormItem) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) Tabs(org.jboss.hal.ballroom.Tabs) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) XML_FORMATTER_TEMPLATE(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates.XML_FORMATTER_TEMPLATE) TAB(org.jboss.hal.resources.Ids.TAB) Elements.section(org.jboss.gwt.elemento.core.Elements.section) AddressTemplate(org.jboss.hal.meta.AddressTemplate) MbuiElement(org.jboss.hal.spi.MbuiElement) Constants(org.jboss.hal.resources.Constants) EmptyState(org.jboss.hal.ballroom.EmptyState) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) DomGlobal.document(elemental2.dom.DomGlobal.document) Operation(org.jboss.hal.dmr.Operation) Ids(org.jboss.hal.resources.Ids) CATEGORY(org.jboss.hal.resources.Names.CATEGORY) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) CSS.marginTopLarge(org.jboss.hal.resources.CSS.marginTopLarge) FormItem(org.jboss.hal.ballroom.form.FormItem) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) MbuiView(org.jboss.hal.spi.MbuiView) SELECTED_LOGGING_PROFILE_TEMPLATE(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates.SELECTED_LOGGING_PROFILE_TEMPLATE) NamedNode(org.jboss.hal.dmr.NamedNode) Elements(org.jboss.gwt.elemento.core.Elements) Form(org.jboss.hal.ballroom.form.Form) EmptyState(org.jboss.hal.ballroom.EmptyState) HTMLElement(elemental2.dom.HTMLElement) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) Constants(org.jboss.hal.resources.Constants) NamedNode(org.jboss.hal.dmr.NamedNode) Operation(org.jboss.hal.dmr.Operation) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) StatementContext(org.jboss.hal.meta.StatementContext) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) Tabs(org.jboss.hal.ballroom.Tabs) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) PostConstruct(javax.annotation.PostConstruct)

Example 2 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class JGroupsPresenter method addStack.

// stack resources
@SuppressWarnings("ConstantConditions")
void addStack() {
    Metadata metadata = metadataRegistry.lookup(STACK_TEMPLATE);
    Metadata transportMetadata = metadataRegistry.lookup(TRANSPORT_TEMPLATE).forOperation(ADD);
    transportMetadata.copyAttribute(SOCKET_BINDING, metadata);
    metadata.makeWritable(SOCKET_BINDING);
    NameItem nameItem = new NameItem();
    String transportLabel = new LabelBuilder().label(TRANSPORT);
    TextBoxItem transportItem = new TextBoxItem(TRANSPORT, transportLabel);
    transportItem.setRequired(true);
    String id = Ids.build(Ids.JGROUPS_STACK_CONFIG, Ids.ADD);
    ModelNodeForm<ModelNode> form = new ModelNodeForm.Builder<>(id, metadata).unboundFormItem(nameItem, 0).unboundFormItem(transportItem, 2).unsorted().requiredOnly().build();
    AddResourceDialog dialog = new AddResourceDialog(Names.STACK, form, (name, model) -> {
        ResourceAddress stackAddress = STACK_TEMPLATE.resolve(filterStatementContext, name);
        String transport = transportItem.getValue();
        ResourceAddress transportAddress = TRANSPORT_TEMPLATE.resolve(filterStatementContext, name, transport);
        Operation addStackOperation = new Operation.Builder(stackAddress, ADD).build();
        Operation addTransportOperation = new Operation.Builder(transportAddress, ADD).payload(model).build();
        Composite composite = new Composite(addStackOperation, addTransportOperation);
        dispatcher.execute(composite, (CompositeResult result) -> {
            MessageEvent.fire(eventBus, Message.success(resources.messages().addResourceSuccess(Names.STACK, name)));
            reload();
        });
    });
    dialog.show();
}
Also used : AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) Composite(org.jboss.hal.dmr.Composite) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) CompositeResult(org.jboss.hal.dmr.CompositeResult) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) Operation(org.jboss.hal.dmr.Operation) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) TextBoxItem(org.jboss.hal.ballroom.form.TextBoxItem) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode)

Example 3 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class HostPreviewAttributes method refresh.

public static void refresh(Host host, PreviewAttributes<Host> attributes, HostActions hostActions) {
    attributes.refresh(host);
    LabelBuilder labelBuilder = new LabelBuilder();
    boolean alive = host.isAlive();
    attributes.setVisible(RELEASE_CODENAME, alive);
    attributes.setVisible(RELEASE_VERSION, alive);
    attributes.setVisible(PRODUCT_NAME, alive);
    attributes.setVisible(PRODUCT_VERSION, alive);
    attributes.setVisible(HOST_STATE, host.isConnected() && !hostActions.isPending(host));
    attributes.setVisible(RUNNING_MODE, alive && !hostActions.isPending(host));
    attributes.setVisible(labelBuilder.label(MANAGEMENT_VERSION), alive && !Version.EMPTY_VERSION.equals(host.getManagementVersion()));
    attributes.setVisible(labelBuilder.label(LAST_CONNECTED), !host.isConnected());
    attributes.setVisible(labelBuilder.label(DISCONNECTED), !host.isConnected());
}
Also used : LabelBuilder(org.jboss.hal.ballroom.LabelBuilder)

Example 4 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder in project console by hal.

the class ResetServerDialog method reset.

void reset(String messagingServer) {
    LabelBuilder labelBuilder = new LabelBuilder();
    String l1 = labelBuilder.label(RESET_ALL_MESSAGE_COUNTERS);
    Property p1 = metadata.getDescription().findOperation(RESET_ALL_MESSAGE_COUNTERS);
    if (p1 != null && p1.getValue().hasDefined(DESCRIPTION)) {
        l1 = p1.getValue().get(DESCRIPTION).asString();
        l1 = Strings.sanitize(l1);
    }
    String l2 = labelBuilder.label(RESET_ALL_MESSAGE_COUNTER_HISTORIES);
    Property p2 = metadata.getDescription().findOperation(RESET_ALL_MESSAGE_COUNTER_HISTORIES);
    if (p2 != null && p2.getValue().hasDefined(DESCRIPTION)) {
        l2 = p2.getValue().get(DESCRIPTION).asString();
        l2 = Strings.sanitize(l2);
    }
    Form<ModelNode> form = new ModelNodeForm.Builder<>(Ids.RESET_MESSAGE_COUNTERS, Metadata.empty()).unboundFormItem(new SwitchItem(RESET_ALL_MESSAGE_COUNTERS, l1)).unboundFormItem(new SwitchItem(RESET_ALL_MESSAGE_COUNTER_HISTORIES, l2)).onSave((f, changedValues) -> column.resetServer(messagingServer, !f.getFormItem(RESET_ALL_MESSAGE_COUNTERS).isEmpty(), !f.getFormItem(RESET_ALL_MESSAGE_COUNTER_HISTORIES).isEmpty())).build();
    form.addFormValidation(new RequireAtLeastOneAttributeValidation<>(asList(RESET_ALL_MESSAGE_COUNTERS, RESET_ALL_MESSAGE_COUNTER_HISTORIES), resources));
    // Make the long labels more readable
    stream(form.element().querySelectorAll("." + halFormLabel + ", ." + halFormInput)).filter(htmlElements()).map(asHtmlElement()).forEach(element -> element.style.width = WidthUnionType.of("50%"));
    Dialog dialog = new Dialog.Builder(resources.constants().reset()).add(form.element()).primary(resources.constants().reset(), form::save).size(Size.MEDIUM).closeIcon(true).closeOnEsc(true).cancel().build();
    dialog.registerAttachable(form);
    form.edit(new ModelNode());
    dialog.show();
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) Dialog(org.jboss.hal.ballroom.dialog.Dialog) RESET_ALL_MESSAGE_COUNTERS(org.jboss.hal.dmr.ModelDescriptionConstants.RESET_ALL_MESSAGE_COUNTERS) Size(org.jboss.hal.ballroom.dialog.Dialog.Size) Ids(org.jboss.hal.resources.Ids) Elements.stream(org.jboss.gwt.elemento.core.Elements.stream) Elements.asHtmlElement(org.jboss.gwt.elemento.core.Elements.asHtmlElement) CSS.halFormLabel(org.jboss.hal.resources.CSS.halFormLabel) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) Elements.htmlElements(org.jboss.gwt.elemento.core.Elements.htmlElements) Property(org.jboss.hal.dmr.Property) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) SwitchItem(org.jboss.hal.ballroom.form.SwitchItem) RESET_ALL_MESSAGE_COUNTER_HISTORIES(org.jboss.hal.dmr.ModelDescriptionConstants.RESET_ALL_MESSAGE_COUNTER_HISTORIES) Resources(org.jboss.hal.resources.Resources) DESCRIPTION(org.jboss.hal.dmr.ModelDescriptionConstants.DESCRIPTION) Arrays.asList(java.util.Arrays.asList) RequireAtLeastOneAttributeValidation(org.jboss.hal.core.mbui.form.RequireAtLeastOneAttributeValidation) Strings(org.jboss.hal.resources.Strings) WidthUnionType(elemental2.dom.CSSProperties.WidthUnionType) Metadata(org.jboss.hal.meta.Metadata) CSS.halFormInput(org.jboss.hal.resources.CSS.halFormInput) Form(org.jboss.hal.ballroom.form.Form) Dialog(org.jboss.hal.ballroom.dialog.Dialog) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) ModelNode(org.jboss.hal.dmr.ModelNode) Property(org.jboss.hal.dmr.Property) SwitchItem(org.jboss.hal.ballroom.form.SwitchItem)

Example 5 with LabelBuilder

use of org.jboss.hal.ballroom.LabelBuilder 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

LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)48 ModelNode (org.jboss.hal.dmr.ModelNode)33 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)32 Metadata (org.jboss.hal.meta.Metadata)28 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)26 Operation (org.jboss.hal.dmr.Operation)25 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)23 Form (org.jboss.hal.ballroom.form.Form)20 Ids (org.jboss.hal.resources.Ids)17 List (java.util.List)15 ModelDescriptionConstants (org.jboss.hal.dmr.ModelDescriptionConstants)15 AddressTemplate (org.jboss.hal.meta.AddressTemplate)15 Resources (org.jboss.hal.resources.Resources)15 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)14 EventBus (com.google.web.bindery.event.shared.EventBus)14 Dispatcher (org.jboss.hal.dmr.dispatch.Dispatcher)14 StatementContext (org.jboss.hal.meta.StatementContext)14 Names (org.jboss.hal.resources.Names)14 Inject (javax.inject.Inject)13 NamedNode (org.jboss.hal.dmr.NamedNode)12