Java Code Examples for com.google.gwt.safehtml.shared.SafeHtmlBuilder#appendHtmlConstant()

The following examples show how to use com.google.gwt.safehtml.shared.SafeHtmlBuilder#appendHtmlConstant() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml serverGroupPreview(final ServerGroupRecord serverGroup, int deployments) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<p>");
    if (deployments == -1) {
        builder.appendEscaped("Deployments for server group ")
                .appendEscaped(serverGroup.getName())
                .appendEscaped(" cannot be read.");
    } else if (deployments == 0) {
        builder.appendEscaped("Server group ")
                .appendEscaped(serverGroup.getName())
                .appendEscaped(" does not contain deployments.");
    } else {
        builder.appendEscaped("Server group ")
                .appendEscaped(serverGroup.getName())
                .appendEscaped(" contains ")
                .append(deployments)
                .appendEscaped(" deployment(s).");
    }
    builder.appendHtmlConstant("</p>");
    return PREVIEWS.serverGroup(builder.toSafeHtml());
}
 
Example 2
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml memberPreview(final Assignment assignment, int memberAssignments) {
    int otherAssignments = max(0, memberAssignments - 1);
    Principal member = assignment.getPrincipal();
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<p>");
    if (!assignment.isInclude()) {
        builder.appendEscaped("Excluded from role ").appendEscaped(assignment.getRole().getName())
                .appendEscaped(". ");
    }
    if (otherAssignments == 0) {
        builder.appendEscaped("Not used in other assignments. ");
    } else if (otherAssignments == 1) {
        builder.appendEscaped("Used in one other assignment. ");
    } else {
        builder.appendEscaped("Used in ").append(otherAssignments).appendEscaped(" other assignments. ");
    }
    if (member.getRealm() != null) {
        builder.appendEscaped("Bound to realm '").appendEscaped(member.getRealm()).appendEscaped("'.");
    }
    builder.appendHtmlConstant("</p>");
    return PREVIEWS.member(member.getName(), builder.toSafeHtml());
}
 
Example 3
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
static SafeHtml unmanaged() {
    // TODO I18n or take from DMR
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.appendHtmlConstant("<table class='help-attribute-descriptions'>");
    addHelpTextRow(builder, "Path:",
            Console.CONSTANTS.unmanagedDeploymentPathDescription());
    addHelpTextRow(builder, "Relative To:",
            Console.CONSTANTS.unmanagedDeploymentRelativeToDescription());
    addHelpTextRow(builder, "Is Archive?:",
            Console.CONSTANTS.unmanagedDeploymentArchiveDescription());
    addHelpTextRow(builder, "Name:", Console.CONSTANTS.deploymentNameDescription());
    addHelpTextRow(builder, "Runtime Name:",
            Console.CONSTANTS.deploymentRuntimeNameDescription());
    if (Console.getBootstrapContext().isStandalone()) {
        addHelpTextRow(builder, "Enable:",
                Console.CONSTANTS.deploymentEnabledDescription());
    }
    return builder.toSafeHtml();
}
 
Example 4
Source File: TemplateUploadWizard.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
@Override
  public void render(Context context, TemplateInfo template, SafeHtmlBuilder sb) {
  if (template == null)
    return;
  sb.appendHtmlConstant("<table style='margin: 4pt 0;'>");

  // Add the thumbnail image, if available, or a default image.
  sb.appendHtmlConstant("<tr><td rowspan='3' width=\"32px\">");
  if ( !template.thumbStr.equals("") )   {
    String src = hostUrl + TEMPLATES_ROOT_DIRECTORY +   template.name + "/" + template.thumbStr;
    sb.appendHtmlConstant("<img style='width:32px' src='" + src + "'>");
  } else {
    ImageResource imgResource = Ode.getImageBundle().appInventorLogo();
    Image img = new Image(imgResource);
    String url = img.getUrl();
    sb.appendHtmlConstant("<img style='width:32px' src='" + url + "'>");
  }
  sb.appendHtmlConstant("</td>");

  // Add the name and description.
  sb.appendHtmlConstant("<td style='font-size:95%;'><b>");
  sb.appendEscaped(template.name);
  sb.appendHtmlConstant("</b></td></tr><tr><td>");
  sb.appendEscaped(template.subtitle);
  sb.appendHtmlConstant("</td></tr></table>");
}
 
