Search in sources :

Example 1 with SelectionAwareStatementContext

use of org.jboss.hal.meta.SelectionAwareStatementContext 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 SelectionAwareStatementContext

use of org.jboss.hal.meta.SelectionAwareStatementContext in project console by hal.

the class LoggingView method init.

@PostConstruct
void init() {
    noRootLogger = new EmptyState.Builder("logging-root-logger-empty", mbuiContext.resources().constants().noRootLogger()).description(mbuiContext.resources().constants().noRootLoggerDescription()).icon("fa fa-sitemap").primaryAction(mbuiContext.resources().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(true);
    // --------------------------- json formatter
    LabelBuilder labelBuilder = new LabelBuilder();
    Metadata jsonMetadata = mbuiContext.metadataRegistry().lookup(JSON_FORMATTER_TEMPLATE);
    Metadata jsonKeyOverridesMetadata = jsonMetadata.forComplexAttribute(KEY_OVERRIDES);
    String jsonLabel = labelBuilder.label(JSON_FORMATTER_TEMPLATE.lastName());
    jsonFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING, JSON, FORMATTER, TABLE), jsonMetadata).button(mbuiContext.tableButtonFactory().add(Ids.build(LOGGING, JSON, FORMATTER, Ids.ADD), jsonLabel, JSON_FORMATTER_TEMPLATE, (name, address) -> presenter.reload())).button(mbuiContext.tableButtonFactory().remove(jsonLabel, JSON_FORMATTER_TEMPLATE, table -> table.selectedRow().getName(), () -> presenter.reload())).column(NAME, (cell, type, row, meta) -> row.getName()).build();
    jsonFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING, JSON, FORMATTER, FORM), jsonMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(jsonLabel, form.getModel().getName(), JSON_FORMATTER_TEMPLATE, changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(jsonLabel, jsonFormatterTable.selectedRow().getName(), JSON_FORMATTER_TEMPLATE, form, jsonMetadata, () -> presenter.reload())).build();
    jsonKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING, FORMATTER, JSON, KEY_OVERRIDES, FORM), jsonKeyOverridesMetadata).singleton(() -> {
        StatementContext jsonStatementContext = new SelectionAwareStatementContext(presenter.getStatementContext(), () -> jsonFormatterTable.selectedRow().getName());
        return new Operation.Builder(JSON_FORMATTER_TEMPLATE.resolve(jsonStatementContext), READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
    }, () -> presenter.addComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, JSON_FORMATTER_TEMPLATE)).onSave((form, changedValues) -> presenter.saveComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, JSON_FORMATTER_TEMPLATE, changedValues)).prepareReset(form -> presenter.resetComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, JSON_FORMATTER_TEMPLATE, jsonKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(jsonLabel, jsonFormatterTable.selectedRow().getName(), KEY_OVERRIDES, JSON_FORMATTER_TEMPLATE)).build();
    Tabs jsonTabs = new Tabs(Ids.build(LOGGING, FORMATTER, JSON, TAB_CONTAINER));
    jsonTabs.add(Ids.build(LOGGING, FORMATTER, JSON, ATTRIBUTES, TAB), mbuiContext.resources().constants().attributes(), jsonFormatterForm.element());
    jsonTabs.add(Ids.build(LOGGING, 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_FORMATTER_ITEM, Ids.build(LOGGING, FORMATTER, JSON, Ids.ITEM), null, Names.JSON_FORMATTER, jsonSection);
    // --------------------------- xml formatter
    Metadata xmlMetadata = mbuiContext.metadataRegistry().lookup(XML_FORMATTER_TEMPLATE);
    Metadata xmlKeyOverridesMetadata = xmlMetadata.forComplexAttribute(KEY_OVERRIDES);
    String xmlLabel = labelBuilder.label(XML_FORMATTER_TEMPLATE.lastName());
    xmlFormatterTable = new ModelNodeTable.Builder<NamedNode>(Ids.build(LOGGING, XML, FORMATTER, TABLE), xmlMetadata).button(mbuiContext.tableButtonFactory().add(Ids.build(LOGGING, XML, FORMATTER, Ids.ADD), xmlLabel, XML_FORMATTER_TEMPLATE, (name, address) -> presenter.reload())).button(mbuiContext.tableButtonFactory().remove(xmlLabel, XML_FORMATTER_TEMPLATE, table -> table.selectedRow().getName(), () -> presenter.reload())).column(NAME, (cell, type, row, meta) -> row.getName()).build();
    xmlFormatterForm = new ModelNodeForm.Builder<NamedNode>(Ids.build(LOGGING, XML, FORMATTER, FORM), xmlMetadata).onSave((form, changedValues) -> mbuiContext.crud().save(xmlLabel, form.getModel().getName(), XML_FORMATTER_TEMPLATE, changedValues, () -> presenter.reload())).prepareReset(form -> mbuiContext.crud().reset(xmlLabel, xmlFormatterTable.selectedRow().getName(), XML_FORMATTER_TEMPLATE, form, xmlMetadata, () -> presenter.reload())).build();
    xmlKeyOverridesForm = new ModelNodeForm.Builder<>(Ids.build(LOGGING, FORMATTER, XML, KEY_OVERRIDES, FORM), xmlKeyOverridesMetadata).singleton(() -> {
        StatementContext xmlStatementContext = new SelectionAwareStatementContext(presenter.getStatementContext(), () -> xmlFormatterTable.selectedRow().getName());
        return new Operation.Builder(XML_FORMATTER_TEMPLATE.resolve(xmlStatementContext), READ_ATTRIBUTE_OPERATION).param(NAME, KEY_OVERRIDES).build();
    }, () -> presenter.addComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, XML_FORMATTER_TEMPLATE)).onSave((form, changedValues) -> presenter.saveComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, XML_FORMATTER_TEMPLATE, changedValues)).prepareReset(form -> presenter.resetComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, XML_FORMATTER_TEMPLATE, xmlKeyOverridesMetadata, form)).prepareRemove(form -> presenter.removeComplexObject(xmlLabel, xmlFormatterTable.selectedRow().getName(), KEY_OVERRIDES, XML_FORMATTER_TEMPLATE)).build();
    Tabs xmlTabs = new Tabs(Ids.build(LOGGING, FORMATTER, XML, TAB_CONTAINER));
    xmlTabs.add(Ids.build(LOGGING, FORMATTER, XML, ATTRIBUTES, TAB), mbuiContext.resources().constants().attributes(), xmlFormatterForm.element());
    xmlTabs.add(Ids.build(LOGGING, 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_FORMATTER_ITEM, Ids.build(LOGGING, FORMATTER, XML, Ids.ITEM), null, Names.XML_FORMATTER, xmlSection);
}
Also used : ModelNode(org.jboss.hal.dmr.ModelNode) StatementContext(org.jboss.hal.meta.StatementContext) MessageEvent(org.jboss.hal.spi.MessageEvent) ModelNodeTable(org.jboss.hal.core.mbui.table.ModelNodeTable) TAB_CONTAINER(org.jboss.hal.resources.Ids.TAB_CONTAINER) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) MbuiViewImpl(org.jboss.hal.core.mbui.MbuiViewImpl) Elements.setVisible(org.jboss.gwt.elemento.core.Elements.setVisible) Tabs(org.jboss.hal.ballroom.Tabs) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) TAB(org.jboss.hal.resources.Ids.TAB) LOGGING_FORMATTER_ITEM(org.jboss.hal.resources.Ids.LOGGING_FORMATTER_ITEM) 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) Message(org.jboss.hal.spi.Message) EmptyState(org.jboss.hal.ballroom.EmptyState) Metadata(org.jboss.hal.meta.Metadata) Names(org.jboss.hal.resources.Names) Elements.h(org.jboss.gwt.elemento.core.Elements.h) DomGlobal.document(elemental2.dom.DomGlobal.document) Table(org.jboss.hal.ballroom.table.Table) Operation(org.jboss.hal.dmr.Operation) SuggestHandler(org.jboss.hal.ballroom.form.SuggestHandler) Ids(org.jboss.hal.resources.Ids) ReadChildrenAutoComplete(org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete) FORM(org.jboss.hal.resources.Ids.FORM) CSS.marginTopLarge(org.jboss.hal.resources.CSS.marginTopLarge) VerticalNavigation(org.jboss.hal.ballroom.VerticalNavigation) ModelNodeHelper.failSafeGet(org.jboss.hal.dmr.ModelNodeHelper.failSafeGet) List(java.util.List) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) AddressTemplates(org.jboss.hal.client.configuration.subsystem.logging.AddressTemplates) SelectionAwareStatementContext(org.jboss.hal.meta.SelectionAwareStatementContext) MbuiContext(org.jboss.hal.core.mbui.MbuiContext) ModelDescriptionConstants(org.jboss.hal.dmr.ModelDescriptionConstants) PostConstruct(javax.annotation.PostConstruct) MbuiView(org.jboss.hal.spi.MbuiView) NamedNode(org.jboss.hal.dmr.NamedNode) Form(org.jboss.hal.ballroom.form.Form) EmptyState(org.jboss.hal.ballroom.EmptyState) HTMLElement(elemental2.dom.HTMLElement) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) 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 3 with SelectionAwareStatementContext

