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

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

Introduction

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

Prototype

public SafeHtmlBuilder() 

Source Link

Document

Constructs an empty SafeHtmlBuilder.

Usage

From source file:org.jboss.hal.client.runtime.configurationchanges.ConfigurationChangeDisplay.java

License:Apache License

@Override
@SuppressWarnings("HardCodedStringLiteral")
public Iterable<HTMLElement> getAdditionalInfoElements() {
    return collect().add(div().css(halConfChangesAdditionalInfo).add(p().css(textRight)
            .innerHtml(new SafeHtmlBuilder().appendEscaped(resources.constants().accessMechanism() + COLON)
                    .appendEscaped(item.getAccessMechanism()).appendHtmlConstant("<br/>")

                    .appendEscaped(resources.constants().remoteAddress() + COLON)
                    .appendEscaped(item.getRemoteAddress()).appendHtmlConstant("<br/>")

                    .appendEscaped(resources.constants().composite() + COLON)
                    .appendEscaped(String.valueOf(item.isComposite())).toSafeHtml())))
            .get();/*from  w  ww .  j  a  v  a  2s.c om*/
}

From source file:org.jboss.hal.client.runtime.host.HostView.java

License:Apache License

@Override
public void updateHost(Host host) {
    hostConfigurationForm.view(host);/*from w ww.  j  a  v  a2s .c  o  m*/
    hostConfigurationForm.getFormItem(NAME).unmask(); // makes no sense that this is sensitive
    HTMLElement element = (HTMLElement) document.getElementById("host-configuration-title");
    if (element != null) {
        element.innerHTML = new SafeHtmlBuilder()
                .appendEscaped(host.isDomainController() ? Names.DOMAIN_CONTROLLER : Names.HOST_CONTROLLER)
                .appendEscaped(" ").appendHtmlConstant("<code>").appendEscaped(host.getName())
                .appendHtmlConstant("</code>").toSafeHtml().asString();
    }
}

From source file:org.jboss.hal.client.runtime.managementoperations.ManagementOperationsDisplay.java

License:Apache License

@Override
@SuppressWarnings("HardCodedStringLiteral")
public SafeHtml getDescriptionHtml() {
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.append(resources.messages().operationLabel(operation.getOperation()));
    if (operation.getActiveAddressHost() != null) {
        html.append(resources.messages().operationHost(operation.getActiveAddressHost()));
    }//from  w w  w  .  ja v  a2  s .c  o  m
    if (operation.getActiveAddressServer() != null) {
        html.append(resources.messages().operationServer(operation.getActiveAddressServer()));
    }
    html.append(resources.messages().addressLabel(operation.getAddress()));
    html.append(resources.messages().callerThreadLabel(operation.getCallerThread()));
    html.append(resources.messages().executionStatusLabel(operation.getExecutionStatus(),
            operation.getExecutionStatusDescription()));
    return html.toSafeHtml();
}

From source file:org.jboss.hal.client.runtime.managementoperations.ManagementOperationsDisplay.java

License:Apache License

@Override
@SuppressWarnings("HardCodedStringLiteral")
public Iterable<HTMLElement> getAdditionalInfoElements() {
    Messages messages = resources.messages();
    return collect().add(div().css(halConfChangesAdditionalInfo)
            .add(p().css(textRight).innerHtml(new SafeHtmlBuilder()
                    .append(messages.accessMechanismLabel(operation.getAccessMechanism()))
                    .append(messages.runningTimeLabel(
                            Format.humanReadableDurationNanoseconds(operation.getRunningTime())))
                    .append(messages.exclusiveRunningTimeLabel(
                            Format.humanReadableDurationNanoseconds(operation.getExclusiveRunningTime())))
                    .append(messages.cancelledLabel(operation.isCancelled()))
                    .append(messages.domainRolloutLabel(operation.isDomainRollout())).toSafeHtml())))
            .get();//from  w w w  . j  a  va 2s  .co  m
}

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());
    }/* w  w  w. j a v a 2  s  .  c o  m*/
    return html.toSafeHtml();
}

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

License:Apache License

