|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Clients may implement the StyledTextContent interface to provide a custom store for the StyledText widget content. The StyledText widget interacts with its StyledTextContent in order to access and update the text that is being displayed and edited in the widget. A custom content implementation can be set in the widget using the StyledText.setContent API.
Method Summary | |
void | addTextChangeListener(TextChangeListener listener)
Called by StyledText to add itself as an Observer to content changes. |
int | getCharCount()
Return the number of characters in the content. |
String | getLine(int lineIndex)
Return the line at the given line index without delimiters. |
int | getLineAtOffset(int offset)
Return the line index at the given character offset. |
int | getLineCount()
Return the number of lines. |
String | getLineDelimiter()
Return the line delimiter that should be used by the StyledText widget when inserting new lines. |
int | getOffsetAtLine(int lineIndex)
Return the character offset of the first character of the given line. |
String | getTextRange(int start,
int length)
Returns a string representing the content at the given range. |
void | removeTextChangeListener(TextChangeListener listener)
Remove the specified text changed listener. |
void | replaceTextRange(int start,
int replaceLength,
String text)
Replace the text with "newText" starting at position "start" for a length of "replaceLength". |
void | setText(String text)
Set text to "text". |
Method Detail |
public void addTextChangeListener(TextChangeListener listener)
public int getCharCount()
public String getLine(int lineIndex)
public int getLineAtOffset(int offset)
public int getLineCount()
public String getLineDelimiter()
public int getOffsetAtLine(int lineIndex)
NOTE: When there is no text (i.e., no lines), getOffsetAtLine(0) is a valid call that should return 0.
public String getTextRange(int start, int length)
public void removeTextChangeListener(TextChangeListener listener)
public void replaceTextRange(int start, int replaceLength, String text)
Implementors have to notify the TextChangeListeners that were added using addTextChangeListener before and after the content is changed. A TextChangingEvent has to be sent to the textChanging method before the content is changed and a TextChangedEvent has to be sent to the textChanged method after the content has changed. The text change that occurs after the TextChangingEvent has been sent has to be consistent with the data provided in the TextChangingEvent. This data will be cached by the widget and will be used when the TextChangedEvent is received.
The TextChangingEvent should be set as follows:
NOTE: newLineCount is the number of inserted lines and replaceLineCount is the number of deleted lines based on the change that occurs visually. For example:
public void setText(String text)
|
Eclipse Platform Release 3.0 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp. and others 2000, 2004. All rights reserved.