use of org.jboss.hal.meta.SelectionAwareStatementContext in project console by hal.

the class LoggingProfileView method addFileHandlerResource.

private void addFileHandlerResource(String templateSuffix, String id, String type, String... attributes) {
    AddressTemplate metadataTemplate = LOGGING_PROFILE_TEMPLATE.append(templateSuffix);
    Metadata metadata = mbuiContext.metadataRegistry().lookup(metadataTemplate);
    AddressTemplate selectionTemplate = SELECTED_LOGGING_PROFILE_TEMPLATE.append(templateSuffix);
    ModelNodeForm.Builder<ModelNode> builder = new ModelNodeForm.Builder<>(id, metadata).fromRequestProperties().unboundFormItem(new NameItem(), 0).customFormItem("file", (attributeDescription) -> new FileFormItem(FILE, true)).unsorted();
    if (attributes != null) {
        builder.include(asList(attributes));
    }
    AddResourceDialog dialog = new AddResourceDialog(mbuiContext.resources().messages().addResourceTitle(type), builder.build(), (name, modelNode) -> {
        ResourceAddress address = selectionTemplate.resolve(selectionAwareStatementContext, name);
        crud().add(type, name, address, modelNode, (n, a) -> presenter.reload());
    });
    dialog.show();
}
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) AddResourceDialog(org.jboss.hal.core.mbui.dialog.AddResourceDialog) NameItem(org.jboss.hal.core.mbui.dialog.NameItem) ResourceAddress(org.jboss.hal.dmr.ResourceAddress) LabelBuilder(org.jboss.hal.ballroom.LabelBuilder) Metadata(org.jboss.hal.meta.Metadata) ModelNode(org.jboss.hal.dmr.ModelNode) ModelNodeForm(org.jboss.hal.core.mbui.form.ModelNodeForm) FileFormItem(org.jboss.hal.core.ui.FileFormItem)

