Search in sources :

Example 1 with RESET_ALL_MESSAGE_COUNTER_HISTORIES

use of org.jboss.hal.dmr.ModelDescriptionConstants.RESET_ALL_MESSAGE_COUNTER_HISTORIES 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)

Aggregations

WidthUnionType (elemental2.dom.CSSProperties.WidthUnionType)1 Arrays.asList (java.util.Arrays.asList)1 Elements.asHtmlElement (org.jboss.gwt.elemento.core.Elements.asHtmlElement)1 Elements.htmlElements (org.jboss.gwt.elemento.core.Elements.htmlElements)1 Elements.stream (org.jboss.gwt.elemento.core.Elements.stream)1 LabelBuilder (org.jboss.hal.ballroom.LabelBuilder)1 Dialog (org.jboss.hal.ballroom.dialog.Dialog)1 Size (org.jboss.hal.ballroom.dialog.Dialog.Size)1 Form (org.jboss.hal.ballroom.form.Form)1 SwitchItem (org.jboss.hal.ballroom.form.SwitchItem)1 ModelNodeForm (org.jboss.hal.core.mbui.form.ModelNodeForm)1 RequireAtLeastOneAttributeValidation (org.jboss.hal.core.mbui.form.RequireAtLeastOneAttributeValidation)1 DESCRIPTION (org.jboss.hal.dmr.ModelDescriptionConstants.DESCRIPTION)1 RESET_ALL_MESSAGE_COUNTERS (org.jboss.hal.dmr.ModelDescriptionConstants.RESET_ALL_MESSAGE_COUNTERS)1 RESET_ALL_MESSAGE_COUNTER_HISTORIES (org.jboss.hal.dmr.ModelDescriptionConstants.RESET_ALL_MESSAGE_COUNTER_HISTORIES)1 ModelNode (org.jboss.hal.dmr.ModelNode)1 Property (org.jboss.hal.dmr.Property)1 Metadata (org.jboss.hal.meta.Metadata)1 CSS.halFormInput (org.jboss.hal.resources.CSS.halFormInput)1 CSS.halFormLabel (org.jboss.hal.resources.CSS.halFormLabel)1