Package com.google.gwt.dom.client

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


      return n.getChildNodes();
   }

   @PatchMethod
   static String getData(JavaScriptObject o) {
      Text text = o.cast();
      return text.getData();
   }
View Full Code Here


   @PatchMethod
   static void setNodeValue(JavaScriptObject jsObject, String nodeValue) {
      Node n = jsObject.cast();
      switch (n.getNodeType()) {
         case Node.TEXT_NODE:
            Text text = n.cast();
            text.setData(nodeValue);
            break;
         case Node.ELEMENT_NODE:
            Element element = n.cast();
            element.setInnerText(nodeValue);
            break;
View Full Code Here

      SpanElement span = (SpanElement) child0.getChild(0);
      assertEquals("", span.getId());
      assertEquals("spanClass", span.getClassName());
      assertEquals(1, span.getChildCount());
      assertEquals(Node.TEXT_NODE, span.getChild(0).getNodeType());
      Text text = span.getChild(0).cast();
      assertEquals("test", text.getData());
      assertEquals("test", span.getInnerText());

      BRElement br = (BRElement) parent1.getChild(1);
      assertEquals("", br.getId());
View Full Code Here

      JavaScriptObjects.setProperty(nodeList, NODE_LIST_INNER_LIST, innerList);
      return nodeList;
   }

   public static Text newText(String data, Document ownerDocument) {
      Text text = newNode(Node.TEXT_NODE).cast();
      JavaScriptObjects.setProperty(text, JsoProperties.NODE_OWNER_DOCUMENT, ownerDocument);
      text.setData(data);

      return text;
   }
View Full Code Here

   public void characters(char[] ch, int start, int length) throws SAXException {

      String string = String.valueOf(ch, start, length).replaceAll("\\u00A0", " ");

      if (string.length() > 0) {
         Text text = Document.get().createTextNode(string);

         if (currentNode != null) {
            currentNode.appendChild(text);
         } else {
            // root text node
View Full Code Here

    if (node == null) {
      logEndNotFound("node is null");
      return;
    }
    if (DomHelper.isTextNode(node)) {
      Text textNode = node.cast();
      String text = textNode.getData();
      if (!text.isEmpty()) {
        if (leading) {
          if (text.charAt(0) == MARKER_CHAR) {
            textNode.setData(text.substring(1));
          }
        } else {
          if (text.charAt(text.length() - 1) == MARKER_CHAR) {
            textNode.setData(text.substring(0, text.length() - 1));
          } else {
            logEndNotFound("last character is not marker");
          }
        }
      } else {
        logEndNotFound("text node is empty");
      }
      if (textNode.getData().isEmpty()) {
        parent.removeChild(textNode);
      }
    } else {
      // In some cases, Safari will put the marker inside of a div, so this
      // traverses down the left or right side of the tree to find it.
View Full Code Here

      // NOTE(user): There is an issue here. When findNodeletWihOffset causes a
      // repair, the data may get inserted twice. The repairer may set the DOM
      // node to reflect the updated content data (which already has the data
      // inseretd). Then, when insertData is called, the data is inserted again.
      findNodeletWithOffset(offset, nodeletOffsetOutput, getRepairer());
      Text nodelet = nodeletOffsetOutput.getNode().<Text>cast();
      int nodeletOffset = nodeletOffsetOutput.getOffset();
      nodelet.insertData(nodeletOffset, arg);
      getExtendedContext().editing().textNodeletAffected(
          nodelet, nodeletOffset, arg.length(), TextNodeChangeType.DATA);
    }
  }
View Full Code Here

        data.substring(offset + count, data.length()));

    if (affectImpl) {
      if (isImplAttached()) {
        findNodeletWithOffset(offset, nodeletOffsetOutput, getRepairer());
        Text nodelet = nodeletOffsetOutput.getNode().cast();
        int subOffset = nodeletOffsetOutput.getOffset();

        if (nodelet.getLength() - subOffset >= count) {
          // Handle the special case where the delete is in a single text nodelet
          // carefully, to avoid splitting it
          nodelet.deleteData(subOffset, count);
          getExtendedContext().editing().textNodeletAffected(
              nodelet, subOffset, -count, TextNodeChangeType.DATA);
        } else {
          // General case
          Node toExcl = implSplitText(offset + count);
View Full Code Here

      return this;
    } else if (offset >= getLength()) {
      return null;
    }

    Text nodelet = null;

    if (affectImpl) {
      nodelet = implSplitText(offset);
    } else {
      nodelet = Document.get().createTextNode("");
View Full Code Here

   * Splits and returns the second.
   * If split point at a node boundary, doesn't split, but returns the next nodelet.
   */
  private Text implSplitText(int offset) {
    findNodeletWithOffset(offset, nodeletOffsetOutput, getRepairer());
    Text text = nodeletOffsetOutput.getNode().<Text>cast();
    if (text.getLength() == nodeletOffsetOutput.getOffset()) {
      return text.getNextSibling().cast();
    } else if (nodeletOffsetOutput.getOffset() == 0) {
      return text;
    } else {
      int nodeletOffset = nodeletOffsetOutput.getOffset();
      Text ret = text.splitText(nodeletOffset);
      // -10000 because the number should be ignored in the splitText case,
      // so some large number to trigger an error if it is not ignored.
      getExtendedContext().editing().textNodeletAffected(
          text, nodeletOffset, -10000, TextNodeChangeType.SPLIT);
      return ret;
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.