@Override
@SuppressWarnings("HardCodedStringLiteral")
public Iterable<HTMLElement> getAdditionalInfoElements() {
    return collect()
            .add(div().css(halExecutionTime).add(p().css(textRight).innerHtml(new SafeHtmlBuilder()
                    .appendEscaped(resources.constants().start() + COLON)
                    .appendEscaped(mediumDateTime(item.getCreateTime())).appendHtmlConstant(BR)
                    .appendEscaped(resources.constants().finished() + COLON)
                    .appendEscaped(failsSafeTime(item, END_TIME, itm -> mediumDateTime(item.getEndTime())))
                    .appendHtmlConstant(BR).appendEscaped(resources.constants().lastModified() + COLON)
                    .appendEscaped(failsSafeTime(item, LAST_UPDATED_TIME,
                            itm -> mediumDateTime(item.getLastUpdatedTime())))
                    .toSafeHtml())))/*  w  w  w . j ava  2  s . co  m*/
            .add(div().css(halExecutionDuration)
                    .add(span().css(fontAwesome("clock-o", x2), marginRight5)
                            .title(resources.constants().duration()))
                    .add(p().css(CSS.lead)
                            .textContent(failsSafeTime(item, END_TIME,
                                    itm -> humanReadableDuration(
                                            itm.getEndTime().getTime() - item.getCreateTime().getTime())))))
            .get();
}

From source file:org.jboss.hal.client.runtime.subsystem.datasource.DataSourcePreview.java

License:Apache License

DataSourcePreview(DataSourceColumn column, Server server, DataSource dataSource, Environment environment,
        Dispatcher dispatcher, StatementContext statementContext, ServerActions serverActions,
        FinderPathFactory finderPathFactory, Places places, Resources resources) {

    super(dataSource.getName(), dataSource.isXa() ? Names.XA_DATASOURCE : Names.DATASOURCE);
    this.server = server;
    this.dataSource = dataSource;
    this.environment = environment;
    this.dispatcher = dispatcher;
    this.statementContext = statementContext;
    this.dataSourceAddress = column.dataSourceAddress(dataSource);

    if (dataSource.fromDeployment()) {
        FinderPath path = finderPathFactory.deployment(dataSource.getDeployment());
        PlaceRequest placeRequest = places.finderPlace(NameTokens.DEPLOYMENTS, path).build();
        Elements.removeChildrenFrom(getLeadElement());
        getLeadElement().appendChild(/*www.j  a v  a  2s  .c o  m*/
                document.createTextNode(dataSource.isXa() ? Names.XA_DATASOURCE : Names.DATASOURCE + " @ "));
        getLeadElement().appendChild(a(places.historyToken(placeRequest)).textContent(dataSource.getPath())
                .title(resources.messages().goTo(Names.DEPLOYMENTS)).get());
    }

    fromDeployment = new EmptyState.Builder(Ids.DATA_SOURCE_RUNTIME_STATISTICS_NOT_AVAILABLE,
            resources.constants().statisticsNotAvailableHeader())
                    .description(resources.messages().dataSourceStatisticsFromDeployment())
                    .icon(fontAwesome("line-chart")).build();
    noStatistics = new EmptyState.Builder(Ids.DATA_SOURCE_RUNTIME_STATISTICS_NOT_ENABLED,
            resources.constants().statisticsDisabledHeader())
                    .description(resources.messages().dataSourceStatisticsDisabled(dataSource.getName()))
                    .icon(fontAwesome("line-chart"))
                    .primaryAction(resources.constants().enableStatistics(),
                            () -> column.enableStatistics(dataSource),
                            Constraint.writable(column.dataSourceConfigurationTemplate(dataSource), ENABLED))
                    .build();

    Constraint reloadConstraint = environment.isStandalone()
            ? Constraint.executable(AddressTemplate.of("/"), RELOAD)
            : Constraint.executable(AddressTemplate.of("/{selected.host}/server-config=*"), RELOAD);
    Constraint restartConstraint = environment.isStandalone()
            ? Constraint.executable(AddressTemplate.of("/"), RELOAD)
            : Constraint.executable(AddressTemplate.of("/{selected.host}/server-config=*"), RESTART);

    needsReloadWarning = new Alert(Icons.WARNING,
            new SafeHtmlBuilder().append(resources.messages().serverNeedsReload(server.getName()))
                    .appendEscaped(" ").append(resources.messages().staleStatistics()).toSafeHtml(),
            resources.constants().reload(), event -> serverActions.reload(server), reloadConstraint);

    needsRestartWarning = new Alert(Icons.WARNING,
            new SafeHtmlBuilder().append(resources.messages().serverNeedsRestart(server.getName()))
                    .appendEscaped(" ").append(resources.messages().staleStatistics()).toSafeHtml(),
            resources.constants().restart(), event -> serverActions.restart(server), restartConstraint);

    disabledWarning = new Alert(Icons.WARNING,
            resources.messages().dataSourceDisabledNoStatistics(dataSource.getName()),
            resources.constants().enable(), event -> column.enableDataSource(dataSource),
            Constraint.writable(column.dataSourceConfigurationTemplate(dataSource), STATISTICS_ENABLED));

    activeConnections = new Utilization(resources.constants().active(), resources.constants().connections(),
            environment.isStandalone(), true);
    maxUsedConnections = new Utilization(resources.constants().maxUsed(), resources.constants().connections(),
            environment.isStandalone(), true);
    hitCount = new Utilization(resources.constants().hitCount(), resources.constants().count(),
            environment.isStandalone(), false);
    missCount = new Utilization(resources.constants().missCount(), resources.constants().count(),
            environment.isStandalone(), false);

    getHeaderContainer().appendChild(refresh = refreshLink(() -> update(null)));
    previewBuilder().add(fromDeployment).add(noStatistics).add(needsReloadWarning).add(needsRestartWarning)
            .add(disabledWarning)
            .add(poolHeader = h(2).css(underline).textContent(resources.constants().connectionPool()).get())
            .add(activeConnections).add(maxUsedConnections).add(cacheHeader = h(2).css(underline)
                    .textContent(resources.constants().preparedStatementCache()).get())
            .add(hitCount).add(missCount);

    // to prevent flickering we initially hide everything
    setVisible(fromDeployment.element(), false);
    setVisible(noStatistics.element(), false);
    needsReloadWarning.element().classList.add(hidden);
    needsRestartWarning.element().classList.add(hidden);
    disabledWarning.element().classList.add(hidden);
}

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//w  w  w . ja va 2 s. c o  m
        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        builder.appendHtmlConstant("<p>");
        if (timestamp != null) {
            builder.appendEscaped(JMS_TIMESTAMP + COLON).appendEscaped(Format.mediumDateTime(timestamp))
                    .appendHtmlConstant("<br/>");
        }
        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/*  ww  w  .j a v a 2 s  .  c  o m*/
    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.client.runtime.TopologyPreview.java

