List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder SafeHtmlBuilder
public SafeHtmlBuilder()
From source file:org.eclipse.che.ide.extension.builder.client.console.BuilderConsoleViewImpl.java
License:Open Source License
/** * Return sanitized message (with all restricted HTML-tags escaped) in SafeHtml. * * @param type//w ww .jav a2 s. c o m * message type (info, error etc.) * @param color * color constant * @param message * message to print * @return message in SafeHtml */ private SafeHtml buildSafeHtmlMessage(String type, String color, String message) { return new SafeHtmlBuilder().appendHtmlConstant("<pre " + PRE_STYLE + ">") .appendHtmlConstant("[<span style='color:" + color + ";'><b>" + type + "</b></span>]") .append(SimpleHtmlSanitizer.sanitizeHtml(message.substring(("[" + type + "]").length()))) .appendHtmlConstant("</pre>").toSafeHtml(); }
From source file:org.eclipse.che.ide.extension.builder.client.console.BuilderConsoleViewImpl.java
License:Open Source License
/** * Returns partially sanitized message. The method allows to place html inside the message. * * @param type/*www. j a va2s. co m*/ * message type (info, error etc.) * @param color * color constant * @param message * message to print * @return message in SafeHtml */ private SafeHtml buildHtmlMessage(String type, String color, String message) { return new SafeHtmlBuilder().appendHtmlConstant("<pre " + PRE_STYLE + ">") .appendHtmlConstant("[<span style='color:" + color + ";'><b>" + type + "</b></span>]") .appendHtmlConstant(message.substring(("[" + type + "]").length())).appendHtmlConstant("</pre>") .toSafeHtml(); }
From source file:org.eclipse.che.ide.extension.builder.client.console.BuilderConsoleViewImpl.java
License:Open Source License
/** * Return sanitized message (with all restricted HTML-tags escaped) in SafeHtml * * @param message/*from www . j a v a 2 s .c om*/ * message to print * @return message in SafeHtml */ private SafeHtml buildSafeHtmlMessage(String message) { return new SafeHtmlBuilder().appendHtmlConstant("<pre " + PRE_STYLE + ">") .append(SimpleHtmlSanitizer.sanitizeHtml(message)).appendHtmlConstant("</pre>").toSafeHtml(); }
From source file:org.eclipse.che.ide.processes.runtime.CellTableRuntimeInfoWidgetFactory.java
License:Open Source License
private Widget createCellTable(ListDataProvider<RuntimeInfo> dataProvider) { CellTable<RuntimeInfo> table = new CellTable<>(100, resources); table.ensureDebugId("runtimeInfoCellTable"); TextColumn<RuntimeInfo> referenceColumn = new TextColumn<RuntimeInfo>() { @Override/*from w ww . j a v a 2 s . c om*/ public String getValue(RuntimeInfo record) { return valueOrDefault(record.getReference()); } @Override public void render(Context context, RuntimeInfo object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "runtime-info-reference-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; TextColumn<RuntimeInfo> portColumn = new TextColumn<RuntimeInfo>() { @Override public String getValue(RuntimeInfo record) { return valueOrDefault(record.getPort()); } @Override public void render(Context context, RuntimeInfo object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "runtime-info-port-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; TextColumn<RuntimeInfo> protocolColumn = new TextColumn<RuntimeInfo>() { @Override public String getValue(RuntimeInfo record) { return valueOrDefault(record.getProtocol()); } @Override public void render(Context context, RuntimeInfo object, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "runtime-info-protocol-" + context.getIndex() + "\">"); super.render(context, object, sb); } }; Column<RuntimeInfo, SafeHtml> urlColumn = new Column<RuntimeInfo, SafeHtml>( new AbstractCell<SafeHtml>("click", "keydown") { @Override public void render(Context context, SafeHtml value, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div id=\"" + UIObject.DEBUG_ID_PREFIX + "runtime-info-url-" + context.getIndex() + "\">"); if (value != null) { sb.append(value); } } @Override protected void onEnterKeyDown(Context context, Element parent, SafeHtml value, NativeEvent event, ValueUpdater<SafeHtml> valueUpdater) { if (valueUpdater != null) { valueUpdater.update(value); } } @Override public void onBrowserEvent(Context context, Element parent, SafeHtml value, NativeEvent event, ValueUpdater<SafeHtml> valueUpdater) { super.onBrowserEvent(context, parent, value, event, valueUpdater); if ("click".equals(event.getType())) { onEnterKeyDown(context, parent, value, event, valueUpdater); } } }) { @Override public SafeHtml getValue(RuntimeInfo record) { String value = valueOrDefault(record.getUrl()); SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<a target=\"_blank\" href=\"" + value + "\">"); sb.appendEscaped(value); sb.appendHtmlConstant("</a>"); return sb.toSafeHtml(); } }; table.addColumn(referenceColumn, locale.cellTableReferenceColumn()); table.addColumn(portColumn, locale.cellTablePortColumn()); table.addColumn(protocolColumn, locale.cellTableProtocolColumn()); table.addColumn(urlColumn, locale.cellTableUrlColumn()); table.setColumnWidth(referenceColumn, 15., Unit.PCT); table.setColumnWidth(portColumn, 7., Unit.PCT); table.setColumnWidth(protocolColumn, 7., Unit.PCT); table.setColumnWidth(urlColumn, 71., Unit.PCT); dataProvider.addDataDisplay(table); return table; }
From source file:org.eclipse.che.plugin.debugger.ide.debug.BreakpointItemRender.java
License:Open Source License
@Override public void render(Element itemElement, Breakpoint itemData) { TableCellElement label = Elements.createTDElement(); SafeHtmlBuilder sb = new SafeHtmlBuilder(); // Add icon/* w w w . j a v a 2s.c om*/ sb.appendHtmlConstant("<table><tr><td>"); SVGResource icon = debuggerResources.breakpoint(); if (icon != null) { sb.appendHtmlConstant("<img src=\"" + icon.getSafeUri().asString() + "\">"); } sb.appendHtmlConstant("</td>"); // Add title sb.appendHtmlConstant("<td>"); String path = itemData.getLocation().getTarget(); sb.appendEscaped(path.substring(path.lastIndexOf("/") + 1) + ":" + String.valueOf(itemData.getLocation().getLineNumber())); sb.appendHtmlConstant("</td></tr></table>"); label.setInnerHTML(sb.toSafeHtml().asString()); itemElement.appendChild(label); }
From source file:org.eclipse.che.plugin.debugger.ide.debug.DebuggerViewImpl.java
License:Open Source License
@Inject protected DebuggerViewImpl(PartStackUIResources partStackUIResources, DebuggerResources resources, DebuggerLocalizationConstant locale, Resources coreRes, VariableTreeNodeRenderer.Resources rendererResources, DebuggerViewImplUiBinder uiBinder) { super(partStackUIResources); this.locale = locale; this.res = resources; this.coreRes = coreRes; setContentWidget(uiBinder.createAndBindUi(this)); TableElement breakPointsElement = Elements.createTableElement(); breakPointsElement.setAttribute("style", "width: 100%"); SimpleList.ListEventDelegate<Breakpoint> breakpointListEventDelegate = new SimpleList.ListEventDelegate<Breakpoint>() { public void onListItemClicked(Element itemElement, Breakpoint itemData) { breakpoints.getSelectionModel().setSelectedItem(itemData); }/*from w ww . j av a2s.co m*/ public void onListItemDoubleClicked(Element listItemBase, Breakpoint itemData) { // TODO: implement 'go to breakpoint source' feature } }; SimpleList.ListItemRenderer<Breakpoint> breakpointListItemRenderer = new SimpleList.ListItemRenderer<Breakpoint>() { @Override public void render(Element itemElement, Breakpoint itemData) { TableCellElement label = Elements.createTDElement(); SafeHtmlBuilder sb = new SafeHtmlBuilder(); // Add icon sb.appendHtmlConstant("<table><tr><td>"); SVGResource icon = res.breakpoint(); if (icon != null) { sb.appendHtmlConstant("<img src=\"" + icon.getSafeUri().asString() + "\">"); } sb.appendHtmlConstant("</td>"); // Add title sb.appendHtmlConstant("<td>"); String path = itemData.getPath(); sb.appendEscaped(path.substring(path.lastIndexOf("/") + 1) + " - [line: " + String.valueOf(itemData.getLineNumber() + 1) + "]"); sb.appendHtmlConstant("</td></tr></table>"); label.setInnerHTML(sb.toSafeHtml().asString()); itemElement.appendChild(label); } @Override public Element createElement() { return Elements.createTRElement(); } }; breakpoints = SimpleList.create((SimpleList.View) breakPointsElement, coreRes.defaultSimpleListCss(), breakpointListItemRenderer, breakpointListEventDelegate); this.breakpointsPanel.add(breakpoints); this.variables = Tree.create(rendererResources, new VariableNodeDataAdapter(), new VariableTreeNodeRenderer(rendererResources)); this.variables.setTreeEventHandler(new Tree.Listener<MutableVariable>() { @Override public void onNodeAction(@NotNull TreeNodeElement<MutableVariable> node) { } @Override public void onNodeClosed(@NotNull TreeNodeElement<MutableVariable> node) { selectedVariable = null; } @Override public void onNodeContextMenu(int mouseX, int mouseY, @NotNull TreeNodeElement<MutableVariable> node) { } @Override public void onNodeDragStart(@NotNull TreeNodeElement<MutableVariable> node, @NotNull MouseEvent event) { } @Override public void onNodeDragDrop(@NotNull TreeNodeElement<MutableVariable> node, @NotNull MouseEvent event) { } @Override public void onNodeExpanded(@NotNull final TreeNodeElement<MutableVariable> node) { selectedVariable = node; delegate.onSelectedVariableElement(selectedVariable.getData()); delegate.onExpandVariablesTree(); } @Override public void onNodeSelected(@NotNull TreeNodeElement<MutableVariable> node, @NotNull SignalEvent event) { selectedVariable = node; delegate.onSelectedVariableElement(selectedVariable.getData()); } @Override public void onRootContextMenu(int mouseX, int mouseY) { } @Override public void onRootDragDrop(@NotNull MouseEvent event) { } @Override public void onKeyboard(@NotNull KeyboardEvent event) { } }); this.variablesPanel.add(variables); minimizeButton.ensureDebugId("debugger-minimizeBut"); }
From source file:org.eclipse.che.plugin.debugger.ide.debug.FrameItemRender.java
License:Open Source License
@Override public void render(Element itemElement, StackFrameDump itemData) { TableCellElement label = Elements.createTDElement(); SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendEscaped(itemData.getLocation().getMethod().getName()); sb.appendEscaped("("); List<? extends Variable> arguments = itemData.getLocation().getMethod().getArguments(); for (int i = 0; i < arguments.size(); i++) { String type = arguments.get(i).getType(); sb.appendEscaped(type.substring(type.lastIndexOf(".") + 1)); if (i != arguments.size() - 1) { sb.appendEscaped(", "); }//w w w .ja v a2 s. c om } sb.appendEscaped("):"); sb.append(itemData.getLocation().getLineNumber()); sb.appendEscaped(", "); Path path = Path.valueOf(itemData.getLocation().getTarget()); String className; if (path.isAbsolute()) { className = path.removeFileExtension().lastSegment(); } else { className = path.lastSegment(); } sb.appendEscaped(className); label.setInnerHTML(sb.toSafeHtml().asString()); itemElement.appendChild(label); }
From source file:org.eclipse.che.plugin.languageserver.ide.editor.codeassist.CompletionItemBasedCompletionProposal.java
License:Open Source License
@Override public String getDisplayString() { SafeHtmlBuilder builder = new SafeHtmlBuilder(); String label = completionItem.getLabel(); int pos = 0;/*from w w w . j a v a 2s.c o m*/ for (Match highlight : highlights) { if (highlight.getStart() == highlight.getEnd()) { continue; } if (pos < highlight.getStart()) { appendPlain(builder, label.substring(pos, highlight.getStart())); } appendHighlighted(builder, label.substring(highlight.getStart(), highlight.getEnd())); pos = highlight.getEnd(); } if (pos < label.length()) { appendPlain(builder, label.substring(pos)); } if (completionItem.getDetail() != null) { appendDetail(builder, completionItem.getDetail()); } return builder.toSafeHtml().asString(); }
From source file:org.eclipse.che.plugin.svn.ide.commit.diff.DiffViewerViewImpl.java
License:Open Source License
private String colorizeDiff(String origin) { StringBuilder html = new StringBuilder(); html.append("<pre>"); for (String line : Splitter.on("\n").splitToList(origin)) { final String prefix = line.substring(0, 1); final String sanitizedLine = new SafeHtmlBuilder().appendEscaped(line).toSafeHtml().asString(); html.append("<span style=\"color:") .append(lineRules.containsKey(prefix) ? lineRules.get(prefix) : lineRules.get("default")) .append(";\">").append(sanitizedLine).append("</span>").append("\n"); }// w ww .j a v a2 s. co m html.append("</pre>"); return html.toString(); }
From source file:org.eclipse.kura.web.client.ui.Device.CommandTabUi.java
License:Open Source License
public void display(String string) { this.resultPanel.clear(); this.resultPanel.add(new HTML(new SafeHtmlBuilder().appendEscapedLines(string).toSafeHtml())); }