List of usage examples for com.google.gwt.dom.client SpanElement setInnerHTML
@Override public void setInnerHTML(String html)
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
private LIElement showGroup(List<Record> recordsToShow, UListElement ul) { final Document document = Document.get(); final String primaryKeyField = getPrimaryKeyFieldName(), iconField = getIconField(), titleField = getTitleField(), infoField = getInfoField(), descriptionField = getDescriptionField(); LIElement lastLI = null;/*ww w. j a v a2 s .c o m*/ for (final Record record : recordsToShow) { final Canvas recordComponent; if (getShowRecordComponents()) { recordComponent = createRecordComponent(record); if (recordComponent == null) { continue; } else recordComponents.add(recordComponent); } else recordComponent = null; final LIElement li = document.createLIElement(); li.addClassName(ROW_CLASS_NAME); com.google.gwt.user.client.Element element = li.cast(); final Object recordID = record.getAttributeAsObject(primaryKeyField); elementMap.put(recordID, element); final Integer recordIndex = record.getAttributeAsInt(recordIndexProperty); li.setAttribute(RECORD_INDEX_ATTRIBUTE_NAME, recordIndex.toString()); if (lastLI == null) { li.addClassName(_CSS.firstTableViewRowClass()); } if (showSelectedIcon && selectedIcon == null && getSelectionType() == SelectionStyle.MULTIPLE) { DivElement selectionDisclosure = document.createDivElement(); selectionDisclosure.setClassName(_CSS.recordSelectionDisclosureClass()); if (!_canSelectRecord(record)) { selectionDisclosure.addClassName(_CSS.nonselectableSelectionDisclosureClass()); } SpanElement span = document.createSpanElement(); selectionDisclosure.appendChild(span); li.appendChild(selectionDisclosure); } if (canRemoveRecords) { Boolean deletable = record.getAttributeAsBoolean(canRemoveProperty); if (deletable == null || (deletable != null && deletable.booleanValue())) { DivElement div = document.createDivElement(); div.addClassName(_CSS.recordDeleteDisclosureClass()); SpanElement span = document.createSpanElement(); div.appendChild(span); li.appendChild(div); if (markedForRemoval != null && markedForRemoval.contains(record)) { _markRecordRemoved(record, div, true); } } } if (canReorderRecords) { MoveIndicator draggableRow = new MoveIndicator(element); add(draggableRow, element); } if (!getShowRecordComponents()) { if (recordFormatter != null) { DivElement div = document.createDivElement(); div.setClassName("content"); div.setInnerHTML(recordFormatter.format(record)); li.appendChild(div); } else { if (getShowNavigation(record)) { final ImageResource navIcon = getNavigationIcon(record); if (navigationMode == NavigationMode.NAVICON_ONLY) { Boolean navigate = record.getAttributeAsBoolean(getRecordNavigationProperty()); if (navigate == null || (navigate != null && navigate.booleanValue())) { final DetailsRow detailsRow = new DetailsRow(navIcon); add(detailsRow, element); } } else if (navIcon != null) { final Image image = new Image(navIcon); image.getElement().addClassName(TableView._CSS.recordDetailDisclosureNavIconClass()); add(image, element); } else { li.addClassName(_CSS.tableViewRowHasNavigationDisclosureClass()); } } if (showIcons) { Object icon = record.get(iconField); if (!(icon instanceof ImageResource) && !(icon instanceof Image)) { icon = formatCellValue(record, recordIndex.intValue(), iconField); } if (icon != null) { SpanElement span = document.createSpanElement(); span.addClassName(RECORD_ICON_CLASS_NAME); li.appendChild(span); li.addClassName(_CSS.tableViewRowHasIconClass()); ImageElement img = document.createImageElement(); if (icon instanceof ImageResource) { img.setSrc(((ImageResource) icon).getSafeUri().asString()); } else if (icon instanceof Image) { img.setSrc(((Image) icon).getUrl()); } else { img.setSrc(icon.toString()); } span.appendChild(img); } } if (showDetailCount) { String count = formatCellValue(record, recordIndex.intValue(), detailCountProperty); if (count != null) { SpanElement span = document.createSpanElement(); span.addClassName(RECORD_COUNTER_CLASS_NAME); span.setInnerHTML(count); li.appendChild(span); } } String title = formatCellValue(record, recordIndex.intValue(), titleField); if (title != null) { SpanElement span = document.createSpanElement(); final String baseStyle = getBaseStyle(record, recordIndex.intValue(), getFieldNum(titleField)); if (baseStyle != null) span.setClassName(baseStyle); span.addClassName(RECORD_TITLE_CLASS_NAME); span.setInnerHTML(title); li.appendChild(span); } if (recordLayout == RecordLayout.AUTOMATIC || recordLayout == RecordLayout.SUMMARY_FULL || recordLayout == RecordLayout.SUMMARY_INFO) { String info = formatCellValue(record, recordIndex.intValue(), infoField); if (info != null) { ul.addClassName(_CSS.stackedTableViewClass()); li.addClassName(_CSS.tableViewRowHasRecordInfoClass()); SpanElement span = document.createSpanElement(); final String baseStyle = getBaseStyle(record, recordIndex.intValue(), getFieldNum(infoField)); if (baseStyle != null) span.setClassName(baseStyle); span.addClassName(RECORD_INFO_CLASS_NAME); span.appendChild(document.createTextNode(info)); li.appendChild(span); } } if (recordLayout == RecordLayout.AUTOMATIC || recordLayout == RecordLayout.TITLE_DESCRIPTION || recordLayout == RecordLayout.SUMMARY_DATA || recordLayout == RecordLayout.SUMMARY_FULL || recordLayout == RecordLayout.SUMMARY_INFO) { String description = formatCellValue(record, recordIndex.intValue(), descriptionField); if (description != null) { SpanElement span = document.createSpanElement(); final String baseStyle = getBaseStyle(record, recordIndex.intValue(), getFieldNum(descriptionField)); if (baseStyle != null) span.setClassName(baseStyle); span.addClassName(RECORD_DESCRIPTION_CLASS_NAME); span.appendChild(document.createTextNode(description)); li.appendChild(span); } } } } else { assert recordComponent != null; recordComponent.getElement().addClassName(RECORD_COMPONENT_CLASS_NAME); add(recordComponent, element); } ul.appendChild(li); lastLI = li; } return lastLI; }
From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java
License:Open Source License
@SGWTInternal protected void _setSelected(Element element) { final SelectionStyle selectionType = getSelectionType(); assert selectionType != null && selectionType != SelectionStyle.NONE; if (!hasClassName(element, _CSS.selectedTableViewRowClass()) && !hasClassName(element, _CSS.selectedTableViewRowHasIconClass())) { if (showSelectedIcon) { element.addClassName(_CSS.selectedTableViewRowHasIconClass()); if (selectionType == SelectionStyle.SINGLE || selectedIcon != null) { SpanElement span = Document.get().createSpanElement(); span.addClassName(_CSS.selectedClass()); Image image = selectedIcon != null ? new Image(selectedIcon) : impl.getDefaultSingleSelectionIcon(); image.getElement().addClassName(_CSS.selectedClass()); span.setInnerHTML(image.toString()); element.insertFirst(span); } else { assert selectionType != SelectionStyle.SINGLE; assert selectionType == SelectionStyle.MULTIPLE; // Find the .selection-disclosure element and add class `CSS.checkedSelectionOrDeleteDisclosureClass()'. NodeList<Node> children = element.getChildNodes(); final int children_length = children.getLength(); int i = 0; for (; i < children_length; ++i) { final Node n = children.getItem(i); if (n.getNodeType() != Node.ELEMENT_NODE) { continue; }//w w w . j av a 2 s .co m final Element child = Element.as(n); if (hasClassName(child, _CSS.recordSelectionDisclosureClass())) { child.addClassName(_CSS.checkedSelectionOrDeleteDisclosureClass()); break; } } assert i < children_length; } } else { element.removeClassName(_CSS.clearingTemporaryTableViewRowSelectionClass()); element.addClassName(_CSS.selectedTableViewRowClass()); } } }
From source file:org.uberfire.client.views.pfly.listbar.PartListDropdown.java
License:Apache License
private SpanElement buildTitleTextWidget(final String title, final IsWidget titleDecoration) { final SpanElement spanElement = Document.get().createSpanElement(); spanElement.addClassName("uf-listbar-panel-header-title-text"); spanElement.addClassName(CSSLocatorsUtils.buildLocator("qe-list-bar-header", title)); final String titleWidget = (titleDecoration instanceof Image) ? titleDecoration.toString() : ""; spanElement.setInnerHTML(titleWidget + " " + title.replaceAll(" ", "\u00a0")); spanElement.setTitle(title);/* w w w . j a va 2s .c o m*/ return spanElement; }
From source file:org.waveprotocol.wave.client.clipboard.Clipboard.java
License:Apache License
/** * Hijacks the paste fragment by hiding a span with metadata at the end of the * fragment.// w w w . j av a2 s . c om * * @param xmlInRange The xml string to pass into the magic span element * @param annotations The annotation string to pass into the magic span * element * @param origRange the current range. The span element will be inserted * before the start * * @return The new adjusted selection. The end will be adjusted such that it * encloses the original selection and the span with metadata */ private PointRange<Node> hijackFragment(String xmlInRange, String annotations, PointRange<Node> origRange) { Point<Node> origStart = origRange.getFirst(); Point<Node> origEnd = origRange.getSecond(); SpanElement spanForXml = Document.get().createSpanElement(); spanForXml.setAttribute(WAVE_XML_ATTRIBUTE, xmlInRange); spanForXml.setAttribute(WAVE_ANNOTATIONS_ATTRIBUTE, annotations); spanForXml.setClassName(MAGIC_CLASSNAME); LOG.trace().log("original point: " + origStart); // NOTE(user): An extra span is required at the end for Safari, otherwise // the span with the metadata may get discarded. SpanElement trailingSpan = Document.get().createSpanElement(); trailingSpan.setInnerHTML(" "); if (origEnd.isInTextNode()) { Text t = (Text) origEnd.getContainer(); t.setData(t.getData().substring(0, origEnd.getTextOffset())); origEnd.getContainer().getParentElement().insertAfter(spanForXml, t); origEnd.getContainer().getParentElement().insertAfter(trailingSpan, spanForXml); } else { origEnd.getContainer().insertAfter(spanForXml, origEnd.getNodeAfter()); origEnd.getContainer().insertAfter(trailingSpan, spanForXml); } Point<Node> newEnd = Point.<Node>inElement(spanForXml.getParentElement(), trailingSpan.getNextSibling()); LOG.trace().log("new point: " + newEnd); LOG.trace().logPlainText("parent: " + spanForXml.getParentElement().getInnerHTML()); assert newEnd.getNodeAfter() == null || newEnd.getNodeAfter().getParentElement() == newEnd.getContainer() : "inconsistent point"; return new PointRange<Node>(origStart, newEnd); }