|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.jidesoft.search.FindAndReplace
public class FindAndReplace
FindAndReplace
is the class that does the find and replace feature in CodeEditor, or as a matter of
fact, anything that has a piece or several pieces of text.
FindAndReplaceDialog
. Each time CodeEditor
pops
up a FindAndReplaceDialog, CodeEditor
will retrieve previous settings stored in this class to configure
the dialog well. If you want to persist those settings between sessions, please invoke those methods, like
setForward(boolean)
/isForward()
, setUseRegex(boolean)
/isUseRegex()
, to load/save
those settings. Those settings include:
setUseRegex/isUseRegex
setFindHistory/getFindHistory
setFindText/getFindText
setReplaceText/getReplaceText
setReplaceHistory/getReplaceHistory
setUseWildcards/isUseWildcards
setUseRegexOrWildcards/isUseRegexOrWildcards
setMatchCase/isMatchCase
setMatchWholeWord/isMatchWholeWord
setOrigin/getOrigin
setReversed/isReversed
setShowFindAll/isShowFindAll
Field Summary | |
---|---|
protected Pattern |
_pattern
|
static FindResult |
EMPTY_RESULT
Empty result means that there is no matching any more to terminate the searching in current file. |
static int |
ORIGIN_ENTIRE
|
static int |
ORIGIN_FROM_CURSOR
|
static int |
SCOPE_GLOBAL
|
static int |
SCOPE_SELECTION
|
Constructor Summary | |
---|---|
FindAndReplace()
The constructor. |
Method Summary | |
---|---|
void |
addFindAndReplaceListener(FindAndReplaceListener FindAndReplaceListener)
Adds a listener. |
void |
addTarget(FindAndReplaceTarget target)
Adds FindAndReplaceTarget in use. |
protected FindResult |
findNext(Matcher m,
int startPosition)
Finds the next matching result from the start position with the matcher. |
protected void |
fireFindAndReplaceEvent(int status)
Fire FindAndReplaceEvents. |
protected void |
fireFindAndReplaceEvent(int status,
FindResult findResult)
Fire FindAndReplaceEvents. |
protected void |
fireFindAndReplaceEvent(int status,
FindResults findResults)
Fire FindAndReplaceEvents. |
protected void |
fireFindAndReplaceEvent(int status,
FindResult findResult,
String replaceString)
Fire FindAndReplaceEvents. |
protected void |
fireFindAndReplaceEvent(int status,
String fileName)
Fire FindAndReplaceEvents. |
protected void |
fireFindAndReplaceEvent(int status,
String fileName,
FindResults findResults)
Fire FindAndReplaceEvents. |
FindAndReplaceListener[] |
getFindAndReplaceListeners()
Gets the FindAndReplaceListeners register on this class. |
Vector<String> |
getFindHistory()
Gets the find history. |
String |
getFindText()
Gets the find text. |
protected int |
getFlags()
Gets searching flags. |
protected Matcher |
getMatcher()
Gets the matcher prepared for searching. |
int |
getOrigin()
Gets the origin. |
Vector<String> |
getReplaceHistory()
Gets the replace history. |
String |
getReplaceText()
Gets the replace text. |
int |
getScope()
Not implemented yet. |
FindAndReplaceTarget |
getTarget()
Gets current target in use. |
FindAndReplaceTarget[] |
getTargets()
Gets all possible FindAndReplaceTarget instances. |
protected void |
initialCharSequence()
Initialize the char sequence prepared for searching. |
boolean |
isForward()
Gets the flag indicating if the search is the same direction with isReversed() . |
boolean |
isMatchCase()
Gets the flag indicating if the search is case sensitive. |
boolean |
isMatchWholeWord()
Gets the flag indicating if only matching whole word. |
boolean |
isReplace()
Gets the flag indicating if the replace option is currently visible in the dialog. |
boolean |
isReversed()
Gets the flag indicating if the search is forward or backward. |
boolean |
isShowFindAll()
Gets the flag indicating if the "Find All" button should be visible. |
boolean |
isTargetChanged()
Gets the flag indicating if the target in use is just changed. |
boolean |
isUseRegex()
Sets the flag indicating if regex is to be used. |
boolean |
isUseRegexOrWildcards()
Gets the flag indicating Regex or wildcards is in use. |
boolean |
isUseWildcards()
Gets the flag indicating if wildcards are to be used. |
protected int |
promptForReplace()
Prompt a dialog for customer to choose if he/she needs replace the match or not. |
void |
removeFindAndReplaceListener(FindAndReplaceListener FindAndReplaceListener)
Removes a listener. |
void |
removeTarget(FindAndReplaceTarget target)
Removes FindAndReplaceTarget in use. |
int |
replace(FindResult findResult,
String replacement)
Process to replace the find result with the replacement |
void |
search()
Process searching. |
void |
search(Matcher m)
Process to search in the document. |
void |
searchAgain()
Process searching again. |
FindResults |
searchAll()
Process searching all. |
protected void |
searchFinished()
Process when search is finished. |
void |
setFindHistory(Vector<String> findHistory)
Sets the find history. |
void |
setFindText(String findText)
Sets the find text. |
void |
setForward(boolean forward)
Sets the flag indicating if the search is the same direction with isReversed() . |
void |
setMatchCase(boolean matchCase)
Sets the flag indicating if the search is case sensitive. |
void |
setMatchWholeWord(boolean matchWholeWord)
Sets the flag indicating if only matching whole word. |
void |
setOrigin(int origin)
Sets the origin. |
void |
setReplace(boolean replace)
Sets the flag indicating if the replace option is currently visible in the dialog. |
void |
setReplaceHistory(Vector<String> replaceHistory)
Sets the replace history. |
void |
setReplaceText(String replaceText)
Sets the replace text. |
void |
setReversed(boolean reversed)
Sets the flag indicating if the search is forward or backward. |
void |
setScope(int scope)
Not implemented yet. |
void |
setShowFindAll(boolean showFindAll)
Sets the flag indicating if the "Find All" button should be visible. |
void |
setTarget(FindAndReplaceTarget target)
Sets FindAndReplaceTarget in use. |
void |
setUseRegex(boolean useRegex)
Gets the flag indicating if regex is to be used. |
void |
setUseRegexOrWildcards(boolean useRegexOrWildcards)
Sets the flag indicating Regex or wildcards is in use. |
void |
setUseWildcards(boolean useWildcards)
Sets the flag indicating if wildcards are to be used. |
void |
textChanged()
Process when the search text is changed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int SCOPE_GLOBAL
public static final int SCOPE_SELECTION
public static final int ORIGIN_ENTIRE
public static final int ORIGIN_FROM_CURSOR
protected Pattern _pattern
public static FindResult EMPTY_RESULT
Constructor Detail |
---|
public FindAndReplace()
Method Detail |
---|
public FindAndReplaceTarget getTarget()
public void setTarget(FindAndReplaceTarget target)
target
- the FindAndReplaceTarget instancepublic void addTarget(FindAndReplaceTarget target)
target
- the FindAndReplaceTarget instancepublic void removeTarget(FindAndReplaceTarget target)
target
- the FindAndReplaceTarget instancepublic FindAndReplaceTarget[] getTargets()
public String getFindText()
public void setFindText(String findText)
findText
- the find textpublic String getReplaceText()
public void setReplaceText(String replaceText)
replaceText
- the replace textpublic Vector<String> getFindHistory()
public void setFindHistory(Vector<String> findHistory)
findHistory
- the find historypublic Vector<String> getReplaceHistory()
public void setReplaceHistory(Vector<String> replaceHistory)
replaceHistory
- the replace historypublic boolean isUseRegexOrWildcards()
public void setUseRegexOrWildcards(boolean useRegexOrWildcards)
useRegexOrWildcards
- the flagpublic boolean isUseWildcards()
public void setUseWildcards(boolean useWildcards)
useWildcards
- the flagpublic boolean isUseRegex()
public void setUseRegex(boolean useRegex)
useRegex
- the flagpublic boolean isMatchWholeWord()
public void setMatchWholeWord(boolean matchWholeWord)
matchWholeWord
- the flagpublic boolean isMatchCase()
public void setMatchCase(boolean matchCase)
matchCase
- the flagpublic int getScope()
public void setScope(int scope)
scope
- the scopepublic int getOrigin()
public void setOrigin(int origin)
origin
- the originpublic void searchAgain()
protected int getFlags()
protected Matcher getMatcher()
protected void initialCharSequence()
public void search()
public FindResults searchAll()
public void search(Matcher m)
m
- the matcherprotected int promptForReplace()
protected FindResult findNext(Matcher m, int startPosition)
m
- the matcherstartPosition
- the start position
EMPTY_RESULT
if nothing found.public int replace(FindResult findResult, String replacement)
findResult
- the find resultreplacement
- the string replacement
public void textChanged()
protected void searchFinished()
public boolean isForward()
isReversed()
.
This is a dynamic flag triggered by CodeEditor.findNext()
and CodeEditor.findPrevious()
.
In most cases, this flag is not supposed to be saved and loaded.
isReversed()
. Otherwise false.public void setForward(boolean forward)
isReversed()
.
forward
- the flagpublic boolean isReversed()
public void setReversed(boolean reversed)
reversed
- the flagpublic boolean isReplace()
public void setReplace(boolean replace)
replace
- the flagpublic boolean isShowFindAll()
public void setShowFindAll(boolean showFindAll)
showFindAll
- the flagpublic void addFindAndReplaceListener(FindAndReplaceListener FindAndReplaceListener)
FindAndReplaceListener
- the listenerpublic void removeFindAndReplaceListener(FindAndReplaceListener FindAndReplaceListener)
FindAndReplaceListener
- the listenerpublic FindAndReplaceListener[] getFindAndReplaceListeners()
protected void fireFindAndReplaceEvent(int status)
status
- the status to be firedprotected void fireFindAndReplaceEvent(int status, FindResults findResults)
status
- the status to be firedfindResults
- the find resultsprotected void fireFindAndReplaceEvent(int status, FindResult findResult)
status
- the status to be firedfindResult
- the find resultprotected void fireFindAndReplaceEvent(int status, FindResult findResult, String replaceString)
status
- the status to be firedfindResult
- the find resultreplaceString
- the replace stringprotected void fireFindAndReplaceEvent(int status, String fileName, FindResults findResults)
status
- the status to be firedfileName
- the file name to store the find resultsfindResults
- the find resultsprotected void fireFindAndReplaceEvent(int status, String fileName)
status
- the status to be firedfileName
- the file name to store the find resultspublic boolean isTargetChanged()
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |