List of usage examples for com.google.gwt.safehtml.shared SafeHtmlUtils htmlEscapeAllowEntities
public static String htmlEscapeAllowEntities(String text)
From source file:org.jboss.hal.client.deployment.BrowseContentElement.java
License:Apache License
private Completable browseContent() { ResourceAddress address = new ResourceAddress().add(DEPLOYMENT, content.getName()); Operation operation = new Operation.Builder(address, BROWSE_CONTENT).build(); return dispatcher.execute(operation).doOnSuccess(result -> { String contentName = SafeHtmlUtils.htmlEscapeAllowEntities(content.getName()); Node<ContentEntry> root = new Node.Builder<>(Ids.CONTENT_TREE_ROOT, contentName, new ContentEntry()) .root().folder().open().build(); JsArray<Node<ContentEntry>> nodes = new JsArray<>(); new ContentParser().parse(root, nodes, result.isDefined() ? result.asList() : emptyList()); if (tree != null) { tree.destroy();//from w w w .j a va 2 s .c om tree = null; } tree = new Tree<>(Ids.CONTENT_TREE, nodes); Elements.removeChildrenFrom(treeContainer); treeContainer.appendChild(tree.element()); tree.attach(); tree.onSelectionChange((event, selectionContext) -> { if (!"ready".equals(selectionContext.action)) { //NON-NLS onNodeSelected(selectionContext); } }); }).toCompletable(); }
From source file:org.jboss.hal.core.modelbrowser.ModelBrowser.java
License:Apache License
/** * Entry point to show the specified address. * * @param root the root address for this model browser * @param updateBreadcrumb {@code true} if this model browser should fire {@link ModelBrowserPathEvent}s *//*from ww w. j ava 2 s.c om*/ public void setRoot(ResourceAddress root, boolean updateBreadcrumb) { this.updateBreadcrumb = updateBreadcrumb; String resource = root.equals(ResourceAddress.root()) ? Names.MANAGEMENT_MODEL : SafeHtmlUtils.htmlEscapeAllowEntities(root.lastValue()); if ("*".equals(resource)) { throw new IllegalArgumentException("Invalid root address: " + root + ". ModelBrowser.setRoot() must be called with a concrete address."); } // TODO Removing a filter in a scoped model browser does not work Elements.setVisible(filter, root.equals(ResourceAddress.root())); Operation ping = new Operation.Builder(root, READ_RESOURCE_OPERATION).build(); dispatcher.execute(ping, result -> { initTree(root, resource); tree.openNode(MODEL_BROWSER_ROOT, () -> resourcePanel.tabs.showTab(0)); tree.selectNode(MODEL_BROWSER_ROOT); adjustHeight(); }, (operation, failure) -> { emptyTree(); MessageEvent.fire(eventBus, Message.error(resources.messages().unknownResource(), resources.messages().unknownResourceDetails(root.toString(), failure))); adjustHeight(); }, (operation, exception) -> { emptyTree(); MessageEvent.fire(eventBus, Message.error(resources.messages().unknownResource(), resources.messages().unknownResourceDetails(root.toString(), exception.getMessage()))); adjustHeight(); }); }
From source file:org.rstudio.studio.client.common.rstudioapi.DialogHtmlSanitizer.java
License:Open Source License
private static String dialogSanitize(String text) { StringBuilder sanitized = new StringBuilder(); boolean firstSegment = true; for (String segment : text.split("<", -1)) { if (firstSegment) { firstSegment = false;/* w w w . j a v a 2 s. com*/ sanitized.append(SafeHtmlUtils.htmlEscapeAllowEntities(segment)); continue; } int tagStart = 0; int tagEnd = segment.indexOf('>'); String tag = null; boolean isValidTag = false; if (tagEnd > 0) { if (segment.charAt(0) == '/') { tagStart = 1; } tag = segment.substring(tagStart, tagEnd).toLowerCase(); if (TAG_WHITELIST.contains(tag)) { isValidTag = true; } } if (isValidTag) { if (tagStart == 0) { sanitized.append('<'); } else { sanitized.append("</"); } sanitized.append(tag).append('>'); sanitized.append(SafeHtmlUtils.htmlEscapeAllowEntities(segment.substring(tagEnd + 1))); } else { sanitized.append("<").append(SafeHtmlUtils.htmlEscapeAllowEntities(segment)); } } return sanitized.toString(); }