Java Examples for org.w3c.dom.ranges.DocumentRange

The following java examples will help you to understand the usage of org.w3c.dom.ranges.DocumentRange. These source code samples are taken from different open source projects.

Example 1
Project: org.eclipse.ecr-master  File: ConfigurationDescriptorImpl.java View source code
public DocumentFragment getFragment() {
    element.normalize();
    Node node = element.getFirstChild();
    if (node == null) {
        return null;
    }
    Range range = ((DocumentRange) element.getOwnerDocument()).createRange();
    range.setStartBefore(node);
    range.setEndAfter(element.getLastChild());
    return range.cloneContents();
}
Example 2
Project: nuxeo-common-master  File: DOMSerializer.java View source code
public static DocumentFragment getContentAsFragment(Element element) {
    Node node = element.getFirstChild();
    if (node == null) {
        // no content
        return null;
    }
    Range range = ((DocumentRange) element.getOwnerDocument()).createRange();
    range.setStartBefore(node);
    range.setEndAfter(element.getLastChild());
    return range.cloneContents();
}
Example 3
Project: ambra-master  File: SelectionRangeListTest.java View source code
public void addRegion(Location location, Object userData) {
    Range range;
    if (location.getType() == Location.RANGE)
        range = (Range) location.getLocation();
    else {
        range = ((DocumentRange) document).createRange();
        range.selectNode((Node) location.getLocation());
    }
    // Ignore it if this range is collapsed (ie. start == end)
    if (!range.getCollapsed())
        insert(new SelectionRange(range, userData));
}
Example 4
Project: flyingsaucer-master  File: SelectionHighlighter.java View source code
private boolean checkDocument() {
    while (true) {
        if (this.document != panel.getDocument() || textInlineMap == null) {
            this.document = panel.getDocument();
            textInlineMap = null;
            this.dotInfo = null;
            this.markInfo = null;
            this.lastSelectionRange = null;
            try {
                this.docRange = (DocumentRange) panel.getDocument();
                this.docTraversal = (DocumentTraversal) panel.getDocument();
                if (this.document != null && this.createMaps()) {
                    return true;
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    return false;
                }
            } catch (ClassCastException cce) {
                XRLog.layout(Level.WARNING, "Document instance cannot create ranges: no selection possible");
                return false;
            }
        }
        return true;
    }
}
Example 5
Project: nuxeo-tycho-osgi-master  File: DOMSerializer.java View source code
public static DocumentFragment getContentAsFragment(Element element) {
    Node node = element.getFirstChild();
    if (node == null) {
        // no content
        return null;
    }
    Range range = ((DocumentRange) element.getOwnerDocument()).createRange();
    range.setStartBefore(node);
    range.setEndAfter(element.getLastChild());
    return range.cloneContents();
}
Example 6
Project: nuxeo-master  File: DOMSerializer.java View source code
public static DocumentFragment getContentAsFragment(Element element) {
    Node node = element.getFirstChild();
    if (node == null) {
        // no content
        return null;
    }
    Range range = ((DocumentRange) element.getOwnerDocument()).createRange();
    range.setStartBefore(node);
    range.setEndAfter(element.getLastChild());
    return range.cloneContents();
}
Example 7
Project: lightreports-master  File: SelectionHighlighter.java View source code
private boolean checkDocument() {
    while (true) {
        if (this.document != panel.getDocument() || textInlineMap == null) {
            this.document = panel.getDocument();
            textInlineMap = null;
            this.dotInfo = null;
            this.markInfo = null;
            this.lastSelectionRange = null;
            try {
                this.docRange = (DocumentRange) panel.getDocument();
                this.docTraversal = (DocumentTraversal) panel.getDocument();
                if (this.document != null && this.createMaps()) {
                    return true;
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    return false;
                }
            } catch (ClassCastException cce) {
                XRLog.layout(Level.WARNING, "Document instance cannot create ranges: no selection possible");
                return false;
            }
        }
        return true;
    }
}
Example 8
Project: flyingsaucer-old-master  File: SelectionHighlighter.java View source code
private boolean checkDocument() {
    while (true) {
        if (this.document != panel.getDocument() || textInlineMap == null) {
            this.document = panel.getDocument();
            textInlineMap = null;
            this.dotInfo = null;
            this.markInfo = null;
            this.lastSelectionRange = null;
            try {
                this.docRange = (DocumentRange) panel.getDocument();
                this.docTraversal = (DocumentTraversal) panel.getDocument();
                if (this.document != null && this.createMaps()) {
                    return true;
                }
                try {
                    Thread.sleep(10);
                } catch (InterruptedException e) {
                    return false;
                }
            } catch (ClassCastException cce) {
                XRLog.layout(Level.WARNING, "Document instance cannot create ranges: no selection possible");
                return false;
            }
        }
        return true;
    }
}