use of org.jboss.hal.ballroom.dialog.Dialog.Size 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();
}
Aggregations