List of usage examples for com.google.gwt.safehtml.shared SafeHtmlBuilder append
public SafeHtmlBuilder append(SafeHtml html)
From source file:com.anritsu.mcrepositorymanager.client.utils.DynamicSelectionCell.java
License:Apache License
@Override public void render(Context context, String value, SafeHtmlBuilder sb) { // Get the view data. Object key = context.getKey(); String viewData = getViewData(key); if (viewData != null && viewData.equals(value)) { clearViewData(key);// w w w .j a va 2 s .c o m viewData = null; } int selectedIndex = getSelectedIndex(viewData == null ? value : viewData); sb.appendHtmlConstant("<select style=\"width:100%\" tabindex=\"-1\">"); int index = 0; for (String option : options) { if (index++ == selectedIndex) { sb.append(template.selected(option)); } else { sb.append(template.deselected(option)); } } sb.appendHtmlConstant("</select>"); }
From source file:com.anritsu.mcrepositorymanager.client.utils.TextAreaInputCell.java
@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);//w ww. ja v a2 s . co m viewData = null; } String s = (viewData != null) ? viewData.getCurrentValue() : value; if (s != null) { sb.append(template.input(s)); } else { sb.appendHtmlConstant("<textarea type=\"text\" cols=\"40\" rows=\"1\" tabindex=\"-1\"></textarea>"); } }
From source file:com.arcbees.chosen.client.ChosenImpl.java
License:Apache License
private SafeHtml createEmptyOption() { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(fromTrustedString("<option value=''></option>")); return builder.toSafeHtml(); }
From source file:com.arcbees.chosen.client.ChosenImpl.java
License:Apache License
private SafeHtml createOption(OptionItem item) { SafeHtmlBuilder builder = new SafeHtmlBuilder(); builder.append(fromTrustedString("<option value='")).appendEscaped(item.getValue()) .append(fromTrustedString("'")); if (item.isSelected()) { builder.append(fromTrustedString(" selected")); }//w ww. j a v a2s. c o m if (item.isDisabled()) { builder.append(fromTrustedString(" disabled")); } builder.append(fromTrustedString(">")).appendEscaped(item.getText()); builder.append(fromTrustedString("</option>")); return builder.toSafeHtml(); }
From source file:com.arcbees.chosen.client.ChosenImpl.java
License:Apache License
private void rebuildResultItems(boolean init) { if (selectedItem != null) { selectedItem.toggleClass(css.chznDefault(), selectedValues.isEmpty()); }/*from ww w. j av a 2s .co m*/ SafeHtmlBuilder content = new SafeHtmlBuilder(); SafeHtmlBuilder optionsHtml = new SafeHtmlBuilder(); selectedValues = new ArrayList<String>(); for (SelectItem item : selectItems) { if (item.isGroup()) { SafeHtml result = resultAddGroup((GroupItem) item); if (result != null) { content.append(result); } } else { OptionItem optionItem = (OptionItem) item; if (optionItem.isEmpty()) { optionsHtml.append(createEmptyOption()); continue; } if (customFilter) { optionsHtml.append(createOption(optionItem)); } SafeHtml optionHtml = resultAddOption(optionItem); if (optionHtml != null) { content.append(optionHtml); } if (optionItem.isSelected()) { addChoice(optionItem); selectedValues.add(optionItem.getValue()); } } } isDisabled = selectElement.isDisabled(); if (isDisabled) { setupDisabledSearchField(); } else { setupEnabledSearchField(); } if (init) { showSearchFieldDefault(defaultText); searchFieldScale(fWidth); } if (customFilter) { // keep the html select element synchronized with the new result. $selectElement.html(optionsHtml.toSafeHtml().asString()); } searchResults.html(content.toSafeHtml().asString()); if (resultsShowing) { positionDropdownResult(); } }
From source file:com.bearsoft.gwt.ui.widgets.grid.cells.DateEditorCell.java
@Override protected void renderCell(Context context, Date value, SafeHtmlBuilder sb) { sb.append(SafeHtmlUtils.fromTrustedString(value != null ? format.format(value) : "")); }
From source file:com.bearsoft.gwt.ui.widgets.grid.cells.DivDecoratorCell.java
@Override public void render(Context context, C value, SafeHtmlBuilder sb) { SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); cell.render(context, value, cellBuilder); sb.append(template.outerDiv(outerDivClasses(context), outerDivPadding(context), cellBuilder.toSafeHtml())); }
From source file:com.bearsoft.gwt.ui.widgets.grid.cells.RenderedEditorCell.java
@Override public void render(final Context context, final T value, SafeHtmlBuilder sb) { CellsResources.INSTANCE.tablecell().ensureInjected(); String viewDataId = ""; if (isEditing(context, null, value)) { final ViewData<T> viewData = getViewData(context.getKey()); viewDataId = viewData.id;//from w w w . ja va 2 s. co m Scheduler.get().scheduleDeferred(new ScheduledCommand() { @Override public void execute() { if (isEditing(context, null, value)) { Element parent = Document.get().getElementById(viewData.id); if (parent != null) { parent.blur(); Element table = parent; while (table != null && !"table".equalsIgnoreCase(table.getTagName())) { table = table.getParentElement(); } final Element table1 = table; if (parent.getOwnerDocument() == Document.get()) { startEditing(context, parent, table1.getParentElement(), value, viewData.updater, new Runnable() { public void run() { if (onEditorClose != null && table1 != null) { onEditorClose.closed(table1); } } }); } } } } }); } if (renderer == null || !renderer.render(context, viewDataId, value, sb)) { SafeHtmlBuilder content = new SafeHtmlBuilder(); renderCell(context, value, content); sb.append(PaddedCell.INSTANCE.generate(viewDataId, CellsResources.INSTANCE.tablecell().padded(), new SafeStylesBuilder().padding(CELL_PADDING, Style.Unit.PX).toSafeStyles(), content.toSafeHtml())); } }
From source file:com.bearsoft.gwt.ui.widgets.grid.cells.TreeExpandableCell.java
@Override public void render(Context context, C value, SafeHtmlBuilder sb) { if (treeProvider != null) { SafeHtmlBuilder cellBuilder = new SafeHtmlBuilder(); cell.render(context, value, cellBuilder); int deepness = getDeepness(context); int outerDivPadding = indent * (deepness + 1); SafeStyles styles = new SafeStylesBuilder() .trustedNameAndValue("background-position", indent * deepness, Style.Unit.PX) .paddingLeft(outerDivPadding, Style.Unit.PX).position(Style.Position.RELATIVE) .height(100, Style.Unit.PCT).toSafeStyles(); sb.append(template.outerDiv(outerDivClasses(context), styles, cellBuilder.toSafeHtml())); } else {/*from ww w .ja v a 2 s .c om*/ cell.render(context, value, sb); } }
From source file:com.chinarewards.gwt.elt.client.widget.SortableHeader.java
License:Apache License
private void renderSortedHtml(int imageWidth, String arrow, String text, SafeHtmlBuilder sb) { sb.appendHtmlConstant("<div style=\"position:relative;cursor:hand;cursor:pointer;" + "padding-right:" + imageWidth + "px;\">"); sb.appendHtmlConstant(arrow);/*from w w w .j a va 2s . c o m*/ sb.appendHtmlConstant("<div>"); SafeHtml safeValue = SafeHtmlUtils.fromString(text); sb.append(safeValue); sb.appendHtmlConstant("</div></div>"); }