Search in sources :

Example 1 with HTMLPreElement

use of elemental2.dom.HTMLPreElement in project console by hal.

the class ConfigurationChangeDisplay method getDescriptionHtml.

@Override
@SuppressWarnings("HardCodedStringLiteral")
public SafeHtml getDescriptionHtml() {
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    if (hideDescriptionWhenLarge()) {
        html.append(SafeHtmlUtils.fromTrustedString("<pre class=\"" + formControlStatic + " " + wrap + "\">"));
    }
    item.changes().forEach(m -> {
        String op = m.get(OPERATION).asString();
        ResourceAddress address = new ResourceAddress(m.get(ADDRESS));
        html.append(SafeHtmlUtils.fromTrustedString(resources.constants().operation() + ": <strong>" + op + "</strong><br/>"));
        html.append(SafeHtmlUtils.fromTrustedString(resources.constants().address() + ": <strong>" + address + "</strong><br/>"));
        HTMLPreElement elem = pre().css(formControlStatic, wrap).element();
        m.asPropertyList().forEach(prop -> {
            boolean allowedProperties = !(prop.getName().equals(OPERATION) || prop.getName().equals(ADDRESS) || prop.getName().equals(OPERATION_HEADERS));
            if (allowedProperties) {
                html.append(SafeHtmlUtils.fromTrustedString("&nbsp;&nbsp;&nbsp;&nbsp;" + prop.getName() + COLON + prop.getValue() + "<br/>"));
            }
        });
    });
    if (hideDescriptionWhenLarge()) {
        html.append(SafeHtmlUtils.fromTrustedString("</pre>"));
    }
    return html.toSafeHtml();
}
Also used : ResourceAddress(org.jboss.hal.dmr.ResourceAddress) HTMLPreElement(elemental2.dom.HTMLPreElement) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 2 with HTMLPreElement

use of elemental2.dom.HTMLPreElement in project console by hal.

the class ConfigurationChangesPresenter method showInDialog.

void showInDialog(String textContent) {
    HTMLPreElement elem = pre().css(formControlStatic, wrap).element();
    elem.textContent = textContent;
    HTMLElement content = div().add(elem).style("overflow: scroll").element();
    int maxheight = applicationHeight() - 6 * MARGIN_BIG;
    content.style.maxHeight = CSSProperties.MaxHeightUnionType.of(px(maxheight));
    Dialog dialog = new Dialog.Builder(resources.constants().configurationChanges()).primary(resources.constants().close(), () -> true).closeOnEsc(true).closeIcon(true).size(LARGE).add(content).build();
    dialog.show();
}
Also used : HTMLElement(elemental2.dom.HTMLElement) HTMLPreElement(elemental2.dom.HTMLPreElement) Dialog(org.jboss.hal.ballroom.dialog.Dialog) OperationFormBuilder(org.jboss.hal.core.mbui.form.OperationFormBuilder)

Aggregations

HTMLPreElement (elemental2.dom.HTMLPreElement)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)1 HTMLElement (elemental2.dom.HTMLElement)1 Dialog (org.jboss.hal.ballroom.dialog.Dialog)1 OperationFormBuilder (org.jboss.hal.core.mbui.form.OperationFormBuilder)1 ResourceAddress (org.jboss.hal.dmr.ResourceAddress)1