List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant
public SafeHtmlBuilder appendHtmlConstant(String html)
From source file:org.zanata.webtrans.client.ui.SearchResultsDocumentTable.java
License:Open Source License
/** * @return a column that displays the source contents for the text flow *//*from ww w . j a v a2 s. c o m*/ private static Column<TransUnitReplaceInfo, List<String>> buildSourceColumn() { return new Column<TransUnitReplaceInfo, List<String>>(new AbstractCell<List<String>>() { @Override public void render(Context context, List<String> contents, SafeHtmlBuilder sb) { Iterable<String> notEmptyContents = Iterables.filter(contents, StringNotEmptyPredicate.INSTANCE); SafeHtml safeHtml = TextContentsDisplay .asSyntaxHighlightAndSearch(notEmptyContents, highlightString).toSafeHtml(); sb.appendHtmlConstant(safeHtml.asString()); } }) { @Override public List<String> getValue(TransUnitReplaceInfo info) { return info.getTransUnit().getSources(); } }; }
From source file:org.zanata.webtrans.client.ui.SearchResultsDocumentTable.java
License:Open Source License
/** * @return a column that displays the target contents for the text flow *//* w w w. ja va2 s . co m*/ private static Column<TransUnitReplaceInfo, TransUnitReplaceInfo> buildTargetColumn() { return new Column<TransUnitReplaceInfo, TransUnitReplaceInfo>(new AbstractCell<TransUnitReplaceInfo>() { @Override public void render(Context context, TransUnitReplaceInfo info, SafeHtmlBuilder sb) { List<String> contents = info.getTransUnit().getTargets(); if (info.getPreviewState() == PreviewState.Show) { SafeHtml safeHtml = TextContentsDisplay.asDiff(contents, info.getPreview().getContents()) .toSafeHtml(); sb.appendHtmlConstant(safeHtml.asString()); } else { SafeHtml safeHtml = TextContentsDisplay.asSyntaxHighlightAndSearch(contents, highlightString) .toSafeHtml(); sb.appendHtmlConstant(safeHtml.asString()); } } }) { @Override public TransUnitReplaceInfo getValue(TransUnitReplaceInfo info) { return info; } @Override public String getCellStyleNames(Context context, TransUnitReplaceInfo info) { String styleNames = Strings.nullToEmpty(super.getCellStyleNames(context, info)); return ContentStateToStyleUtil.stateToStyle(info.getTransUnit().getStatus(), styleNames); } }; }
From source file:org.zanata.webtrans.client.ui.SearchResultsDocumentTable.java
License:Open Source License
private static SafeHtml buildButtonHtml(String message, String buttonLabel, String title, boolean enabled) { SafeHtmlBuilder sb = new SafeHtmlBuilder().appendHtmlConstant(message) .appendHtmlConstant("<button type=\"button\" tabindex=\"-1\""); if (!enabled) { sb.appendHtmlConstant(" title=\"").appendEscaped(title).appendHtmlConstant("\" disabled=\"disabled\""); }//ww w . j a v a 2 s .co m return sb.appendHtmlConstant(">").appendEscaped(buttonLabel).appendHtmlConstant("</button>").toSafeHtml(); }
From source file:py.edu.uca.intercajas.client.menumail.Mailboxes.java
License:Apache License
/** * Generates HTML for a tree item with an attached icon. * //from ww w .j ava2 s. c om * @param imageProto the image prototype to use * @param title the title of the item * @return the resultant HTML */ private SafeHtml imageItemHTML(ImageResource imageProto, String title) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(AbstractImagePrototype.create(imageProto).getSafeHtml()); builder.appendHtmlConstant(" "); builder.appendEscaped(title); return builder.toSafeHtml(); }
From source file:ru.ppsrk.gwt.client.ComboCell.java
License:Apache License
@Override public void render(Context context, ComboItem value, SafeHtmlBuilder sb) { // Get the view data. Object key = context.getKey(); ComboItem viewData = getViewData(key); if (viewData != null && viewData.equals(value)) { clearViewData(key);/*from www . j a va2 s . c o m*/ viewData = null; } int selectedIndex = getSelectedIndex(viewData == null ? value : viewData); sb.appendHtmlConstant("<select tabindex=\"-1\">"); int index = 0; for (ComboItem option : options) { if (index++ == selectedIndex) { sb.append(template.selected(option.getId(), option.getListboxValue())); } else { sb.append(template.deselected(option.getId(), option.getListboxValue())); } } sb.appendHtmlConstant("</select>"); }
From source file:ru.ppsrk.gwt.client.DynamicSelectionCell.java
License:Apache License
@Override public void render(Context context, Pair<Long, String> value, SafeHtmlBuilder sb) { // Get the view data. Object key = context.getKey(); Pair<Long, String> viewData = getViewData(key); if (viewData != null && viewData.equals(value)) { clearViewData(key);// ww w. j a v a 2s . co m viewData = null; } int selectedIndex = getSelectedIndex(viewData == null ? value : viewData); sb.appendHtmlConstant("<select tabindex=\"-1\">"); int index = 0; for (Pair<Long, String> option : options) { if (index++ == selectedIndex) { sb.append(template.selected(option.getLeft(), option.getRight())); } else { sb.append(template.deselected(option.getLeft(), option.getRight())); } } sb.appendHtmlConstant("</select>"); }
From source file:strat.mining.multipool.stats.client.component.cell.BooleanImageCell.java
License:Open Source License
@Override public void render(com.google.gwt.cell.client.Cell.Context context, Boolean value, SafeHtmlBuilder sb) { String html = "<div style=\"text-align: center;\" >"; if (value) {/*w w w . j ava 2 s . c om*/ if (trueImage != null) { html += renderer.render(trueImage).asString(); } } else { if (falseImage != null) { html += renderer.render(falseImage).asString(); } } html += "</div>"; sb.appendHtmlConstant(html); }
From source file:strat.mining.multipool.stats.client.component.cell.HashrateCell.java
License:Open Source License
@Override public void render(com.google.gwt.cell.client.Cell.Context context, Float value, SafeHtmlBuilder sb) { if (threshold != null && value < threshold) { sb.appendHtmlConstant("<span style=\"color: red;\">" + numberFormat.format(value) + "</span>"); } else {// w w w .jav a2 s . c om sb.appendEscaped(numberFormat.format(value)); } }
From source file:strat.mining.multipool.stats.client.component.cell.StalerateCell.java
License:Open Source License
@Override public void render(com.google.gwt.cell.client.Cell.Context context, Float value, SafeHtmlBuilder sb) { if (threshold != null && value > threshold) { sb.appendHtmlConstant("<span style=\"color: red;\">" + numberFormat.format(value) + " %</span>"); } else {// w ww . ja v a 2s . c o m sb.appendEscaped(numberFormat.format(value == null ? 0 : value) + " %"); } }
From source file:stroom.alert.client.view.CommonAlertViewImpl.java
License:Apache License
@Override public void setDetail(final SafeHtml html) { if (html != null && html.asString().length() > 0) { final SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.appendHtmlConstant( "<div style=\"font-family: Courier New; font-size: 10px; white-space: pre;\">"); builder.append(html);/*from ww w . jav a 2s . c om*/ builder.appendHtmlConstant("</div>"); detail.setHTML(builder.toSafeHtml()); showDetail(false); } else { showHideDetail.setVisible(false); setDetailVisible(false); } }