Java Code Examples for com.google.gwt.safehtml.shared.SafeHtmlBuilder#appendEscaped()
The following examples show how to use
com.google.gwt.safehtml.shared.SafeHtmlBuilder#appendEscaped() .
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: TemplateUploadWizard.java From appinventor-extensions with Apache License 2.0 | 6 votes |
@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 2
Source File: Templates.java From core with GNU Lesser General Public License v2.1 | 6 votes |
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: ModelBrowserView.java From core with GNU Lesser General Public License v2.1 | 6 votes |
private void addChildrenTypes(ModelTreeItem rootItem, List<ModelNode> modelNodes) { rootItem.removeItems(); final ChildInformation childInformation = parseChildrenTypes(modelNodes); for(String child : childInformation.getNames()) { final ModelNode address = getNodeAddress(rootItem, child); SafeHtmlBuilder html = new SafeHtmlBuilder(); html.appendHtmlConstant("<i class='icon-folder-close-alt'></i> "); html.appendEscaped(child); TreeItem childItem = new ModelTreeItem(html.toSafeHtml(), child, address, childInformation.isSingleton(child)); childItem.addItem(new PlaceholderItem()); rootItem.addItem(childItem); rootItem.updateChildInfo(childInformation); } rootItem.setState(true); }
Example 4
Source File: Templates.java From core with GNU Lesser General Public License v2.1 | 5 votes |
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 5
Source File: WebServiceDescriptions.java From core with GNU Lesser General Public License v2.1 | 5 votes |
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 6
Source File: StaticHelp.java From core with GNU Lesser General Public License v2.1 | 5 votes |
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 7
Source File: MessageCell.java From core with GNU Lesser General Public License v2.1 | 5 votes |
@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 8
Source File: JndiTreeParser.java From core with GNU Lesser General Public License v2.1 | 4 votes |
@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 9
Source File: RBACUtil.java From core with GNU Lesser General Public License v2.1 | 4 votes |
private static void dumpPermissions(SafeHtmlBuilder html, SecurityContextImpl securityContext) { for(AddressTemplate resource : securityContext.requiredResources) { html.appendHtmlConstant("<h3>").appendEscaped(resource.toString()).appendHtmlConstant("</h3>"); html.appendHtmlConstant("<hr noshade/>"); Constraints constraints = securityContext.getActiveConstraints(resource); // default constraints html.appendHtmlConstant("<ul>"); html.appendHtmlConstant("<li>").appendEscaped("read-config:"+constraints.isReadResource()).appendHtmlConstant("</li>"); html.appendHtmlConstant("<li>").appendEscaped("write-config:"+constraints.isWriteResource()).appendHtmlConstant("</li>"); html.appendHtmlConstant("</ul>"); html.appendHtmlConstant("<p/>"); html.appendHtmlConstant("<h4>Attributes</h4>"); html.appendHtmlConstant("<table border='0' cellpadding='5'>"); html.appendHtmlConstant("<tr>"); html.appendHtmlConstant("<th>"); html.appendEscaped("Attribute Name"); html.appendHtmlConstant("</th>"); html.appendHtmlConstant("<th>"); html.appendEscaped("Read"); html.appendHtmlConstant("</th>"); html.appendHtmlConstant("<th>"); html.appendEscaped("Write"); html.appendHtmlConstant("</th>"); html.appendHtmlConstant("</tr>"); for(String att : constraints.attributePermissions.keySet()) { html.appendHtmlConstant("<tr>"); html.appendHtmlConstant("<td>"); html.appendEscaped(att); html.appendHtmlConstant("</td>"); html.appendHtmlConstant("<td>"); Constraints.AttributePerm attributePerm = constraints.attributePermissions.get(att); html.appendEscaped(String.valueOf(attributePerm.isRead())); html.appendHtmlConstant("</td>"); html.appendHtmlConstant("<td>"); html.appendEscaped(String.valueOf(attributePerm.isWrite())); html.appendHtmlConstant("</td>"); html.appendHtmlConstant("</tr>"); } html.appendHtmlConstant("</table>"); html.appendHtmlConstant("<p/>"); html.appendHtmlConstant("<h4>Operations</h4>"); html.appendHtmlConstant("<table border='0' cellpadding='5'>"); html.appendHtmlConstant("<tr>"); html.appendHtmlConstant("<th>"); html.appendEscaped("Operation Name"); html.appendHtmlConstant("</th>"); html.appendHtmlConstant("<th>"); html.appendEscaped("Exec"); html.appendHtmlConstant("</th>"); html.appendHtmlConstant("</tr>"); if(!constraints.execPermission.isEmpty()) { for(String op : constraints.execPermission) { html.appendHtmlConstant("<tr>"); html.appendHtmlConstant("<td>"); html.appendEscaped(op); html.appendHtmlConstant("</td>"); html.appendHtmlConstant("<td>"); html.appendEscaped("true"); html.appendHtmlConstant("</td>"); html.appendHtmlConstant("</tr>"); } } html.appendHtmlConstant("</table>"); } }