de.hunsicker.jalopy.plugin
Interface Editor


public interface Editor

Represents an editor view used to display and interactively modify the contents of a Java source file.

Version:
$Revision: 1.6 $
Author:
Marco Hunsicker

Method Summary
 void attachAnnotations(java.util.List annotations)
          Attaches the given annotations to this view.
 java.util.List detachAnnotations()
          Detaches all existing annotations of this view.
 int getCaretPosition()
          Returns the current location of the caret.
 int getColumn()
          Returns the column offset in the current line.
 ProjectFile getFile()
          Returns the file of the editor.
 int getLength()
          Returns the number of characters in the editor document.
 int getLine()
          Returns the current line number.
 java.lang.String getSelectedText()
          Returns the selected text contained in this editor.
 int getSelectionEnd()
          Returns the selected text's end position.
 int getSelectionStart()
          Returns the selected text's start position.
 java.lang.String getText()
          Returns the text contained in this editor.
 void paste(java.lang.String text)
          Replaces the currently selected content with new content represented by the given string.
 void requestFocus()
          Tries to set the focus on the receiving component.
 void selectAll()
          Selects the whole text of the editor.
 void setCaretPosition(int offset)
          Moves the caret to the given location.
 void setCaretPosition(int line, int column)
          Moves the caret to the given location.
 void setSelection(int startOffset, int endOffset)
          Selects the specified text.
 void setText(java.lang.String text)
          Sets the text of this editor to the specified text.
 

Method Detail

setCaretPosition

public void setCaretPosition(int offset)
Moves the caret to the given location.

Parameters:
offset - the text offset where the caret should be placed (absolute character position).
Throws:
java.lang.IllegalArgumentException - if offset < 0 || offset > getLength()

setCaretPosition

public void setCaretPosition(int line,
                             int column)
Moves the caret to the given location.

Parameters:
line - line number.
column - column offset in the given line.
Throws:
java.lang.IllegalArgumentException - if line < 1 || column < 1

getCaretPosition

public int getCaretPosition()
Returns the current location of the caret.

Returns:
current caret position (absolute character position, >= 0).

getColumn

public int getColumn()
Returns the column offset in the current line.

Returns:
current column offset (>= 1).

getFile

public ProjectFile getFile()
Returns the file of the editor.

Returns:
the file that has its contents displayed in the editor.

getLength

public int getLength()
Returns the number of characters in the editor document.

Returns:
the document length (>= 0).
Since:
1.0b8

getLine

public int getLine()
Returns the current line number.

Returns:
current line (>= 1).

getSelectedText

public java.lang.String getSelectedText()
Returns the selected text contained in this editor.

Returns:
selected text. If no text is selected or the document is empty, returns null.

setSelection

public void setSelection(int startOffset,
                         int endOffset)
Selects the specified text.

Parameters:
startOffset - the offset you wish to start selection on (absolute character position).
endOffset - the offset you wish to end selection on (absolute character position).
Throws:
java.lang.IllegalArgumentException - if startOffset < 0 || endOffset < 0

getSelectionEnd

public int getSelectionEnd()
Returns the selected text's end position.

Returns:
the selected text's end position (>=0). Returns 0 if the document is empty, or the position of the caret if there is no selection.

getSelectionStart

public int getSelectionStart()
Returns the selected text's start position.

Returns:
the start position (>=0). Returns 0 for an empty document, or the position of the caret if there is no selection.

setText

public void setText(java.lang.String text)
Sets the text of this editor to the specified text. If the text is null or empty, has the effect of simply deleting the old text.

Parameters:
text - the new text to be set.

getText

public java.lang.String getText()
Returns the text contained in this editor.

Returns:
the text.

attachAnnotations

public void attachAnnotations(java.util.List annotations)
Attaches the given annotations to this view.

Parameters:
annotations - list of annotations (of type <Annotation>) to attach.
Since:
1.0b9
See Also:
Annotation

detachAnnotations

public java.util.List detachAnnotations()
Detaches all existing annotations of this view.

Returns:
list with all annotations of this view (of type <Annotation>). Returns an empty list, if no annotations were attached.
Since:
1.0b9
See Also:
attachAnnotations(java.util.List)

paste

public void paste(java.lang.String text)
Replaces the currently selected content with new content represented by the given string. If there is no selection this amounts to an insert of the given text. If there is no replacement text this amounts to a removal of the current selection.

Parameters:
text - the string to replace the selection with.

requestFocus

public void requestFocus()
Tries to set the focus on the receiving component.


selectAll

public void selectAll()
Selects the whole text of the editor.



Copyright © 1997-2005 Jalopy. All Rights Reserved.