org.xwiki.gwt.dom.client
Interface Selection


public interface Selection

A selection object represents the ranges that the user has selected, or the cursor position when the user didn't select any range. It is the only was to get access to the current DOM nodes being edited with the WYSIWYG editor.

Version:
$Id: Selection.java 20042 2009-05-16 12:12:50Z sdumitriu $

Method Summary
 void addRange(Range range)
          Adds a range to this selection.
 void collapse(com.google.gwt.dom.client.Node parentNode, int offset)
          Collapses the selection to a single point, at the specified offset in the given DOM node.
 void collapseToEnd()
          Collapses the whole selection to a single point at the end of the current selection (irrespective of direction).
 void collapseToStart()
          Collapses the whole selection to a single point at the start of the current selection (irrespective of direction).
 boolean containsNode(com.google.gwt.dom.client.Node node, boolean partlyContained)
          Indicates whether the given node is part of the selection.
 void deleteFromDocument()
          Deletes this selection from document the nodes belong to.
 void extend(com.google.gwt.dom.client.Node parentNode, int offset)
          Extends the selection by moving the selection end to the specified node and offset, preserving the selection begin position.
 com.google.gwt.dom.client.Node getAnchorNode()
           
 int getAnchorOffset()
           
 com.google.gwt.dom.client.Node getFocusNode()
           
 int getFocusOffset()
           
 Range getRangeAt(int index)
           
 int getRangeCount()
           
 boolean isCollapsed()
           
 void removeAllRanges()
          Removes all ranges from the current selection.
 void removeRange(Range range)
          Removes the given range from the selection.
 void selectAllChildren(com.google.gwt.dom.client.Node parentNode)
          Adds all children of the specified node to the selection.
 void selectionLanguageChange(boolean langRTL)
          Modifies the cursor Bidi level after a change in keyboard direction.
 java.lang.String toString()
           
 

Method Detail

getAnchorNode

com.google.gwt.dom.client.Node getAnchorNode()
Returns:
the node in which the selection begins

getAnchorOffset

int getAnchorOffset()
Returns:
the offset within the getAnchorNode() where the selection begins

getFocusNode

com.google.gwt.dom.client.Node getFocusNode()
Returns:
the node in which the selection ends

getFocusOffset

int getFocusOffset()
Returns:
the offset within the getFocusNode() where the selection ends.

isCollapsed

boolean isCollapsed()
Returns:
true if the selection is collapsed

getRangeCount

int getRangeCount()
Returns:
the number of ranges in the selection

getRangeAt

Range getRangeAt(int index)
Parameters:
index - the index of the range to retrieve. Usually the selection contains just one range.
Returns:
the range at the specified index

collapse

void collapse(com.google.gwt.dom.client.Node parentNode,
              int offset)
Collapses the selection to a single point, at the specified offset in the given DOM node. When the selection is collapsed, and the content is focused and editable, the caret will blink there.

Parameters:
parentNode - the DOM node where the selection will be set
offset - specifies where to place the selection in the given node

extend

void extend(com.google.gwt.dom.client.Node parentNode,
            int offset)
Extends the selection by moving the selection end to the specified node and offset, preserving the selection begin position. The new selection end result will always be from the anchorNode to the new focusNode, regardless of direction.

Parameters:
parentNode - the node where the selection will be extended to
offset - specifies where to end the selection in the given node

collapseToStart

void collapseToStart()
Collapses the whole selection to a single point at the start of the current selection (irrespective of direction). If content is focused and editable, the caret will blink there.


collapseToEnd

void collapseToEnd()
Collapses the whole selection to a single point at the end of the current selection (irrespective of direction). If content is focused and editable, the caret will blink there.


containsNode

boolean containsNode(com.google.gwt.dom.client.Node node,
                     boolean partlyContained)
Indicates whether the given node is part of the selection.

Parameters:
node - the DOM node to be tested
partlyContained - if false, the entire subtree rooted in the given node is tested
Returns:
true when the entire node is part of the selection

selectAllChildren

void selectAllChildren(com.google.gwt.dom.client.Node parentNode)
Adds all children of the specified node to the selection. Previous selection is lost.

Parameters:
parentNode - the parent of the children to be added to the selection

addRange

void addRange(Range range)
Adds a range to this selection.

Parameters:
range - the range to be added

removeRange

void removeRange(Range range)
Removes the given range from the selection.

Parameters:
range - the range to be removed from the selection.

removeAllRanges

void removeAllRanges()
Removes all ranges from the current selection.


deleteFromDocument

void deleteFromDocument()
Deletes this selection from document the nodes belong to.


selectionLanguageChange

void selectionLanguageChange(boolean langRTL)
Modifies the cursor Bidi level after a change in keyboard direction.

Parameters:
langRTL - is true if the new language is right-to-left or false if the new language is left-to-right

toString

java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the currently selected text


Copyright © 2004-2010 XWiki. All Rights Reserved.