Package com.google.gwt.dom.client

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


    // or null if no such element
    Node nodeletBeforeTextNodes;
    ContentNode wrapperBeforeTextNodes;

    // Our cursors
    Text current = target;
    ContentNode possibleOwnerNode;

    // Go leftwards to find the start of the text nodelet sequence
    for (nodeletBeforeTextNodes = filteredHtml.getPreviousSibling(target);
         nodeletBeforeTextNodes != null;
         nodeletBeforeTextNodes = filteredHtml.getPreviousSibling(nodeletBeforeTextNodes)) {
      Text maybeText = filteredHtml.asText(nodeletBeforeTextNodes);
      if (maybeText == null) {
        break;
      }
      current = maybeText;
    }
View Full Code Here


    if (elementPoint != null) {
      return elementPoint;
    }
    Element parent;
    Node nodeAfter;
    Text text = point.getContainer().cast();
    parent = text.getParentElement();
    int offset = point.getTextOffset();
    if (offset == 0) {
      nodeAfter = text;
    } else if (offset == text.getLength()) {
      nodeAfter = text.getNextSibling();
    } else {
      nodeAfter = text.splitText(offset);
    }
    return Point.inElement(parent, nodeAfter);
  }
View Full Code Here

  @SuppressWarnings("unchecked"// NOTE(zdwang): This is for (Point<Node>) action[1]
  public void run(TypingExtractor extractor, Object... actions) throws HtmlMissing, HtmlInserted {
    for (Object a : actions) {
      Object[] action = (Object[]) a;
      Point<Node> sel = getSelectionStart();
      Text txt = sel == null ? null : sel.getContainer().<Text>cast();
      Action type = (Action) action[0];
      switch (type) {
        case MOVE:
          //extractor.flush();
          setCaret((Point<Node>) action[1]);
          break;
        case TYPE:
          String typed = (String) action[1];
          extractor.somethingHappened(getSelectionStart());
          if (sel.isInTextNode()) {
            txt.insertData(sel.getTextOffset(), (String) action[1]);
            moveCaret(((String) action[1]).length());
          } else {
            txt = Document.get().createTextNode(typed);
            sel.getContainer().insertBefore(txt, sel.getNodeAfter());
            setCaret(Point.inText((Node)txt, typed.length()));
View Full Code Here

    }
  }

  private void deleteText(int amount) {
    Point<Node> sel = getSelectionStart();
    Text txt = sel == null ? null : sel.getContainer().<Text>cast();
    int startIndex = sel.getTextOffset(), len;
    while (amount > 0) {
      if (txt == null || !DomHelper.isTextNode(txt)) {
        throw new RuntimeException("Action ran off end of text node");
      }
      String data = txt.getData();
      int remainingInNode = data.length() - startIndex;
      if (remainingInNode >= amount) {
        len = amount;
      } else {
        len = remainingInNode;
      }
      txt.setData(data.substring(0, startIndex) + data.substring(startIndex + len));
      amount -= len;
      startIndex = 0;
      txt = htmlView.getNextSibling(txt).cast();
    }
    moveCaret(0);
View Full Code Here

        caret = Point.inText(caret.getNodeAfter(), 0);
      } else {
        throw new RuntimeException("Unimplemented/Invalid");
      }
    }
    Text nodelet = caret.getContainer().cast();
    int offset = caret.getTextOffset() + distance;
    while (offset < 0) {
      nodelet = htmlView.getPreviousSibling(nodelet).cast();
      if (nodelet == null || !DomHelper.isTextNode(nodelet)) {
        throw new RuntimeException("Action ran off end of text node");
      }
      offset += nodelet.getLength();
    }
    while (offset > nodelet.getLength()) {
      offset -= nodelet.getLength();
      nodelet = htmlView.getPreviousSibling(nodelet).cast();
      if (nodelet == null || !DomHelper.isTextNode(nodelet)) {
        throw new RuntimeException("Action ran off end of text node");
      }
    }
View Full Code Here

   protected void appendText(T wrapped, String data) {
      if (HasText.class.isInstance(wrapped)) {
         ((HasText) wrapped).setText(data);
      } else {
         Element element = getElement(wrapped);
         Text text = JsoUtils.newText(data, element.getOwnerDocument());
         element.appendChild(text);
      }
   }
View Full Code Here

   protected void appendElement(Element wrapped, Element child) {
      wrapped.appendChild(child);
   }

   protected void appendText(Element wrapped, String data) {
      Text text = JsoUtils.newText(data, wrapped.getOwnerDocument());
      wrapped.appendChild(text);
   }
View Full Code Here

  @Override
  public void setStart(final Selection selection, final SelectionEndPoint start) {
    Checker.notNull("parameter:selection", selection);
    Checker.notNull("parameter:start", start);

    final Text textNode = start.getTextNode();
    final int offset = start.getOffset();
    this.setStart0(selection, textNode, offset);
  }
View Full Code Here

  @Override
  public void setEnd(final Selection selection, final SelectionEndPoint end) {
    Checker.notNull("parameter:selection", selection);
    Checker.notNull("parameter:end", end);

    final Text textNode = end.getTextNode();
    final int offset = end.getOffset();
    this.setEnd0(selection, textNode, offset);
  }
View Full Code Here

  @Override
  protected void surround0(final Selection selection, final Element element) {
    // get child index of selection start textNode from its parent.
    final SelectionEndPoint selectionStart = this.getStart(selection);
    final Text textNode = selectionStart.getTextNode();
    final Element parentOfTextNode = JavaScript.getElement(textNode, PARENT_NODE);

    int insertIndex = 0;
    if (selectionStart.getOffset() > 0) {
      insertIndex = this.getChildIndexOfTextNode(textNode) + 1;
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.