Java Code Examples for com.google.gwt.dom.client.Element#setInnerText()

The following examples show how to use com.google.gwt.dom.client.Element#setInnerText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubaTreeTableWidget.java    From cuba with Apache License 2.0 6 votes vote down vote up
@Override
protected void initCellWithText(String text, char align, String style, boolean textIsHTML,
                                boolean sorted, String description, TableCellElement td) {
    super.initCellWithText(text, align, style, textIsHTML, sorted, description, td);

    Element tdElement = td.cast();
    Tools.textSelectionEnable(tdElement, _delegate.textSelectionEnabled);

    if ((_delegate.clickableColumns != null && _delegate.clickableColumns.contains(currentColumnKey))
            || (_delegate.clickableTableColumns != null && _delegate.clickableTableColumns.contains(currentColumnKey))) {
        tdElement.addClassName(CUBA_TABLE_CLICKABLE_CELL_CONTENT);
        Element wrapperElement = tdElement.getFirstChildElement();
        final Element clickableSpan = DOM.createSpan().cast();
        clickableSpan.setClassName(CUBA_TABLE_CLICKABLE_CELL_STYLE);

        clickableSpan.setInnerText(wrapperElement.getInnerText());

        wrapperElement.removeAllChildren();
        DOM.appendChild(wrapperElement, clickableSpan);
    }

    if (_delegate.multiLineCells) {
        Style wrapperStyle = tdElement.getFirstChildElement().getStyle();
        wrapperStyle.setWhiteSpace(Style.WhiteSpace.PRE_LINE);
    }
}
 
Example 2
Source File: DomUtil.java    From mapper with Apache License 2.0 5 votes vote down vote up
public static WritableProperty<String> innerTextOf(final Element e) {
  return new WritableProperty<String>() {
    @Override
    public void set(String value) {
      e.setInnerText(value);
    }
  };
}
 
Example 3
Source File: EditToolbar.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
private Element createHeadingElement(int level) {
  Element e = Document.get().createElement("h" + level);
  e.getStyle().setMarginTop(2, Unit.PX);
  e.getStyle().setMarginBottom(2, Unit.PX);
  e.setInnerText("Heading " + level);
  return e;
}
 
Example 4
Source File: CollapsibleDomImpl.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
public void setUnreadBlipCount(int unreadBlipCount) {
  self.setAttribute(UNREAD_BLIPS_ATTRIBUTE, "" + unreadBlipCount);
  Element unread = getCountUnread();
  unread.setInnerText("(" + unreadBlipCount + ")");
  if (unreadBlipCount > 0) {
    unread.getStyle().clearDisplay();
  } else {
    unread.getStyle().setDisplay(Display.NONE);
  }
  updatedCssClassNames();
}
 
Example 5
Source File: DiffHighlightingFilter.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
private void createDeleteElement(String innerText, ReadableStringMap<Object> annotations) {
  Element element = Document.get().createSpanElement();
  applyAnnotationsToElement(element, annotations);
  DiffManager.styleElement(element, DiffType.DELETE);
  element.setInnerText(innerText);
  currentDeleteInfo.htmlElements.add(element);
}
 
Example 6
Source File: AgentAdapter.java    From incubator-retired-wave with Apache License 2.0 5 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  Element unknown = Document.get().createDivElement();
  unknown.setClassName(css.unknown());
  unknown.setInnerText("<" + element.getTagName() + ">");
  DomHelper.setContentEditable(unknown, false, false);
  DomHelper.makeUnselectable(unknown);
  return unknown;
}
 
Example 7
Source File: Page.java    From requestor with Apache License 2.0 5 votes vote down vote up
private static void setPageElementText(String id, String title, boolean alignCenter) {
    final Element e = Document.get().getElementById(id);
    e.setInnerText(title);
    if (alignCenter) {
        e.addClassName("text-center");
    } else {
        e.removeClassName("text-center");
    }
}
 
