|
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.editor.CodeEditorFindAndReplaceTarget
public class CodeEditorFindAndReplaceTarget
A FindAndReplaceTarget
implementation for CodeEditor
.
Constructor Summary | |
---|---|
CodeEditorFindAndReplaceTarget(CodeEditor codeEditor)
|
Method Summary | |
---|---|
void |
adjustCurrentPosition(String searchingText,
boolean forward)
Adjusts current position according to searching text in the first attempt to search. |
void |
changedUpdate(DocumentEvent e)
|
CodeEditor |
getCodeEditor()
|
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. |
void |
insertUpdate(DocumentEvent e)
|
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 |
removeUpdate(DocumentEvent e)
|
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. |
protected void |
setTargetChanged(boolean targetChanged)
|
void |
showMessage(String message)
Shows a message. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CodeEditorFindAndReplaceTarget(CodeEditor codeEditor)
Method Detail |
---|
public FindResultIntepreter getIntepreter()
FindAndReplaceTarget
FindResult
.
CodeEditor
implements FindResultIntepreter.
getIntepreter
in interface FindAndReplaceTarget
public CodeEditor getCodeEditor()
public JComponent getConfigurationPanel()
FindAndReplaceTarget
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.
getConfigurationPanel
in interface FindAndReplaceTarget
public boolean hasNext()
FindAndReplaceTarget
hasNext
in interface FindAndReplaceTarget
public void next()
FindAndReplaceTarget
next
in interface FindAndReplaceTarget
public boolean hasPrevious()
FindAndReplaceTarget
hasPrevious
in interface FindAndReplaceTarget
public void previous()
FindAndReplaceTarget
previous
in interface FindAndReplaceTarget
public int getCurrentPosition(boolean forward)
FindAndReplaceTarget
getCurrentPosition
in interface FindAndReplaceTarget
forward
- true or false.
public void adjustCurrentPosition(String searchingText, boolean forward)
FindAndReplaceTarget
adjustCurrentPosition
in interface FindAndReplaceTarget
searchingText
- current searching textforward
- true or false.public void highlight(int start, int end)
FindAndReplaceTarget
highlight
in interface FindAndReplaceTarget
start
- the start offset of the text that is found.end
- the end offset of the text that is found.public void replace(int offset, int len, String str) throws BadLocationException
FindAndReplaceTarget
replace
in interface FindAndReplaceTarget
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 documentpublic Window getPromptDialogParent()
FindAndReplaceTarget
getPromptDialogParent
in interface FindAndReplaceTarget
public Point getPromptDialogLocation(Rectangle dialogBounds)
FindAndReplaceTarget
getPromptDialogLocation
in interface FindAndReplaceTarget
dialogBounds
- the bounds of the dialog before determining its location
public Point getPromptDialogLocation()
FindAndReplaceTarget
getPromptDialogLocation
in interface FindAndReplaceTarget
public void scrollToShowCaret(Rectangle promptDialogBounds)
FindAndReplaceTarget
scrollToShowCaret
in interface FindAndReplaceTarget
promptDialogBounds
- the prompt dialog boundspublic String getCurrentName()
FindAndReplaceTarget
getCurrentName
in interface FindAndReplaceTarget
public CharSequence getCurrentText()
FindAndReplaceTarget
getCurrentText
in interface FindAndReplaceTarget
public void showMessage(String message)
FindAndReplaceTarget
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.
showMessage
in interface FindAndReplaceTarget
message
- the messagepublic void replaceAllStarts()
FindAndReplaceTarget
replaceAllStarts
in interface FindAndReplaceTarget
public void replaceAllEnds()
FindAndReplaceTarget
replaceAllEnds
in interface FindAndReplaceTarget
protected void setTargetChanged(boolean targetChanged)
public boolean isTargetChanged()
FindAndReplaceTarget
isTargetChanged
in interface FindAndReplaceTarget
public void insertUpdate(DocumentEvent e)
insertUpdate
in interface DocumentListener
public void removeUpdate(DocumentEvent e)
removeUpdate
in interface DocumentListener
public void changedUpdate(DocumentEvent e)
changedUpdate
in interface DocumentListener
public String getResourceString(String key)
FindAndReplaceTarget
getResourceString
in interface FindAndReplaceTarget
key
- the resource key
public Locale getLocale()
FindAndReplaceTarget
getLocale
in interface FindAndReplaceTarget
|
JIDE 3.5.15 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |