Example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant

List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant

Introduction

In this page you can find the example usage for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant.

Prototype

public SafeHtmlBuilder appendHtmlConstant(String html) 

Source Link

Document

Appends a compile-time-constant string, which will not be escaped.

Usage

From source file:org.jboss.hal.client.deployment.UploadStatistics.java

License:Apache License

private SafeHtml sentences(SortedSet<String> added, SortedSet<String> replaced, SortedSet<String> failed) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    if (!added.isEmpty()) {
        if (environment.isStandalone()) {
            builder.append(MESSAGES.deploymentAdded(added.size()));
        } else {/*from w w  w  . j  a  v a  2 s .  c o m*/
            builder.append(MESSAGES.contentAdded(added.size()));
        }
        if (!replaced.isEmpty() || !failed.isEmpty()) {
            builder.appendHtmlConstant("<br/>"); //NON-NLS
        }
    }
    if (!replaced.isEmpty()) {
        if (environment.isStandalone()) {
            builder.append(MESSAGES.deploymentReplaced(replaced.size()));
        } else {
            builder.append(MESSAGES.contentReplaced(replaced.size()));
        }
        if (!failed.isEmpty()) {
            builder.appendHtmlConstant("<br/>"); //NON-NLS
        }
    }
    if (!failed.isEmpty()) {
        if (environment.isStandalone()) {
            builder.append(MESSAGES.deploymentOpFailed(failed.size()));
        } else {
            builder.append(MESSAGES.contentOpFailed(failed.size()));
        }
    }
    return builder.toSafeHtml();
}

From source file:org.jboss.hal.client.runtime.subsystem.batch.ExecutionNodeDisplay.java

License:Apache License

@Override
@SuppressWarnings("HardCodedStringLiteral")
public SafeHtml getDescriptionHtml() {
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendEscaped(Names.INSTANCE_ID + COLON + item.getInstanceId()).appendHtmlConstant(BR)
            .appendEscaped(Names.BATCH_STATUS + COLON + item.getBatchStatus());
    if (item.getExitError() != null) {
        html.appendHtmlConstant(BR).appendEscaped(item.getExitError());
    }/*  ww w.  j  a  v a  2  s .c  o m*/
    return html.toSafeHtml();
}

From source file:org.jboss.hal.client.runtime.subsystem.messaging.JmsMessageDisplay.java

License:Apache License

@Override
public SafeHtml getDescriptionHtml() {
    Date timestamp = message.getTimestamp();
    Date expiration = message.getExpiration();
    if (timestamp != null || expiration != null) {
        @NonNls
        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        builder.appendHtmlConstant("<p>");
        if (timestamp != null) {
            builder.appendEscaped(JMS_TIMESTAMP + COLON).appendEscaped(Format.mediumDateTime(timestamp))
                    .appendHtmlConstant("<br/>");
        }// ww  w  . jav a  2  s.com
        if (expiration != null) {
            builder.appendEscaped(JMS_EXPIRATION + COLON).appendEscaped(Format.mediumDateTime(expiration));
        }
        return builder.toSafeHtml();
    }
    return null;
}

From source file:org.jboss.hal.client.runtime.subsystem.messaging.JmsMessageDisplay.java

License:Apache License

@Override
public SafeHtml getAdditionalInfoHtml() {
    @NonNls
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<p>").appendEscaped(JMS_PRIORITY + COLON + message.get(JMS_PRIORITY).asInt())
            .appendHtmlConstant("</br/>")
            .appendEscaped(JMS_DELIVERY_MODE + COLON + message.get(JMS_DELIVERY_MODE).asString())
            .appendHtmlConstant("</p>");
    return builder.toSafeHtml();
}

From source file:org.jboss.hal.core.modelbrowser.AttributesTable.java

License:Apache License

AttributesTable(List<Property> attributes, Resources resources) {

    HTMLElement tbody;//  w ww. j  a  va 2s . c o  m
    this.root = table().css(table, tableBordered, tableStriped, CSS.attributes)
            .add(thead().add(tr().add(th().textContent(resources.constants().attribute()))
                    .add(th().textContent(resources.constants().type()))
                    .add(th().textContent(resources.constants().storage()))
                    .add(th().textContent(resources.constants().accessType()))))
            .add(tbody = tbody().get()).get();

    HelpTextBuilder helpTextBuilder = new HelpTextBuilder();
    for (Property property : Ordering.natural().onResultOf(Property::getName).sortedCopy(attributes)) {
        ModelNode attribute = property.getValue();
        boolean required = attribute.hasDefined(NILLABLE) && !attribute.get(NILLABLE).asBoolean();
        boolean deprecated = attribute.hasDefined(DEPRECATED) && attribute.get(DEPRECATED).asBoolean();
        SafeHtml description = helpTextBuilder.helpText(property);

        // start a new table row
        HtmlContentBuilder<HTMLTableRowElement> builder = tr();

        // attribute name & description
        @NonNls
        SafeHtmlBuilder html = new SafeHtmlBuilder();
        html.appendHtmlConstant(
                "<strong" + (deprecated ? " class=\"" + CSS.deprecated + "\" title=\"deprecated\"" : "") + ">")
                .appendEscaped(property.getName()).appendHtmlConstant("</strong>");
        if (required) {
            html.appendHtmlConstant(NBSP).append(resources.messages().requiredMarker());
        }
        if (description != null) {
            html.appendHtmlConstant("<br/>").append(description);
        }
        builder.add(td().innerHtml(html.toSafeHtml()));

        // type
        builder.add(td().textContent(Types.formatType(attribute)));

        // storage
        HTMLElement storageTd;
        builder.add(storageTd = td().get());
        if (attribute.hasDefined(STORAGE)) {
            switch (attribute.get(STORAGE).asString()) {
            case CONFIGURATION:
                storageTd.appendChild(i().css(fontAwesome("database")).title(CONFIGURATION).get());
                break;
            case RUNTIME:
                storageTd.appendChild(i().css(pfIcon("memory")).title(RUNTIME).get());
                break;
            default:
                storageTd.innerHTML = SafeHtmlUtils.fromSafeConstant(NBSP).asString();
                break;
            }
        } else {
            builder.innerHtml(SafeHtmlUtils.fromSafeConstant(NBSP));
        }

        // access type
        HTMLElement accessTypeTd;
        builder.add(accessTypeTd = td().get());
        if (attribute.hasDefined(ACCESS_TYPE)) {
            switch (attribute.get(ACCESS_TYPE).asString()) {
            case READ_WRITE:
                accessTypeTd.appendChild(i().css(pfIcon("edit")).title(READ_WRITE).get());
                break;
            case READ_ONLY:
                accessTypeTd.appendChild(i().css(fontAwesome("lock")).title(READ_ONLY).get());
                break;
            case METRIC:
                accessTypeTd.appendChild(i().css(pfIcon("trend-up")).title(METRIC).get());
                break;
            default:
                accessTypeTd.innerHTML = SafeHtmlUtils.fromSafeConstant(NBSP).asString();
                break;
            }
        } else {
            builder.innerHtml(SafeHtmlUtils.fromSafeConstant(NBSP));
        }

        tbody.appendChild(builder.get());
    }
}

From source file:org.jboss.hal.core.modelbrowser.OperationsTable.java

License:Apache License

OperationsTable(List<Property> operations, Resources resources) {
    HTMLElement tbody;//  w w w .  ja  v a2s .  c o  m

    this.resources = resources;
    this.root = table().css(table, tableBordered, tableStriped, CSS.operations)
            .add(thead().add(
                    tr().add(th().textContent(Names.NAME)).add(th().textContent(resources.constants().input()))
                            .add(th().textContent(resources.constants().output()))))
            .add(tbody = tbody().get()).get();

    for (Property property : Ordering.natural().onResultOf(Property::getName).sortedCopy(operations)) {
        ModelNode operation = property.getValue();
        String description = operation.hasDefined(DESCRIPTION) ? operation.get(DESCRIPTION).asString() : null;

        // start a new table row
        HtmlContentBuilder<HTMLTableRowElement> builder = tr();

        // operation name & description
        SafeHtmlBuilder html = new SafeHtmlBuilder();
        html.appendHtmlConstant("<strong>") //NON-NLS
                .appendEscaped(property.getName()).appendHtmlConstant("</strong>"); //NON-NLS
        if (description != null) {
            html.appendHtmlConstant("<br/>").appendEscaped(description); //NON-NLS
        }
        builder.add(td().innerHtml(html.toSafeHtml()));

        // input
        HTMLElement inputTd;
        builder.add(inputTd = td().get());
        if (operation.hasDefined(REQUEST_PROPERTIES)
                && !operation.get(REQUEST_PROPERTIES).asPropertyList().isEmpty()) {
            List<Property> input = operation.get(REQUEST_PROPERTIES).asPropertyList();
            HTMLElement ul;
            inputTd.appendChild(ul = ul().css(operationParameter).get());
            for (Property parameter : Ordering.natural().onResultOf(Property::getName).sortedCopy(input)) {
                HTMLElement li;
                ul.appendChild(li = li().get());
                buildParameter(li, parameter.getName(), parameter.getValue());
            }
        } else {
            inputTd.innerHTML = SafeHtmlUtils.fromSafeConstant(NBSP).asString();
        }

        // output
        HTMLElement outputTd;
        builder.add(outputTd = td().get());
        if (operation.hasDefined(REPLY_PROPERTIES) && !operation.get(REPLY_PROPERTIES).asList().isEmpty()) {
            buildParameter(outputTd, null, operation.get(REPLY_PROPERTIES));
        } else {
            outputTd.innerHTML = SafeHtmlUtils.fromSafeConstant(NBSP).asString();
        }

        tbody.appendChild(builder.get());
    }
}

From source file:org.jboss.hal.core.modelbrowser.OperationsTable.java

License:Apache License

private void buildParameter(HTMLElement element, String name, ModelNode parameter) {
    boolean required = parameter.hasDefined(REQUIRED) && parameter.get(REQUIRED).asBoolean();
    String description = parameter.hasDefined(DESCRIPTION) ? parameter.get(DESCRIPTION).asString() : null;

    SafeHtmlBuilder html = new SafeHtmlBuilder();
    if (name != null) {
        //noinspection HardCodedStringLiteral
        html.appendHtmlConstant("<code>").appendEscaped(name).appendHtmlConstant("</code>").appendEscaped(": ");
    }/*from w  w  w.  j  a  va 2s. co m*/
    html.appendEscaped(Types.formatType(parameter));
    if (required) {
        html.appendHtmlConstant(NBSP).append(resources.messages().requiredMarker());
    }
    if (description != null) {
        html.appendHtmlConstant("<br/>").appendEscaped(description); //NON-NLS
    }
    element.innerHTML = html.toSafeHtml().asString();
}

From source file:org.jbpm.console.ng.gc.client.util.ButtonActionCell.java

License:Apache License

public void render(final Cell.Context context, final T value, final SafeHtmlBuilder sb) {
    final SafeHtmlBuilder mysb = new SafeHtmlBuilder();
    final Button btn = GWT.create(Button.class);
    btn.setText(getText(value));/*from ww w.  j av  a 2 s  .co  m*/
    btn.setTitle(getText(value));
    btn.setType(ButtonType.DEFAULT);
    btn.setSize(ButtonSize.SMALL);
    btn.getElement().getStyle().setMarginRight(5, Style.Unit.PX);
    mysb.appendHtmlConstant(btn.getElement().getString());
    sb.append(mysb.toSafeHtml());
}

From source file:org.jbpm.workbench.common.client.util.ConditionalKebabActionCell.java

License:Apache License

@Override
public void render(final Cell.Context context, final T value, final SafeHtmlBuilder sb) {

    final List<ConditionalAction<T>> availableActions = actions.stream()
            .filter(a -> a.getPredicate().test(value)).collect(Collectors.toList());
    if (availableActions.isEmpty()) {
        return;//from   ww w . ja v  a 2 s .  co  m
    }
    if (availableActions.size() > 1) {
        final KebabMenu menu = kebabMenus.get();
        menu.setItemsAlignment(KebabMenu.ItemsAlignment.RIGHT);
        menu.setDropPosition(KebabMenu.DropPosition.UP);
        menu.getElement().id = Document.get().createUniqueId();
        final List<ConditionalAction<T>> actionMenus = availableActions.stream()
                .filter(action -> action.isNavigation() == false).collect(Collectors.toList());
        actionMenus.forEach(action -> {
            addKebabMenuItem(menu, value, action.getText(), action.getCallback());
        });
        final List<ConditionalAction<T>> navigationMenus = availableActions.stream()
                .filter(action -> action.isNavigation()).collect(Collectors.toList());
        if (actionMenus.isEmpty() == false && navigationMenus.isEmpty() == false) {
            menu.addSeparator();
        }
        navigationMenus.forEach(action -> {
            addKebabMenuItem(menu, value, action.getText(), action.getCallback());
        });
        sb.appendHtmlConstant(getHTMLContent(menu.getElement()));

        fixOpenPosition(menu.getElement().id);
    } else {
        final Button button = buttons.get();
        button.setType(Button.ButtonType.BUTTON);
        button.setButtonStyleType(Button.ButtonStyleType.DEFAULT);
        button.setText(availableActions.get(0).getText());
        button.getElement().id = Document.get().createUniqueId();
        setCallback(button.getElement().id, value, availableActions.get(0).getCallback());
        sb.appendHtmlConstant(getHTMLContent(button.getElement()));
    }
}

From source file:org.jbpm.workbench.common.client.util.GenericErrorSummaryCountCell.java

License:Apache License

@Override
public void render(Context context, C value, SafeHtmlBuilder sb) {
    Integer errCount = (value != null && value.getErrorCount() != null ? value.getErrorCount() : 0);

    DOMTokenList tooltipClasses = tooltip.getClassList();
    tooltip.setTextContent(Integer.toString(errCount));

    if (errCount > 0) {
        tooltipClasses.add(ERROR_PRESENT_STYLE);
    } else {/*w w  w  .j  a v a2 s. com*/
        tooltipClasses.remove(ERROR_PRESENT_STYLE);
    }

    if (viewPresenter.getViewErrorsActionCondition().test(value)) {
        tooltip.setTitle(Constants.INSTANCE.ErrorCountNumberView(errCount));
        tooltip.setAttribute(DATA_INSTANCE_ATTRIBUTE, value.getId().toString());
        tooltipClasses.add(LINK_AVAILABLE_STYLE);

        initTooltipsAsync();

    } else {
        tooltip.removeAttribute("title");
        tooltip.removeAttribute(DATA_INSTANCE_ATTRIBUTE);
        tooltipClasses.remove(LINK_AVAILABLE_STYLE);
    }

    sb.appendHtmlConstant(tooltip.getOuterHTML());
}