@API(type=NOT_EXTENDABLE, src=PUBLIC) public interface WSTextBasedEditorPage extends WSEditorPage
Modifier and Type | Method and Description |
---|---|
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.
|
int getSelectionStart()
int getSelectionEnd()
java.lang.String getSelectedText()
int getCaretOffset()
void deleteSelection()
boolean hasSelection()
true
if there is a selection, false
otherwise.void selectWord()
void setCaretPosition(int offset)
offset
- The offset where the caret should be positioned, 0 based.void select(int startOffset, int endOffset)
startOffset
- Inclusive start offsetendOffset
- Exclusive end offsetint[] getWordAtCaret()
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.Point getLocationOnScreenAsPoint(int x, int y)
x
- The "x" coordinate relative to the viewport origin.y
- The "y" coordinate relative to the viewport origin.null
Point.Point getLocationRelativeToEditorFromScreen(int x, int y)
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.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.Rectangle modelToViewRectangle(int offset)
offset
- The document offset to get the corresponding caret shape for.null
Rectangle.int viewToModelOffset(int x, int y)
x
- The "x" coordinate relative to the editing component origin.y
- The "y" coordinate relative to the editing component origin.null
,
instead an undefined view to model info object is returned if a valid one could not be determined.void setEditable(boolean editable)
editable
- true
if the page should be editable.boolean isEditable()
setEditable(boolean)
method.true
if the document is editable.int[] getStartEndOffsets(DocumentPositionedInfo dpInfo) throws javax.swing.text.BadLocationException
DocumentPositionedInfo
.dpInfo
- The document position information.javax.swing.text.BadLocationException
- If the document position info does not correspond to a
valid position in document.© Copyright SyncRO Soft SRL 2002 - 2014. All rights reserved.