Example usage for com.google.gwt.dom.client Text getNextSibling

List of usage examples for com.google.gwt.dom.client Text getNextSibling

Introduction

In this page you can find the example usage for com.google.gwt.dom.client Text getNextSibling.

Prototype

@Override
    public Node getNextSibling() 

Source Link

Usage

From source file:org.waveprotocol.wave.client.editor.content.ContentTextNode.java

License:Apache License

/**
 * Splits and returns the second.//from   w  ww. j  av  a  2s . c  om
 * 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;
    }
}

From source file:org.waveprotocol.wave.client.editor.content.SelectionMaintainer.java

License:Apache License

/**
 * @see LowLevelEditingConcerns#textNodeletAffected(Text, int, int, TextNodeChangeType)
 *//*from w  w  w  .  j  ava 2 s .c  om*/
void textNodeletAffected(Text nodelet, int affectedAfterOffset, int insertionAmount,
        TextNodeChangeType changeType) {

    if (needToRestoreSelection == true) {
        return;
    }
    switch (changeType) {
    case DATA:
        if (!QuirksConstants.OK_SELECTION_ACROSS_TEXT_NODE_DATA_CHANGES
                && matchesSelectionTextNodes(nodelet, affectedAfterOffset)) {
            needToRestoreSelection = true;
        } else {
            maybeUpdateNodeOffsets(nodelet, affectedAfterOffset, nodelet, insertionAmount);
        }
        return;
    case SPLIT:
        if (matchesSelectionTextNodes(nodelet, affectedAfterOffset)) {
            if (!QuirksConstants.OK_SELECTION_ACROSS_TEXT_NODE_SPLITS) {
                needToRestoreSelection = true;
            } else {
                maybeUpdateNodeOffsets(nodelet, affectedAfterOffset, nodelet.getNextSibling().<Text>cast(),
                        -affectedAfterOffset);
            }
        }
        return;
    case REMOVE:
        if (!QuirksConstants.OK_SELECTION_ACROSS_NODE_REMOVALS && matchesSelectionTextNodes(nodelet)) {
            needToRestoreSelection = true;
        }
        return;
    case MOVE:
    case REPLACE_DATA:
        if (matchesSelectionTextNodes(nodelet)) {
            needToRestoreSelection = true;
        }
        return;
    }
}

From source file:org.waveprotocol.wave.client.editor.impl.NodeManager.java

License:Apache License

/**
 * Converts the given point to a parent-nodeAfter point, splitting a
 * text node if necessary.//from   w w  w .j  a  v a  2 s. c o  m
 *
 * @param point
 * @return a point at the same location, between node boundaries
 */
public static Point.El<Node> forceElementPoint(Point<Node> point) {
    Point.El<Node> elementPoint = point.asElementPoint();
    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);
}