Example 5
Source File: Header.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private Widget getLinksSection() {
    linksPane = new HTMLPanel(createLinks());
    linksPane.getElement().setId("header-links-section");
    linksPane.getElement().setAttribute("role", "menubar");
    linksPane.getElement().setAttribute("aria-controls", "main-content-area");

    for (final ToplevelTabs.Config tlt : toplevelTabs) {
        final String id = "header-" + tlt.getToken();

        SafeHtmlBuilder html = new SafeHtmlBuilder();
        html.appendHtmlConstant("<div class='header-link-label'>");
        html.appendHtmlConstant("<span role='menuitem'>");
        html.appendHtmlConstant(tlt.getTitle());
        html.appendHtmlConstant("</span>");
        html.appendHtmlConstant("</div>");
        HTML widget = new HTML(html.toSafeHtml());
        widget.setStyleName("fill-layout");

        widget.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                // navigate either child directly or parent if revealed the first time
                /*boolean hasChild = perspectiveStore.hasChild(tlt.getToken());
                String token = hasChild ?
                        perspectiveStore.getChild(tlt.getToken()) : tlt.getToken();
                boolean updateToken = hasChild ? true : tlt.isUpdateToken();*/

                String token = tlt.getToken();
                placeManager.revealPlace(
                        new PlaceRequest.Builder().nameToken(token).build(), tlt.isUpdateToken()
                );
            }
        });
        linksPane.add(widget, id);

    }

    return linksPane;
}
 
Example 6
Source File: LinkBar.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void addLink(String text, ClickHandler handler) {

        InlineLink html = new InlineLink(text);
        //html.setHTML("<a href='javascript:void(0)' tabindex='0'>"+text+"</a>");

        html.addClickHandler(handler);
        html.addStyleName("link-bar");

        SafeHtmlBuilder builder = new SafeHtmlBuilder();

        if(numLinks==0)
        {
            if(!navOnFirstPage)
            {
                html.addStyleName("link-bar-first");
                builder.appendHtmlConstant("<i class='icon-list-ul'></i>");
                builder.appendHtmlConstant("&nbsp;");
            }
        }

        builder.appendHtmlConstant("<a href='javascript:void(0)' tabindex='0'>"+text+"</a>");
        html.setHTML(builder.toSafeHtml());
        links.add(html);

        bar.add(html);

        numLinks++;

    }
 
Example 7
Source File: StaticHelp.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void addHelpTextRow(SafeHtmlBuilder builder, String name, String desc) {
    builder.appendHtmlConstant("<tr class='help-field-row'>");
    builder.appendHtmlConstant("<td class='help-field-name'>");
    builder.appendEscaped(name);
    builder.appendHtmlConstant("</td>");
    builder.appendHtmlConstant("<td class='help-field-desc'>");
    builder.appendEscaped(desc);
    builder.appendHtmlConstant("</td>");
    builder.appendHtmlConstant("</tr>");
}
 
Example 8
Source File: Header.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String createLinks() {

        SafeHtmlBuilder headerString = new SafeHtmlBuilder();

        if (!toplevelTabs.isEmpty()) {
            headerString
                    .appendHtmlConstant("<table border=0 class='header-links' cellpadding=0 cellspacing=0 border=0>");
            headerString.appendHtmlConstant("<tr id='header-links-ref'>");

            headerString.appendHtmlConstant("<td><img src=\"images/blank.png\" width=1/></td>");
            for (ToplevelTabs.Config tlt : toplevelTabs) {
                final String id = "header-" + tlt.getToken();
                String styleClass = "header-link";
                String styleAtt = "vertical-align:middle; text-align:center";

                String td = "<td style='" + styleAtt + "' id='" + id + "' class='" + styleClass + "'></td>";

                headerString.appendHtmlConstant(td);
                //headerString.append(title);

                //headerString.appendHtmlConstant("<td ><img src=\"images/blank.png\" width=1 height=32/></td>");

            }

            headerString.appendHtmlConstant("</tr>");
            headerString.appendHtmlConstant("</table>");
            headerString.appendHtmlConstant("<div id='subnavigation' style='float:right;clear:right;'/>");
        }

        return headerString.toSafeHtml().asString();
    }
 
