Oxygen XML Editor 16.1 Author API

ro.sync.exml.workspace.api.editor.page
Interface WSTextBasedEditorPage

All Superinterfaces:
WSEditorPage
All Known Subinterfaces:
AuthorEditorAccess, WSAuthorComponentEditorPage, WSAuthorEditorPage, WSAuthorEditorPageBase, WSTextEditorPage, WSXMLTextEditorPage

@API(type=NOT_EXTENDABLE,
     src=PUBLIC)
public interface WSTextBasedEditorPage
extends WSEditorPage

Provides access to methods related to the editor actions and information for the Text and Author pages.

Since:
11.2

Method Summary
 void deleteSelection()
          Delete the selected text, if any.
 int getCaretOffset()
          The current caret offset.
 Point getLocationOnScreenAsPoint(int x, int y)
          Take relative mouse coordinates and translate then to absolute on-screen coordinates.
 Point 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.
 java.lang.String getSelectedText()
          Get the selected text.
 int getSelectionEnd()
          Get selection end offset.
 int getSelectionStart()
          Get selection start offset.
 int[] getStartEndOffsets(DocumentPositionedInfo dpInfo)
          Find the start and end offsets that correspond to a document position information DocumentPositionedInfo.
 int[] getWordAtCaret()
          Compute the offsets of the word that contains the caret position.
 boolean hasSelection()
          Check if the editor page has a selection
 boolean isEditable()
          Check if the document can be edited.
 Rectangle modelToViewRectangle(int offset)
          Returns a representation of the caret shape for the specified document offset.
 void select(int startOffset, int endOffset)
          Select the interval between start and end offset.
 void selectWord()
          Select the word at caret, if any.
 void setCaretPosition(int offset)
          Move the caret to the specified offset.
 void setEditable(boolean editable)
          Sets the specified flag to indicate whether or not this page should be editable.
 int viewToModelOffset(int x, int y)
          Get the position in the document corresponding to the point in the editing component.
 

Method Detail

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

java.lang.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 offset
endOffset - 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

Point getLocationOnScreenAsPoint(int x,
                                 int y)
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

Point 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.

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

Rectangle modelToViewRectangle(int offset)
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.

setEditable

void setEditable(boolean editable)
Sets the specified flag to indicate whether or not this page should be editable.

Parameters:
editable - true if the page should be editable.
Since:
12.2

isEditable

boolean isEditable()
Check if the document can be edited. A document can be set as read-only from API, by using the setEditable(boolean) method.

Returns:
true if the document is editable.
Since:
14.1

getStartEndOffsets

int[] getStartEndOffsets(DocumentPositionedInfo dpInfo)
                         throws javax.swing.text.BadLocationException
Find the start and end offsets that correspond to a document position information DocumentPositionedInfo.

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:
javax.swing.text.BadLocationException - If the document position info does not correspond to a valid position in document.
Since:
14.1

Oxygen XML Editor 16.1 Author API

© Copyright SyncRO Soft SRL 2002 - 2014. All rights reserved.