Example usage for com.google.gwt.dom.client Range selectNode

List of usage examples for com.google.gwt.dom.client Range selectNode

Introduction

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

Prototype

public final native void selectNode(Node referenceNode) ;

Source Link

Usage

From source file:org.rstudio.core.client.dom.impl.DomUtilsStandardImpl.java

License:Open Source License

public String replaceSelection(Document document, String text) {
    if (!isSelectionInElement(document.getBody()))
        throw new IllegalStateException("Selection is not active");

    Range rng = getSelectionRange(NativeWindow.get(document), true);
    String orig = rng.toStringJs();
    rng.deleteContents();//  ww w  .  ja va2 s .co  m

    Text textNode = document.createTextNode(text);
    rng.insertNode(textNode);
    rng.selectNode(textNode);

    Selection.get(NativeWindow.get(document)).setRange(rng);

    return orig;
}

From source file:org.rstudio.core.client.dom.impl.DomUtilsStandardImpl.java

License:Open Source License

@Override
public void selectElement(Element el) {
    Document doc = el.getOwnerDocument();
    Range rng = Range.create(doc);
    rng.selectNode(el);
    Selection.get(NativeWindow.get(doc)).setRange(rng);
}