Example 9
Source File: ParticipantsPanel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void render(Context context, TXParticipant txParticipant, SafeHtmlBuilder html) {
    html.appendHtmlConstant("<ul style='font-size:9px; list-style-type:none'>");
    if(txParticipant.getJndiName()!=null)
        html.appendHtmlConstant("<li>JNDI: ").appendEscaped(txParticipant.getJndiName());

    if(txParticipant.getEisName()!=null)
        html.appendHtmlConstant("<li>EIS: ").appendEscaped(txParticipant.getEisName());

    if(txParticipant.getJmxName()!=null)
        html.appendHtmlConstant("<li>JMX: ").appendEscaped(txParticipant.getJmxName());

    html.appendHtmlConstant("</ul>");
}
 
Example 10
Source File: WebServiceDescriptions.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public static SafeHtml getEndpointDescription()
{
    SafeHtmlBuilder html = new SafeHtmlBuilder();
    html.appendHtmlConstant("<ul>");
    html.appendHtmlConstant("<li>");
    html.appendEscaped("context: Webservice endpoint context.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("class: Webservice implementation class.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("type: Webservice endpoint type.") ;
    html.appendHtmlConstant("<li>");
    html.appendEscaped("wsdl-url:Webservice endpoint WSDL URL.") ;
    html.appendHtmlConstant("</ul>");
    return html.toSafeHtml();
}
 
Example 11
Source File: StaticHelpPanel.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
public StaticHelpPanel(String helpText) {

        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        builder.appendHtmlConstant("<div class='help-attribute-descriptions' style='padding-left:10px;'>");
        builder.appendHtmlConstant(helpText);
        builder.appendHtmlConstant("</div>");
        this.helpText = builder.toSafeHtml();
    }
 
Example 12
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
static SafeHtml principalPreview(final Principal principal, Iterable<Assignment> includes,
        Iterable<Assignment> excludes) {
    SafeHtmlBuilder details = new SafeHtmlBuilder();
    details.appendHtmlConstant("<p>");
    if (!Iterables.isEmpty(excludes)) {
        List<Role> excludedRoles = Roles.orderedByName().immutableSortedCopy(distinctRoles(excludes));
        details.appendEscaped("Excluded from ");
        details.appendEscaped(Joiner.on(", ").join(Lists.transform(excludedRoles, Role::getName)));
        details.appendEscaped(".");
        details.appendHtmlConstant("<br/>");
    }
    if (!Iterables.isEmpty(includes)) {
        List<Role> assignedRoles = Roles.orderedByName().immutableSortedCopy(distinctRoles(includes));
        details.appendEscaped("Assigned to ");
        details.appendEscaped(Joiner.on(", ").join(Lists.transform(assignedRoles, Role::getName)));
        details.appendEscaped(".");
    }
    if (Iterables.isEmpty(excludes) && Iterables.isEmpty(includes)) {
        details.appendEscaped("No roles are assigned to this ");
        details.appendEscaped(principal.getType() == Principal.Type.USER ? "user" : "group");
        details.append('.');
    }
    details.appendHtmlConstant("</p>");
    return principal.getType() == Principal.Type.USER ?
            PREVIEWS.user(principal.getName(), details.toSafeHtml()) :
            PREVIEWS.group(principal.getName(), details.toSafeHtml());
}
 
Example 13
Source File: LayerCatalogDialog.java    From geowe-core with GNU General Public License v3.0 5 votes vote down vote up
private RowExpander<LayerDef> createRowExpander() {
	return new RowExpander<LayerDef>(new AbstractCell<LayerDef>() {
		@Override
		public void render(Context context, LayerDef value,
				SafeHtmlBuilder sb) {
			sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>"
					+ UICatalogMessages.INSTANCE.description() + ":</b> "
					+ value.getDescription() + "</p>");
		}
	});
}
 
