|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FindAndReplaceTarget
FindAndReplaceTarget
is the target that FindAndReplace
works on. Basically it abstracts all
the methods that FindAndReplace
needs in order to perform find and replace on anything.
FindAndReplaceTarget
can represent a piece of text, several pieces of text, a file, all files in the
same folder, or a list of files at any location. By default, we provide CodeEditorFindAndReplaceTarget for one
CodeEditor, CodeEditorSelectionFindAndReplaceTarget for the selection in a CodeEditor and
CodeEditorDocumentPaneFindAndReplaceTarget for all CodeEditor inside a DocumentPane.
Method Summary | |
---|---|
void |
adjustCurrentPosition(String searchingText,
boolean forward)
Adjusts current position according to searching text in the first attempt to search. |
JComponent |
getConfigurationPanel()
FindAndReplaceTarget can be added to FindAndReplacePanel so that user can configure it. |
String |
getCurrentName()
Gets the name of the target. |
int |
getCurrentPosition(boolean forward)
Gets the current position where the next search will start. |
CharSequence |
getCurrentText()
Gets the current text. |
FindResultIntepreter |
getIntepreter()
Gets the interpreter that can understand the start offset and end offset in a FindResult . |
Locale |
getLocale()
Gets the target's locale. |
Point |
getPromptDialogLocation()
Gets the default prompt dialog location without concerning the caret position. |
Point |
getPromptDialogLocation(Rectangle dialogBounds)
Gets the prompt dialog location. |
Window |
getPromptDialogParent()
Gets the window that can be used as the parent of the prompt dialog. |
String |
getResourceString(String key)
Gets resource string from target. |
boolean |
hasNext()
Checks if there is more chunk of text after the current text when FindAndReplace reaches the end of the current text when searching forward. |
boolean |
hasPrevious()
Checks if there is more chunk of text before the current text when FindAndReplace reaches the start of the current text when searching backward. |
void |
highlight(int start,
int end)
Highlights the text to indicate the text matches the searching criteria. |
boolean |
isTargetChanged()
Checks if the text in the target changes. |
void |
next()
Changes the current text to the next one. |
void |
previous()
Changes the current text to the previous one. |
void |
replace(int offset,
int len,
String str)
Replaces some text with the new text. |
void |
replaceAllEnds()
Replace all ends. |
void |
replaceAllStarts()
Replace all starts. |
void |
scrollToShowCaret(Rectangle promptDialogBounds)
Scrolls to show caret. |
void |
showMessage(String message)
Shows a message. |
Method Detail |
---|
JComponent getConfigurationPanel()
FindAndReplaceTarget
can be added to FindAndReplacePanel
so that user can configure it.
The panel returned from this method is the panel. FindAndReplacePanel
will add a radio button before
the configuration panel, so there is no need to have a radio button inside the panel. If there is nothing to
configure for this target, you just return a JLabel with the descriptive name. For example, something like new
JLabel("Selection") if the target is for the selected text in a CodeEditor.
FindAndReplacePanel
will arrange all configuration panels vertically, so you should make sure the
configuration panel are arranged horizontally (very wide instead very tall) so that the overall appearance looks
good. If for whatever reason you have to make the configuration very tall, you may need to override FindAndReplacePanel.createTargetPanel()
method so that you can do the layout of the configuration panels
yourself.
String getCurrentName()
CharSequence getCurrentText()
int getCurrentPosition(boolean forward)
forward
- true or false.
void adjustCurrentPosition(String searchingText, boolean forward)
searchingText
- current searching textforward
- true or false.void highlight(int start, int end)
start
- the start offset of the text that is found.end
- the end offset of the text that is found.void replace(int offset, int len, String str) throws BadLocationException
offset
- the offset from the beginning.len
- the number of characters to be replaced.str
- the new text to replace the old text.
BadLocationException
- if the given offset is not a valid position within the documentvoid replaceAllStarts()
void replaceAllEnds()
Window getPromptDialogParent()
Point getPromptDialogLocation(Rectangle dialogBounds)
dialogBounds
- the bounds of the dialog before determining its location
Point getPromptDialogLocation()
void scrollToShowCaret(Rectangle promptDialogBounds)
promptDialogBounds
- the prompt dialog boundsvoid showMessage(String message)
FindAndReplace
needs to provide some feedback to user. It will call this method to
show user a message. It's up to you how to implement it. In CodeEditor, we use a JidePopup to display a
tooltip-like popup near the caret. You can display a message in your status bar if you want.
message
- the messageboolean hasNext()
void next()
boolean hasPrevious()
void previous()
FindResultIntepreter getIntepreter()
FindResult
.
CodeEditor
implements FindResultIntepreter.
boolean isTargetChanged()
String getResourceString(String key)
key
- the resource key
Locale getLocale()
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |