Package com.google.gwt.dom.client

Examples of com.google.gwt.dom.client.Text


    // but sometimes it might not be attached but should, and so should throw an exception.
    if (!isContentAttached() || !isImplAttached()) {
      simpleNormaliseImpl();
    }

    Text first = getImplNodelet();
    if (first.getLength() == getLength()) {
      return;
    }

    ContentNode next = checkNodeAndNeighbour(this);
    HtmlView filteredHtml = getFilteredHtmlView();

    //String sum = "";
    Node nextImpl = (next == null) ? null : next.getImplNodelet();
    for (Text nodelet = first; nodelet != nextImpl && nodelet != null;
        nodelet = filteredHtml.getNextSibling(first).cast()) {
      //sum += nodelet.getData();
      if (nodelet != first) {
        getExtendedContext().editing().textNodeletAffected(
            nodelet, -1000, -1000, TextNodeChangeType.REMOVE);
        nodelet.removeFromParent();
      }
    }

    getExtendedContext().editing().textNodeletAffected(
        first, -1000, -1000, TextNodeChangeType.REPLACE_DATA);
    first.setData(getData());
  }
View Full Code Here


        // just browser DOM has been munged which we repair
        repairer.revert(Point.before(getRenderedContentView(), this), null);
      }
    }

    Text nodelet = getImplNodelet();
    getExtendedContext().editing().textNodeletAffected(
        nodelet, -1000, -1000, TextNodeChangeType.REPLACE_DATA);
    nodelet.setData(getData());
    return nodelet;
  }
View Full Code Here

    // 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);
View Full Code Here

   */
  public void somethingHappened(Point<Node> previousSelectionStart)
      throws HtmlMissing, HtmlInserted {
    Preconditions.checkNotNull(previousSelectionStart,
        "Typing extractor notified with null selection");
    Text node = previousSelectionStart.isInTextNode()
      ? previousSelectionStart.getContainer().<Text>cast()
      : null;

    // Attempt to associate our location with a node
    // This should be a last resort, ideally we should be given selections
    // in the correct text node, when the selection is at a text node boundary
    if (node == null) {
      HtmlView filteredHtml = filteredHtmlView;
      Node nodeBefore = Point.nodeBefore(filteredHtml, previousSelectionStart.asElementPoint());
      Node nodeAfter = previousSelectionStart.getNodeAfter();
      //TODO(danilatos): Usually we would want nodeBefore as a preference, but
      // not always...
      if (nodeBefore != null && DomHelper.isTextNode(nodeBefore)) {
        node = nodeBefore.cast();
        previousSelectionStart = Point.<Node>inText(node, 0);
      } else if (nodeAfter != null && DomHelper.isTextNode(nodeAfter)) {
        node = nodeAfter.cast();
        previousSelectionStart = Point.<Node>inText(node, node.getLength());
      }
    }

    TypingState t = findTypingState(previousSelectionStart);

View Full Code Here

    // If it's inserting text
    if (DomHelper.isTextNode(signal.getTarget()) &&
        (signal.getType().equals(BrowserEvents.DOMCharacterDataModified) ||
         signal.getType().equals(BrowserEvents.DOMNodeInserted))) {

      Text textNode = signal.getTarget().cast();
      if (textNode.getLength() > 0) {
        Node e = textNode.getPreviousSibling();
        if (e != null && !DomHelper.isTextNode(e)
            && e.<Element>cast().getTagName().toLowerCase().equals("a")) {

          FocusedPointRange<Node> selection =  editorInteractor.getHtmlSelection();
          if (selection.isCollapsed() && selection.getFocus().getTextOffset() == 0) {
View Full Code Here

    private boolean isPartOfThisState(Point<Node> point) {

      checkRangeIsValid();

      Text node = point.isInTextNode()
        ? point.getContainer().<Text>cast()
        : null;

      if (node == null) {
        // If we're not in a text node - i.e. we just started typing
View Full Code Here

     *   for text nodes, instead we'll assume they're new and part of this
     *   typing sequence.
     */
    private void startTypingSequence(Point.Tx<Node> previousSelectionStart)
        throws HtmlMissing, HtmlInserted {
      Text node = previousSelectionStart.getContainer().cast();
      ContentView renderedContent = renderedContentView;
      HtmlView filteredHtml = filteredHtmlView;
      try {
        // This might throw an exception
        ContentTextNode wrapper = manager.findTextWrapper(node, true);
View Full Code Here

        // Is this method slow? we need it often enough, but not in 95% of scenarios,
        // so there is room to optimise.

        // See if there are other text nodes we should check
        Text selNode = previousSelectionStart.getContainer().cast();
        int selOffset = previousSelectionStart.getTextOffset();

        // TODO(patcoleman): see if being zero here is actually a problem.
        // assert selNode.getLength() > 0;

        if (selOffset == 0 && firstWrapper.getImplNodelet() == selNode) {
          // if we are at beginning of mutating node
          ContentNode prev = renderedContent.getPreviousSibling(firstWrapper);
          if (prev != null && prev.isTextNode()) {
            firstWrapper = (ContentTextNode)prev;
          }
        } else {
          ContentNode nextNode = renderedContent.getNextSibling(lastWrapper);
          Node nextNodelet = nextNode != null ? nextNode.getImplNodelet() : null;
          if (selOffset == selNode.getLength() &&
              filteredHtml.getNextSibling(selNode) == nextNodelet) {
            // if we are at end of mutating node
            if (nextNode != null && nextNode.isTextNode()) {
              lastWrapper = (ContentTextNode)nextNode;
            }
View Full Code Here

    /**
     * @return The current value of the text in the html, within our tracked range
     */
    private String calculateNewValue() {
      HtmlView filteredHtml = filteredHtmlView;
      Text fromIncl = htmlRange.getStartNode(filteredHtml).cast();
      Node toExcl = htmlRange.getPointAfter().getNodeAfter();

      return ContentTextNode.sumTextNodes(fromIncl, toExcl, filteredHtml);
    }
View Full Code Here

      assert firstWrapper != null;

      if (partOfMutatingRange(point.getContainer())) {
        // TODO(danilatos): check for mutatingNodeOwns duplicates a loop which
        // is done in getOffset
        Text toFind = point.getContainer().<Text>cast();
        HtmlView filteredHtml = filteredHtmlView;

        return ContentTextNode.getOffset(
            toFind,
            htmlRange.getStartNode(filteredHtml).<Text>cast(),
View Full Code Here

TOP

Related Classes of com.google.gwt.dom.client.Text

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.