Example 14
Source File: MessageCell.java    From core with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void render(
        Context context,
        Message message,
        SafeHtmlBuilder safeHtmlBuilder)
{


    //ImageResource icon = MessageCenterView.getSeverityIcon(message.getSeverity());
    //AbstractImagePrototype prototype = AbstractImagePrototype.create(icon);

    String styles = (context.getIndex() %2 > 0) ? "message-list-item message-list-item-odd" : "message-list-item";
    String rowStyle= message.isNew()  ? "" : "message-list-item-old";
    styles = styles + " list-" +message.getSeverity().getStyle();

    safeHtmlBuilder.appendHtmlConstant("<table width='100%' cellpadding=4 cellspacing=0>");
    safeHtmlBuilder.appendHtmlConstant("<tr valign='middle' class='"+rowStyle+"'>");
    /*safeHtmlBuilder.appendHtmlConstant("<td width='10%'>");
    safeHtmlBuilder.appendHtmlConstant(message.getSeverity().getTag());
    safeHtmlBuilder.appendHtmlConstant("</td>");*/
    safeHtmlBuilder.appendHtmlConstant("<td>");

    safeHtmlBuilder.appendHtmlConstant("<div class='"+styles+"'>");
    String actualMessage = message.getConciseMessage().length()>30 ? message.getConciseMessage().substring(0, 30)+" ..." : message.getConciseMessage();

    //safeHtmlBuilder.appendHtmlConstant(TEMPLATE.message(styles, actualMessage));
    safeHtmlBuilder.appendEscaped(actualMessage);
    safeHtmlBuilder.appendHtmlConstant("</div>");


    safeHtmlBuilder.appendHtmlConstant("</td></tr></table>");

}
 
Example 15
Source File: StackedBar.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Widget asWidget() {

        SafeHtmlBuilder builder = new SafeHtmlBuilder();

        builder.appendHtmlConstant("<div id='"+ outerId +"'><div id='"+innerId+"'/></div>");

        panel = new HTMLPanel(builder.toSafeHtml());

        Element outerElement = panel.getElementById(outerId);
        outerElement.addClassName("stacked-bar-total");
        outerElement.setAttribute("style", "width:100%");
        outerElement.setAttribute("cssText", "width:100%!important");


        Element innerElement = panel.getElementById(innerId);
        innerElement.addClassName("stacked-bar-actual");
        innerElement.setInnerText(label);

        return panel;
    }
 
Example 16
Source File: JndiTreeParser.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void render(Context context, JndiEntry value, SafeHtmlBuilder sb) {

    if (value instanceof AttributeEntry) {
        //print information about the binding
        AttributeEntry attributeEntry = (AttributeEntry) value;

        sb.appendHtmlConstant("<table width='100%' border=0>");

            //uri
            sb.appendHtmlConstant("<tr>");
                sb.appendHtmlConstant("<td width='60%'>");
                    sb.appendHtmlConstant("<b>");
                        sb.appendEscaped(Console.CONSTANTS.subsys_naming_URI());
                    sb.appendHtmlConstant("</b>");
                sb.appendHtmlConstant("</td>");

                sb.appendHtmlConstant("<td width='40%'>");
                    sb.appendEscaped(attributeEntry.getParentUri());
                sb.appendHtmlConstant("</td>");

            sb.appendHtmlConstant("</tr>");

            //type
            sb.appendHtmlConstant("<tr>");
                sb.appendHtmlConstant("<td width='60%'>");
                    sb.appendHtmlConstant("<b>");
                        sb.appendEscaped(Console.CONSTANTS.subsys_naming_type());
                    sb.appendHtmlConstant("</b>");
                sb.appendHtmlConstant("</td>");

                sb.appendHtmlConstant("<td width='40%'>");
                    sb.appendEscaped(attributeEntry.getParentDataType());
                sb.appendHtmlConstant("</td>");

            sb.appendHtmlConstant("</tr>");

            //value
            sb.appendHtmlConstant("<tr>");
                sb.appendHtmlConstant("<td width='60%'>");
                    sb.appendHtmlConstant("<b>");
                        sb.appendEscaped(Console.CONSTANTS.subsys_naming_value());
                    sb.appendHtmlConstant("</b>");
                sb.appendHtmlConstant("</td>");

                sb.appendHtmlConstant("<td width='40%'>");
                    sb.appendEscaped(attributeEntry.getParentValue());
                sb.appendHtmlConstant("</td>");

            sb.appendHtmlConstant("</tr>");
        sb.appendHtmlConstant("</table>");
    } else {

        sb.appendHtmlConstant("<table width='100%' border=0>");
        sb.appendHtmlConstant("<tr>");

            sb.appendHtmlConstant("<td width='100%'>");
            sb.appendEscaped(value.getName());
            sb.appendHtmlConstant("</td>");

        sb.appendHtmlConstant("</tr>");
        sb.appendHtmlConstant("</table>");
    }
}
 
