List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendHtmlConstant
public SafeHtmlBuilder appendHtmlConstant(String html)
From source file:com.dianaui.universal.core.client.ui.ButtonCell.java
License:Apache License
@Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<button type=\"button\" class=\"btn " + (type != null ? type.getCssName() : "") + (size != null ? " " + size.getCssName() : "") + "\" tabindex=\"-1\">"); if (data != null) { String iconHtml = ""; if (fontAwesomeIcon != null || glyphicon != null) { String iconClasses = fontAwesomeIcon != null ? Styles.FONT_AWESOME_BASE + " " + fontAwesomeIcon.getCssName() : Styles.GLYPHICON_BASE + " " + glyphicon.getCssName(); if (fontAwesomeIcon != null) { if (iconSize != null) iconClasses += iconSize.getCssName() + " "; if (iconFlip != null) iconClasses += iconFlip.getCssName() + " "; if (iconRotate != null) iconClasses += iconRotate.getCssName() + " "; if (iconBordered) iconClasses += Styles.ICON_BORDER + " "; if (iconMuted) iconClasses += Styles.ICON_MUTED + " "; if (iconLight) iconClasses += Styles.ICON_LIGHT + " "; if (iconSpin) iconClasses += Styles.ICON_SPIN + " "; if (iconFixedWidth) iconClasses += Styles.ICON_FIXED_WIDTH; }/*from ww w .j a va 2 s .c o m*/ iconHtml = "<i class=\"" + iconClasses + "\"></i> "; } if (iconPosition == IconPosition.LEFT) { sb.appendHtmlConstant(iconHtml); sb.appendEscapedLines(separator); } sb.append(data); if (iconPosition == IconPosition.RIGHT) { sb.appendEscapedLines(separator); sb.appendHtmlConstant(iconHtml); } } sb.appendHtmlConstant("</button>"); }
From source file:com.gafactory.core.client.ui.grids.TextInputCell.java
License:Apache License
@Override public void render(Context context, String value, SafeHtmlBuilder sb) { // Get the view data. Object key = context.getKey(); ViewData viewData = getViewData(key); if (viewData != null && viewData.getCurrentValue().equals(value)) { clearViewData(key);//from www . ja v a 2 s . co m viewData = null; } String s = (viewData != null) ? viewData.getCurrentValue() : value; if (s != null) { sb.append(template.input(s)); } else { sb.appendHtmlConstant("<input type=\"text\" class=\"form-control\" tabindex=\"-1\"></input>"); } }
From source file:com.github.gwtbootstrap.client.ui.base.ValueBoxBase.java
License:Apache License
/** * // w w w .j a v a 2 s . co m * @see com.google.gwt.editor.client.HasEditorErrors#showErrors(java.util.List) */ @Override public void showErrors(List<EditorError> errors) { Widget decoratedWidget = controlGroup != null ? controlGroup : this; if (errors != null && !errors.isEmpty()) { StyleHelper.addStyle(decoratedWidget, ControlGroupType.ERROR); SafeHtmlBuilder sb = new SafeHtmlBuilder(); for (EditorError error : errors) { if (error.getEditor() == this) { error.setConsumed(true); sb.appendEscaped(error.getMessage()); sb.appendHtmlConstant("<br />"); } } setErrorLabelText(sb.toSafeHtml().asString()); } else { StyleHelper.removeStyle(decoratedWidget, ControlGroupType.ERROR); setErrorLabelText(""); } }
From source file:com.github.gwtbootstrap.client.ui.ButtonCell.java
License:Apache License
@Override public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<button type=\"button\" class=\"btn " + (type != null ? type.get() : "") + (size != null ? " " + size.get() : "") + "\" tabindex=\"-1\">"); if (data != null) { if (icon != null) { sb.appendHtmlConstant("<i class=\"" + icon.get() + "\"></i> "); }/* ww w . ja v a2 s.com*/ sb.append(data); } sb.appendHtmlConstant("</button>"); }
From source file:com.github.gwtbootstrap.client.ui.CodeBlock.java
License:Apache License
/** * Sets the widget's text.//w w w. j av a 2 s . co m * <p> * Any HTML content is escaped and displayed as text. * * @param html * the text to be set */ public void setHTML(String html) { String[] lines = html.split("\\\\n"); SafeHtmlBuilder shb = new SafeHtmlBuilder(); for (String s : lines) { shb.appendEscaped(s); shb.appendHtmlConstant("<br/>"); } if (getStyleName().contains("prettyprinted")) { removeStyleName("prettyprinted"); } getElement().setInnerHTML(shb.toSafeHtml().asString()); if (isAttached()) { helper.configure(linenums); } }
From source file:com.goodow.web.reader.client.TextAreaCell.java
License:Apache License
@Override public void render(final com.google.gwt.cell.client.Cell.Context context, final String value, final SafeHtmlBuilder sb) { Object key = context.getKey(); ViewData viewData = getViewData(key); if (viewData != null && viewData.getCurrentValue().equals(value)) { clearViewData(key);/*w w w . j av a 2 s .c o m*/ viewData = null; } String s = (viewData != null) ? viewData.getCurrentValue() : value; if (s != null) { sb.append(template.input(s)); } else { sb.appendHtmlConstant( "<textarea rows=\"3\" dir style=\"resize: none;margin: 2px; width: 130px;height: 50px;\"></textarea>"); } }
From source file:com.google.code.tree.client.CustomEditTextCell.java
License:Apache License
@Override public void render(Context context, UpdatableTreeNode value, SafeHtmlBuilder sb) { // Get the view data. Object key = context.getKey(); ViewData viewData = getViewData(key); if (viewData != null && !viewData.isEditing() && value != null && value.getLabel().equals(viewData.getText())) { clearViewData(key);/*from www. ja va 2 s . c om*/ viewData = null; } String toRender = value.getLabel(); if (viewData != null) { String text = viewData.getText(); if (viewData.isEditing()) { /* * Do not use the renderer in edit mode because the value of a * text input element is always treated as text. SafeHtml isn't * valid in the context of the value attribute. */ sb.append(template.input(text, charSize)); return; } else { // The user pressed enter, but view data still exists. toRender = text; } } if (toRender != null && toRender.trim().length() > 0) { sb.append(renderer.render(toRender)); } else { /* * Render a blank space to force the rendered element to have a * height. Otherwise it is not clickable. */ sb.appendHtmlConstant("\u00A0"); } }
From source file:com.google.developers.gdgfirenze.admin.client.cell.SampleCell.java
License:Apache License
@Override public void render(Context context, AbstractSample sample, SafeHtmlBuilder sb) { // Value can be null, so do a null check.. if (sample == null) { return;/*from w w w. j av a2 s . c o m*/ } sb.appendHtmlConstant("<table><tr><td colspan=\"2\"><strong>"); if (sample.getType() != null) { final ResourcePrototype icon = ICON_BUNDLE.getResource(findIconName(sample.getType())); if (icon != null) { final Image image = new Image((ImageResource) icon); image.setTitle(sample.getType()); sb.appendHtmlConstant(image.toString()); } else { sb.appendEscaped(sample.getType()); } } sb.appendEscaped(sample.getTime().toString()); sb.appendHtmlConstant("</strong></td></tr>"); if (sample instanceof NumericValueSample) { final NumericValueSample numericValueSample = (NumericValueSample) sample; sb.appendHtmlConstant(getTableRow("Value", numericValueSample.getValue())); } else if (sample instanceof StringValueSample) { final StringValueSample stringValueSample = (StringValueSample) sample; sb.appendHtmlConstant(getTableRow("Value", stringValueSample.getValue())); } else if (sample instanceof StringValueSample) { final StringValueSample stringValueSample = (StringValueSample) sample; sb.appendHtmlConstant("<tr><td>Value: </td><td>"); sb.appendEscaped(stringValueSample.getValue()); sb.appendHtmlConstant("</td><td>"); } else if (sample instanceof PositionSample) { final PositionSample positionSample = (PositionSample) sample; sb.appendHtmlConstant(getTableRow("Latitude,Longitude", fromDoubleToString(positionSample.getLat()) + "," + fromDoubleToString(positionSample.getLng()))); sb.appendHtmlConstant(getTableRow("Altitude", positionSample.getAlt())); sb.appendHtmlConstant(getTableRow("Bearing", positionSample.getBearing())); sb.appendHtmlConstant(getTableRow("Speed", positionSample.getSpeed())); sb.appendHtmlConstant(getTableRow("Accuracy", positionSample.getAccuracy())); } else if (sample instanceof WifiSignalSample) { final WifiSignalSample wifiSignalSample = (WifiSignalSample) sample; sb.appendHtmlConstant(getTableRow("Frequency", wifiSignalSample.getFrequency())); sb.appendHtmlConstant(getTableRow("Level", wifiSignalSample.getLevel())); sb.appendHtmlConstant(getTableRow("BSSID", wifiSignalSample.getBssid())); sb.appendHtmlConstant(getTableRow("SSID", wifiSignalSample.getSsid())); sb.appendHtmlConstant(getTableRow("Capabilities", wifiSignalSample.getCapabilities())); } sb.appendHtmlConstant("</table>"); }
From source file:com.google.developers.gdgfirenze.admin.client.cell.SensorCell.java
License:Apache License
@Override public void render(Context context, Sensor sensor, SafeHtmlBuilder sb) { // Value can be null, so do a null check.. if (sensor == null) { return;// w ww. j a v a2 s .c o m } sb.appendHtmlConstant("<table><tr><td title=\"" + sensor.getId() + "\"><strong>"); sb.appendEscaped(sensor.getName()); sb.appendHtmlConstant("</strong>"); if (sensor.getType() != null) { sb.appendHtmlConstant("</td><td>"); final ResourcePrototype icon = ICON_BUNDLE.getResource(findIconName(sensor.getType())); if (icon != null) { final Image image = new Image((ImageResource) icon); image.setTitle(sensor.getType()); sb.appendHtmlConstant(image.toString()); } else { sb.appendEscaped(sensor.getType()); } } sb.appendHtmlConstant("</td></tr><tr><td style=\"font-size:0.9em;\">"); sb.appendEscaped(sensor.getDescription()); if (sensor.getLastSeen() != null || sensor.getLat() != null) { sb.appendHtmlConstant("</td></tr><tr><td style=\"font-size:0.9em;\"><dl>"); if (sensor.getLastSeen() != null) { sb.appendHtmlConstant("<dt>Last Seen:</dt><dd>"); sb.appendEscaped(df.format(sensor.getLastSeen())); sb.appendHtmlConstant("</dd>"); } if (sensor.getLat() != null) { sb.appendHtmlConstant("<dt>Position:</dt><dd>"); sb.appendEscaped(sensor.getLat() + "," + sensor.getLng()); sb.appendHtmlConstant("</dd>"); } sb.appendHtmlConstant("</dl>"); } sb.appendHtmlConstant("</td></td></table>"); }
From source file:com.google.gerrit.client.ui.HighlightSuggestion.java
License:Apache License
@Override public String getDisplayString() { int start = 0; int keyLen = keyword.length(); SafeHtmlBuilder builder = new SafeHtmlBuilder(); for (;;) {/* w ww. j a v a 2 s . c om*/ int index = value.indexOf(keyword, start); if (index == -1) { builder.appendEscaped(value.substring(start)); break; } builder.appendEscaped(value.substring(start, index)); builder.appendHtmlConstant("<strong>"); start = index + keyLen; builder.appendEscaped(value.substring(index, start)); builder.appendHtmlConstant("</strong>"); } return builder.toSafeHtml().asString(); }