Interface WSTextBasedEditorPage
- All Superinterfaces:
WSEditorPage
- All Known Subinterfaces:
AuthorEditorAccess
,IWebappAuthorEditorAccess
,WSAuthorComponentEditorPage
,WSAuthorEditorPage
,WSAuthorEditorPageBase
,WSTextEditorPage
,WSXMLTextEditorPage
Provides access to methods related to the editor actions and information for
the Text and Author pages.
- Since:
- 11.2
-
Method Summary
Modifier and TypeMethodDescriptionvoid
copy()
Copy the selected content to clipboard.createAnchor
(int offset) Create an anchor at a certain offset in the content of this Text or Author editing mode.void
Delete the selected text, if any.int
The current caret offset.getLocationOnScreenAsPoint
(int x, int y) Take relative mouse coordinates and translate then to absolute on-screen coordinates.getLocationRelativeToEditorFromScreen
(int x, int y) Take mouse coordinates relative to the main application frame/display and translate then to coordinates relative to the editing area.int
getOffsetForAnchor
(Anchor anchor) Get the offset corresponding to an Anchor which was created either in this editing mode or in another editing mode/page.Get the selected text.int
Get selection end offset.int
Get selection start offset.int[]
Find the start and end offsets that correspond to a document position informationDocumentPositionedInfo
.int[]
Compute the offsets of the word that contains the caret position.boolean
Check if the editor page has a selectionmodelToViewRectangle
(int offset) Returns a representation of the caret shape for the specified document offset.void
Smart scroll so that the current caret position and some content around it becomes visible.void
select
(int startOffset, int endOffset) Select the interval between start and end offset.void
Select the word at caret, if any.void
setCaretPosition
(int offset) Move the caret to the specified offset.int
viewToModelOffset
(int x, int y) Get the position in the document corresponding to the point in the editing component.Methods inherited from interface ro.sync.exml.workspace.api.editor.page.WSEditorPage
getParentEditor, hasFocus, isEditable, requestFocus, setEditable, setReadOnly, setReadOnly
-
Method Details
-
getSelectionStart
int getSelectionStart()Get selection start offset. It is inclusive.- Returns:
- The selection start offset, 0 based.
-
getSelectionEnd
int getSelectionEnd()Get selection end offset. It is exclusive.- Returns:
- The selection end offset, 0 based.
-
getSelectedText
String getSelectedText()Get the selected text. The text does not contain XML tags for the Author page.- Returns:
- The selected text or an empty string if no selection is present.
-
getCaretOffset
int getCaretOffset()The current caret offset.- Returns:
- The caret offset, 0 based.
-
deleteSelection
void deleteSelection()Delete the selected text, if any. -
hasSelection
boolean hasSelection()Check if the editor page has a selection- Returns:
true
if there is a selection,false
otherwise.
-
selectWord
void selectWord()Select the word at caret, if any. -
setCaretPosition
void setCaretPosition(int offset) Move the caret to the specified offset.- Parameters:
offset
- The offset where the caret should be positioned, 0 based.
-
select
void select(int startOffset, int endOffset) Select the interval between start and end offset.- Parameters:
startOffset
- Inclusive start offsetendOffset
- Exclusive end offset
-
getWordAtCaret
int[] getWordAtCaret()Compute the offsets of the word that contains the caret position.- Returns:
- An array with the start and end offsets of the word at caret or
null
if the values couldn't be obtained. The start offset is inclusive and greater or equal than 1. The end offset is also inclusive and less or equal than the content length.
-
getLocationOnScreenAsPoint
Take relative mouse coordinates and translate then to absolute on-screen coordinates.- Parameters:
x
- The "x" coordinate relative to the viewport origin.y
- The "y" coordinate relative to the viewport origin.- Returns:
- A point with the "x" and "y" coordinates relative to the screen.
It does not return a
null
Point.
-
getLocationRelativeToEditorFromScreen
Take mouse coordinates relative to the main application frame/display and translate then to coordinates relative to the editing area.- Parameters:
x
- The "x" coordinate which is relative to the main application frame/display.y
- The "y" coordinate which is relative to the main application frame/display.- Returns:
- A point with the "x" and "y" coordinates relative to the editing component area.
It does not return a
null
Point. For example an Eclipse org.eclipse.swt.dnd.DropTargetEvent has the x and y coordinates relative to the Display. In order to use API like viewToModelOffset(), the coordinates need to be translated relative to the editing area. - Since:
- 14.2
-
modelToViewRectangle
Returns a representation of the caret shape for the specified document offset.- Parameters:
offset
- The document offset to get the corresponding caret shape for.- Returns:
- The caret rectangle shape. It does not return a
null
Rectangle.
-
viewToModelOffset
int viewToModelOffset(int x, int y) Get the position in the document corresponding to the point in the editing component.- Parameters:
x
- The "x" coordinate relative to the editing component origin.y
- The "y" coordinate relative to the editing component origin.- Returns:
- The offset corresponding to the given point. The method does not return
null
, instead an undefined view to model info object is returned if a valid one could not be determined.
-
getStartEndOffsets
Find the start and end offsets that correspond to a document position informationDocumentPositionedInfo
.- Parameters:
dpInfo
- The document position information.- Returns:
- an array of length two containing the start offset at index 0 and the end offset at index 1.
- Throws:
BadLocationException
- If the document position info does not correspond to a valid position in document.- Since:
- 14.1
-
createAnchor
Create an anchor at a certain offset in the content of this Text or Author editing mode. The anchor can later be used in the current or in another editing mode to identify an offset particular to it. For example you can create an anchor in the Author editing mode based on an Author-specific offset and then use it in the Text editing mode to identify a specific offset in the Text editing page. A previous created anchor will not be updated dynamically when changes are made in the document so using it later on will not guarantee that it will point exactly at the offset for which it was originally computed.- Parameters:
offset
- The offset in the edited content.- Returns:
- An implementation independent anchor which indicates to this offset. The anchor is not automatically updated when the content in the document changes.
- Throws:
BadLocationException
- When the offset is not valid.- Since:
- 21
-
getOffsetForAnchor
Get the offset corresponding to an Anchor which was created either in this editing mode or in another editing mode/page.- Parameters:
anchor
- The anchor.- Returns:
- The offset in this page's contents corresponding to the Anchor object.
- Throws:
BadLocationException
- When there are problems identifying the offset.- Since:
- 21
-
scrollCaretToVisible
void scrollCaretToVisible()Smart scroll so that the current caret position and some content around it becomes visible.- Since:
- 18
-
copy
void copy()Copy the selected content to clipboard. If there is no selection, this method does nothing.- Since:
- 27
*********************************
EXPERIMENTAL - Subject to change
********************************
Please note that this API is not marked as final and it can change in one of the next versions of the application. If you have suggestions, comments about it, please let us know.
-