List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder appendEscaped
public SafeHtmlBuilder appendEscaped(String text)
From source file:com.sencha.gxt.cell.core.client.PropertyDisplayCell.java
License:sencha.com license
public void render(Cell.Context context, C value, SafeHtmlBuilder sb) { sb.appendEscaped(propertyEditor.render(value)); }
From source file:com.sencha.gxt.theme.base.client.field.FieldLabelDefaultAppearance.java
License:sencha.com license
@Override public void onUpdateOptions(XElement parent, FieldLabelOptions options) { LabelAlign labelAlign = options.getLabelAlign(); XElement fieldElement = getChildElementWrapper(parent); XElement labelElement = getLabelElement(parent); // Adjust for label content, label separator SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.append(options.getContent());// www.j av a2 s . c om sb.appendEscaped(options.getLabelSeparator()); labelElement.setInnerSafeHtml(sb.toSafeHtml()); // Adjust for label alignment if (labelAlign == LabelAlign.TOP) { parent.addClassName(style.fieldItemLabelTop()); } else { parent.removeClassName(style.fieldItemLabelTop()); } // Adjust for label width if (labelAlign == LabelAlign.TOP) { labelElement.getStyle().setProperty("width", "auto"); fieldElement.getStyle().setPaddingLeft(0, Unit.PX); } else { int pad = options.getLabelPad(); if (pad == 0) pad = 5; labelElement.getStyle().setWidth(options.getLabelWidth(), Unit.PX); fieldElement.getStyle().setPaddingLeft(options.getLabelWidth() + pad, Unit.PX); } // Adjust for label word wrap labelElement.getStyle().setProperty("whiteSpace", options.getWordWrap() ? "normal" : "nowrap"); }
From source file:com.sencha.gxt.widget.core.client.grid.editing.AbstractGridEditing.java
License:sencha.com license
protected void getErrorMessage(IsField<?> field, SafeHtmlBuilder sb, SafeHtml title) { boolean result = true; if (field instanceof ValueBaseField) { ValueBaseField<?> vfield = (ValueBaseField<?>) field; result = vfield.isCurrentValid(true); }// w w w . j a v a 2 s . c o m if (!result || !field.isValid(true)) { sb.appendHtmlConstant("<li><b>"); sb.append(title); sb.appendHtmlConstant("</b>: "); sb.appendEscaped(field.getErrors().get(0).getMessage()); sb.appendHtmlConstant("</li>"); } }
From source file:com.tasktop.c2c.server.common.profile.web.client.ValidatingTextAreaInputCell.java
License:Open Source License
private void renderError(Context context, String value, SafeHtmlBuilder sb) { // Tack on our surrounding highlight. sb.appendHtmlConstant("<div class=\"errorLabelWrapper\">"); super.render(context, value, sb); // Also add in a space for our validation failure message. sb.appendHtmlConstant("<div class=\"errorLabel\">"); sb.appendEscaped(ValidationUtils.getErrorMessage(context.getKey(), fieldName, errorMap)); sb.appendHtmlConstant("</div></div>"); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.TasksSummaryListView.java
License:Open Source License
private void createProductHeader(Product product) { SafeHtmlBuilder sb = new SafeHtmlBuilder(); sb.appendHtmlConstant("<h2 class=\"task-summary-product-header\">"); sb.appendEscaped(tasksMessages.productWithName(product.getName())); sb.appendHtmlConstant("</h2>"); taskSummaryPanel.add(new HTML(sb.toSafeHtml())); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.TasksSummaryView.java
License:Open Source License
public void createTaskSegment(String segmentTitle, List<Task> segmentTaskList) { // This was originally implemented using a similar pattern to ApplicationCard - however, that way took several // seconds on large lists and this is basically instantaneous (even though it doesn't look as pretty). SafeHtmlBuilder bodyBuilder = new SafeHtmlBuilder(); int numClosed = 0; for (Task curTask : segmentTaskList) { bodyBuilder.appendHtmlConstant("<div class=\"task-summary-card\">"); Anchor link = new Anchor(tasksMessages.taskWithId(curTask.getId())); link.setHref(ProjectTaskPlace.createPlace(appId, curTask.getId()).getHref()); if (!curTask.getStatus().isOpen()) { link.addStyleName("resolved"); numClosed++;/*from www . jav a 2 s. c o m*/ } bodyBuilder.appendHtmlConstant(link.toString()); bodyBuilder.appendHtmlConstant(" -- "); bodyBuilder.appendEscaped(curTask.getShortDescription()); bodyBuilder.appendHtmlConstant("<div class=\"clearleft\"></div></div>"); } SafeHtmlBuilder headerBuilder = new SafeHtmlBuilder(); if (segmentTitle != null) { int total = segmentTaskList.size(); int numOpen = total - numClosed; Task sampleTask = segmentTaskList.get(0); Anchor link = new Anchor(segmentTitle, ProjectTasksSummaryPlace .createPlaceForComponentAndRelease(appId, (Integer) productId, sampleTask.getComponent().getId(), sampleTask.getMilestone().getValue()) .getHref()); // We have a title, so insert it at the beginning of the HTML. headerBuilder.appendHtmlConstant("<h3 class=\"task-summary-header\">"); headerBuilder .appendEscaped(tasksMessages.taskSummaryHeader(link.toString(), total, numOpen, numClosed)); headerBuilder.appendHtmlConstant("</h3>"); } // Now, add in the body after the header. headerBuilder.append(bodyBuilder.toSafeHtml()); taskSummaryPanel.add(new HTML(headerBuilder.toSafeHtml())); }
From source file:com.tasktop.c2c.server.tasks.client.widgets.TaskViewImpl.java
License:Open Source License
private SafeHtml getHtmlForStrings(List<String> strings) { SafeHtmlBuilder shb = new SafeHtmlBuilder(); for (int i = 0; i < strings.size(); i++) { // First, append this string as an escaped value to prevent XSS shb.appendEscaped(strings.get(i)); // Then, if this isn't the last tag, append a <br/> if (i < (strings.size() - 1)) { shb.appendHtmlConstant("<br/>"); }/* ww w .j a va2s . c om*/ } // Check if we ended up with a blank string - if we did, send back a default if (strings.size() == 0) { shb.appendEscaped(commonProfileMessages.none()); } return shb.toSafeHtml(); }
From source file:com.toedter.gwt.demo.contacts.client.ui.ContactCell.java
License:Open Source License
@Override public void render(Context context, Contact value, SafeHtmlBuilder sb) { if (value != null) { sb.appendEscaped(value.getFirstName() + " " + value.getLastName()); }// w w w . j a v a 2s .c o m }
From source file:cz.metacentrum.perun.webgui.widgets.UnaccentMultiWordSuggestOracle.java
License:Apache License
/** * Returns real suggestions with the given query in <code>strong</code> html * font.//from w w w .ja v a 2 s. com * * @param query query string * @param candidates candidates * @return real suggestions */ private List<MultiWordSuggestion> convertToFormattedSuggestions(String query, List<String> candidates) { List<MultiWordSuggestion> suggestions = new ArrayList<MultiWordSuggestion>(); for (int i = 0; i < candidates.size(); i++) { String candidate = candidates.get(i); int cursor = 0; int index = 0; // Use real suggestion for assembly. String formattedSuggestion = toRealSuggestions.get(candidate); // Create strong search string. SafeHtmlBuilder accum = new SafeHtmlBuilder(); String[] searchWords = query.split(WHITESPACE_STRING); while (true) { WordBounds wordBounds = findNextWord(candidate, searchWords, index); if (wordBounds == null) { break; } if (wordBounds.startIndex == 0 || WHITESPACE_CHAR == candidate.charAt(wordBounds.startIndex - 1)) { String part1 = formattedSuggestion.substring(cursor, wordBounds.startIndex); String part2 = formattedSuggestion.substring(wordBounds.startIndex, wordBounds.endIndex); cursor = wordBounds.endIndex; accum.appendEscaped(part1); accum.appendHtmlConstant("<strong>"); accum.appendEscaped(part2); accum.appendHtmlConstant("</strong>"); } index = wordBounds.endIndex; } // Check to make sure the search was found in the string. if (cursor == 0) { continue; } accum.appendEscaped(formattedSuggestion.substring(cursor)); MultiWordSuggestion suggestion = createSuggestion(formattedSuggestion, accum.toSafeHtml().asString()); suggestions.add(suggestion); } return suggestions; }
From source file:de.knightsoftnet.validators.client.decorators.AbstractDecorator.java
License:Apache License
/** * The default implementation will display, but not consume, received errors whose * {@link EditorError#getEditor() getEditor()} method returns the Editor passed into * {@link #setEditor}.//from w ww . j a va 2s.co m * * @param errors a List of {@link EditorError} instances */ @Override public void showErrors(final List<EditorError> errors) { final Set<String> messages = new HashSet<String>(); for (final EditorError error : errors) { if (this.editorErrorMatches(error)) { messages.add(error.getMessage()); } } if (messages.isEmpty()) { this.errorLabel.setText(StringUtils.EMPTY); this.errorLabel.getElement().getStyle().setDisplay(Display.NONE); if (this.contents.getWidget() != null) { this.contents.getWidget().removeStyleName(this.decoratorStyle.errorInputStyle()); this.contents.getWidget().addStyleName(this.decoratorStyle.validInputStyle()); } } else { if (this.contents.getWidget() != null) { this.contents.getWidget().removeStyleName(this.decoratorStyle.validInputStyle()); this.contents.getWidget().addStyleName(this.decoratorStyle.errorInputStyle()); if (this.focusOnError) { this.setFocus(true); } } final SafeHtmlBuilder sb = new SafeHtmlBuilder(); for (final String message : messages) { sb.appendEscaped(message); sb.appendHtmlConstant("<br />"); } this.errorLabel.setHTML(sb.toSafeHtml()); this.errorLabel.getElement().getStyle().setDisplay(Display.TABLE); } }