Aggregations

DomGlobal.document (elemental2.dom.DomGlobal.document)3 HTMLElement (elemental2.dom.HTMLElement)3 Arrays.asList (java.util.Arrays.asList)3 List (java.util.List)3 PostConstruct (javax.annotation.PostConstruct)3 Elements.h (org.jboss.gwt.elemento.core.Elements.h)3 Elements.p (org.jboss.gwt.elemento.core.Elements.p)3 Elements.section (org.jboss.gwt.elemento.core.Elements.section)3 EmptyState (org.jboss.hal.ballroom.EmptyState)3 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)3 Tabs (org.jboss.hal.ballroom.Tabs)3 VerticalNavigation (org.jboss.hal.ballroom.VerticalNavigation)3 ReadChildrenAutoComplete (org.jboss.hal.ballroom.autocomplete.ReadChildrenAutoComplete)3 Form (org.jboss.hal.ballroom.form.Form)3 SuggestHandler (org.jboss.hal.ballroom.form.SuggestHandler)3 Table (org.jboss.hal.ballroom.table.Table)3 MbuiContext (org.jboss.hal.core.mbui.MbuiContext)3 MbuiViewImpl (org.jboss.hal.core.mbui.MbuiViewImpl)3 AddResourceDialog (org.jboss.hal.core.mbui.dialog.AddResourceDialog)3 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)3