Example 8
Source File: Popover.java    From putnami-web-toolkit with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void setTitle(String title) {
	Element titleElement = Document.get().createElement("h3");
	this.container.appendChild(titleElement);
	StyleUtils.addStyle(titleElement, Popover.STYLE_TITLE);
	titleElement.setInnerText(title);
}
 
Example 9
Source File: NavTreeWidgetView.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
protected void addItem(String iconClass, String id, String name, String description, Command onClicked) {
    Element nameEl = onClicked != null ? Document.get().createAnchorElement() : Document.get().createSpanElement();
    nameEl.setInnerText(name);
    nameEl.setClassName(onClicked != null ? "uf-navtree-widget-non-clicked" : "uf-navtree-widget-non-clickable");
    if (description != null && !description.equals(name)) {
        nameEl.setTitle(description);
    }

    SpanElement iconSpan = Document.get().createSpanElement();
    iconSpan.setClassName("uf-navtree-widget-icon " + iconClass);

    DivElement div = Document.get().createDivElement();
    div.appendChild(iconSpan);
    div.appendChild(nameEl);

    navWidget.appendChild((Node) div);
    itemMap.put(id, nameEl);

    if (onClicked != null) {
        Event.sinkEvents(nameEl, Event.ONCLICK);
        Event.setEventListener(nameEl, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    }
}
 
Example 10
Source File: EditToolbar.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private Element createHeadingElement(int level) {
  Element e = Document.get().createElement("h" + level);
  e.getStyle().setMarginTop(2, Unit.PX);
  e.getStyle().setMarginBottom(2, Unit.PX);
  e.setInnerText("Heading " + level);
  return e;
}
 
Example 11
Source File: CollapsibleDomImpl.java    From swellrt with Apache License 2.0 5 votes vote down vote up
public void setUnreadBlipCount(int unreadBlipCount) {
  self.setAttribute(UNREAD_BLIPS_ATTRIBUTE, "" + unreadBlipCount);
  Element unread = getCountUnread();
  unread.setInnerText("(" + unreadBlipCount + ")");
  if (unreadBlipCount > 0) {
    unread.getStyle().clearDisplay();
  } else {
    unread.getStyle().setDisplay(Display.NONE);
  }
  updatedCssClassNames();
}
 
Example 12
Source File: DiffHighlightingFilter.java    From swellrt with Apache License 2.0 5 votes vote down vote up
private void createDeleteElement(String innerText, ReadableStringMap<Object> annotations) {
  Element element = Document.get().createSpanElement();
  applyAnnotationsToElement(element, annotations);
  DiffManager.styleElement(element, DiffType.DELETE,
      operationCtx.getCreator() != null ? operationCtx.getCreator().getAddress() : "",
      operationCtx.getHashedVersion().getVersion(), operationCtx.getTimestamp());
  element.setInnerText(innerText);
  currentDeleteInfo.htmlElements.add(element);
}
 
Example 13
Source File: AgentAdapter.java    From swellrt with Apache License 2.0 5 votes vote down vote up
@Override
public Element createDomImpl(Renderable element) {
  Element unknown = Document.get().createDivElement();
  unknown.setClassName(css.unknown());
  unknown.setInnerText("<" + element.getTagName() + ">");
  DomHelper.setContentEditable(unknown, false, false);
  DomHelper.makeUnselectable(unknown);
  return unknown;
}
 
Example 14
Source File: VDragCaptionProvider.java    From cuba with Apache License 2.0 5 votes vote down vote up
public Element getDragCaptionElement(Widget w) {
    ComponentConnector component = Util.findConnectorFor(w);
    DDLayoutState state = ((DragAndDropAwareState) root.getState()).getDragAndDropState();
    DragCaptionInfo dci = state.dragCaptions.get(component);

    Document document = Document.get();

    Element dragCaptionImage = document.createDivElement();
    Element dragCaption = document.createSpanElement();

    String dragCaptionText = dci.caption;
    if (dragCaptionText != null) {
        if (dci.contentMode == ContentMode.TEXT) {
            dragCaption.setInnerText(dragCaptionText);
        } else if (dci.contentMode == ContentMode.HTML) {
            dragCaption.setInnerHTML(dragCaptionText);
        } else if (dci.contentMode == ContentMode.PREFORMATTED) {
            PreElement preElement = document.createPreElement();
            preElement.setInnerText(dragCaptionText);
            dragCaption.appendChild(preElement);
        }
    }

    String dragIconKey = state.dragCaptions.get(component).iconKey;
    if (dragIconKey != null) {
        String resourceUrl = root.getResourceUrl(dragIconKey);
        Icon icon = component.getConnection().getIcon(resourceUrl);
        dragCaptionImage.appendChild(icon.getElement());
    }

    dragCaptionImage.appendChild(dragCaption);

    return dragCaptionImage;
}
 
Example 15
Source File: EditToolbar.java    From swellrt with Apache License 2.0 4 votes vote down vote up
private Element createFontFamilyElement(FontFamily family) {
  Element e = Document.get().createSpanElement();
  e.getStyle().setProperty("fontFamily", family.style);
  e.setInnerText(family.description);
  return e;
}
 
Example 16
Source File: EditToolbar.java    From swellrt with Apache License 2.0 4 votes vote down vote up
private Element createFontSizeElement(double baseSize, double size) {
  Element e = Document.get().createSpanElement();
  e.getStyle().setFontSize(size / baseSize, Unit.EM);
  e.setInnerText(((int) size) + "");
  return e;
}
 
Example 17
Source File: EditToolbar.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
private Element createFontSizeElement(double baseSize, double size) {
  Element e = Document.get().createSpanElement();
  e.getStyle().setFontSize(size / baseSize, Unit.EM);
  e.setInnerText(((int) size) + "");
  return e;
}
 
Example 18
Source File: EditToolbar.java    From incubator-retired-wave with Apache License 2.0 4 votes vote down vote up
private Element createFontFamilyElement(FontFamily family) {
  Element e = Document.get().createSpanElement();
  e.getStyle().setProperty("fontFamily", family.style);
  e.setInnerText(family.description);
  return e;
}
 
Example 19
Source File: WeekGrid.java    From calendar-component with Apache License 2.0 4 votes vote down vote up
private void createTimeBar(boolean format24h) {
    setStylePrimaryName("v-calendar-times");

    // Fist "time" is empty
    Element e = DOM.createDiv();
    setStyleName(e, "v-calendar-time");
    e.setInnerText("");
    getElement().appendChild(e);

    DateTimeService dts = new DateTimeService();

    if (format24h) {
        for (int i = firstHour + 1; i <= lastHour; i++) {
            e = DOM.createDiv();
            setStyleName(e, "v-calendar-time");
            String delimiter = dts.getClockDelimeter();
            e.setInnerHTML("<span>" + i + "</span>" + delimiter + "00");
            getElement().appendChild(e);
        }
    } else {
        // FIXME Use dts.getAmPmStrings(); and make sure that
        // DateTimeService has a some Locale set.
        String[] ampm = new String[] { "AM", "PM" };

        int amStop = (lastHour < 11) ? lastHour : 11;
        int pmStart = (firstHour > 11) ? firstHour % 11 : 0;

        if (firstHour < 12) {
            for (int i = firstHour + 1; i <= amStop; i++) {
                e = DOM.createDiv();
                setStyleName(e, "v-calendar-time");
                e.setInnerHTML("<span>" + timesFor12h[i] + "</span>"
                        + " " + ampm[0]);
                getElement().appendChild(e);
            }
        }

        if (lastHour > 11) {
            for (int i = pmStart; i < lastHour - 11; i++) {
                e = DOM.createDiv();
                setStyleName(e, "v-calendar-time");
                e.setInnerHTML("<span>" + timesFor12h[i] + "</span>"
                        + " " + ampm[1]);
                getElement().appendChild(e);
            }
        }
    }
}