Example 17
Source File: PreviewState.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void error(SafeHtmlBuilder html, String title) {
    html.appendHtmlConstant("<p/><span style='padding-left:12px' class='error-color'>&nbsp;</span>&nbsp;");
    html.appendEscaped(title).appendHtmlConstant("<p/>");
}
 
Example 18
Source File: PreviewState.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void info(SafeHtmlBuilder html, String title) {
    html.appendHtmlConstant("<p/><span style='padding-left:12px' class='info-color'>&nbsp;</span>&nbsp;");
    html.appendEscaped(title).appendHtmlConstant("<p/>");
}
 
Example 19
Source File: PreviewState.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static void paused(SafeHtmlBuilder html, String title) {
    html.appendHtmlConstant("<p/><span style='padding-left:12px' class='paused-color'>&nbsp;</span>&nbsp;");
    html.appendEscaped(title).appendHtmlConstant("<p/>");
}
 
Example 20
Source File: Templates.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
static SafeHtml deploymentPreview(final Deployment deployment) {
    SafeHtmlBuilder enabledDisabledBuilder = new SafeHtmlBuilder();
    if (deployment.isEnabled()) {
        PreviewState.good(enabledDisabledBuilder, "Deployment is enabled");
    } else {
        PreviewState.paused(enabledDisabledBuilder, "Deployment is disabled");
    }

    SafeHtmlBuilder details = new SafeHtmlBuilder();
    details.appendHtmlConstant("<h3>").appendEscaped("Overview").appendHtmlConstant("</h3>")
            .appendHtmlConstant("<ul>");
    if (deployment.getEnabledTime() != null) {
        details.appendHtmlConstant("<li class='deployment-timestamp'>").appendEscaped("Last enabled at ")
                .appendEscaped(deployment.getEnabledTime());
    } else {
        details.appendHtmlConstant("<li>").appendEscaped("The deployment was never enabled");
    }
    
    // print if managed yes/no
    if (deployment.isManaged()) {
        details.appendHtmlConstant("<li>Managed: Yes");
    } else {
        details.appendHtmlConstant("<li>Managed: No");
    }

    // print if archive yes/no
    if (deployment.isArchive()) {
        details.appendHtmlConstant("<li>Archive: Yes");
    } else {
        details.appendHtmlConstant("<li>Archive: No");
    }
    
    if (deployment.getDisabledTime() != null) {
        details.appendHtmlConstant("<li class='deployment-timestamp'>").appendEscaped("Last disabled at ")
                .appendEscaped(deployment.getDisabledTime());
    } else {
        details.appendHtmlConstant("<li>").appendEscaped("The deployment was never disabled");
    }
    details.appendHtmlConstant("<li>").appendEscaped("Runtime name: ")
            .appendEscaped(deployment.getRuntimeName());
    details.appendHtmlConstant("</ul>");

    if (deployment.hasSubdeployments()) {
        details.appendHtmlConstant("<h3>").appendEscaped("Nested Deployments").appendHtmlConstant("</h3>")
                .appendHtmlConstant("<p>")
                .appendEscaped("The deployment contains ")
                .appendEscaped(String.valueOf(deployment.getSubdeployments().size()))
                .appendEscaped(" nested deployments")
                .appendHtmlConstant("</p>");

    }

    return deployment.getReferenceServer().isStandalone() ?
            PREVIEWS.standaloneDeployment(deployment.getName(), enabledDisabledBuilder.toSafeHtml(),
                    details.toSafeHtml()) :
            PREVIEWS.domainDeployment(deployment.getName(), deployment.getReferenceServer().getHost(),
                    deployment.getReferenceServer().getServer(), enabledDisabledBuilder.toSafeHtml(),
                    details.toSafeHtml());
}