License:Apache License

@SuppressWarnings("HardCodedStringLiteral")
private HTMLElement buildTable(List<Host> hosts, List<ServerGroup> serverGroups, List<Server> servers) {
    HTMLTableElement table = table().css(topology).get();

    // <colgroup>
    double width = 100.0 / (serverGroups.size() + 1);
    HtmlContentBuilder<HTMLTableColElement> colgroup = colgroup().add(col().attr("width", width + "%"));
    for (int i = 0; i < serverGroups.size(); i++) {
        colgroup.add(col().attr("width", width + "%"));
    }//from  ww  w  .j  av a  2s.  co m
    table.appendChild(colgroup.get());
    // </colgroup>

    // <thead>
    HtmlContentBuilder<HTMLTableSectionElement> thead = thead().add(tr()
            .add(th().css(empty)
                    .innerHtml(new SafeHtmlBuilder().appendEscaped(Names.SERVER_GROUPS + " ")
                            .appendHtmlConstant("&rarr;").appendHtmlConstant("<br/>")
                            .appendEscaped(Names.HOSTS + " ").appendHtmlConstant("&darr;").toSafeHtml()))
            .addAll(serverGroups.stream().map(this::serverGroupElement).collect(toList())));
    table.appendChild(thead.get());
    // </thead>

    HTMLElement tbody = tbody().get();
    for (Host host : hosts) {
        HTMLElement tr;
        tbody.appendChild(tr = tr().get());
        tr.appendChild(hostElement(host));
        for (ServerGroup serverGroup : serverGroups) {
            List<HTMLElement> matchingServers = servers.stream()
                    .filter(sc -> host.getName().equals(sc.getHost())
                            && serverGroup.getName().equals(sc.getServerGroup()))
                    .sorted(comparing(Server::getName)).map(this::serverElement).collect(toList());
            if (matchingServers.isEmpty()) {
                tr.appendChild(td().css(empty).get());
            } else {
                tr.appendChild(td().add(div().css(CSS.servers).addAll(matchingServers)).get());
            }
        }
    }
    table.appendChild(tbody);
    // </tbody>

    return table;
}