JIDE 3.5.15

com.jidesoft.editor
Class CodeEditorSelectionFindAndReplaceTarget

java.lang.Object
  extended by com.jidesoft.editor.CodeEditorFindAndReplaceTarget
      extended by com.jidesoft.editor.CodeEditorSelectionFindAndReplaceTarget
All Implemented Interfaces:
SelectionListener, FindAndReplaceTarget, PropertyChangeListener, EventListener, DocumentListener

public class CodeEditorSelectionFindAndReplaceTarget
extends CodeEditorFindAndReplaceTarget
implements SelectionListener, PropertyChangeListener

A FindAndReplaceTarget implementation for the selection in CodeEditor.


Constructor Summary
CodeEditorSelectionFindAndReplaceTarget(CodeEditor codeEditor)
           
 
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.
 int getCurrentPosition(boolean forward)
          Gets the current position where the next search will start.
 CharSequence getCurrentText()
          Gets the current text.
 Color getHighlightColor()
          Gets the highlight color.
 boolean hasHighlight()
           
 void highlight(int start, int end)
          Highlights the text to indicate the text matches the searching criteria.
 void propertyChange(PropertyChangeEvent evt)
           
 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 selectionChanged(SelectionEvent e)
          Called when selection changed.
 void setHighlightColor(Color highlightColor)
          Changes the highlight color.
 
Methods inherited from class com.jidesoft.editor.CodeEditorFindAndReplaceTarget
changedUpdate, getCodeEditor, getCurrentName, getIntepreter, getLocale, getPromptDialogLocation, getPromptDialogLocation, getPromptDialogParent, getResourceString, hasNext, hasPrevious, insertUpdate, isTargetChanged, next, previous, removeUpdate, scrollToShowCaret, setTargetChanged, showMessage
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeEditorSelectionFindAndReplaceTarget

public CodeEditorSelectionFindAndReplaceTarget(CodeEditor codeEditor)
Method Detail

getHighlightColor

public Color getHighlightColor()
Gets the highlight color.

Returns:
the highlight color.

setHighlightColor

public void setHighlightColor(Color highlightColor)
Changes the highlight color.

Parameters:
highlightColor - the highlight color

getCurrentText

public CharSequence getCurrentText()
Description copied from interface: FindAndReplaceTarget
Gets the current text.

Specified by:
getCurrentText in interface FindAndReplaceTarget
Overrides:
getCurrentText in class CodeEditorFindAndReplaceTarget
Returns:
the current text.

getConfigurationPanel

public JComponent getConfigurationPanel()
Description copied from interface: 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.

Specified by:
getConfigurationPanel in interface FindAndReplaceTarget
Overrides:
getConfigurationPanel in class CodeEditorFindAndReplaceTarget
Returns:
the configuration panel.

hasHighlight

public boolean hasHighlight()

replace

public void replace(int offset,
                    int len,
                    String str)
             throws BadLocationException
Description copied from interface: FindAndReplaceTarget
Replaces some text with the new text. This method is used to replace the text.

Specified by:
replace in interface FindAndReplaceTarget
Overrides:
replace in class CodeEditorFindAndReplaceTarget
Parameters:
offset - the offset from the beginning.
len - the number of characters to be replaced.
str - the new text to replace the old text.
Throws:
BadLocationException - if the given offset is not a valid position within the document

adjustCurrentPosition

public void adjustCurrentPosition(String searchingText,
                                  boolean forward)
Description copied from interface: FindAndReplaceTarget
Adjusts current position according to searching text in the first attempt to search.

Specified by:
adjustCurrentPosition in interface FindAndReplaceTarget
Overrides:
adjustCurrentPosition in class CodeEditorFindAndReplaceTarget
Parameters:
searchingText - current searching text
forward - true or false.

highlight

public void highlight(int start,
                      int end)
Description copied from interface: FindAndReplaceTarget
Highlights the text to indicate the text matches the searching criteria.

Specified by:
highlight in interface FindAndReplaceTarget
Overrides:
highlight in class CodeEditorFindAndReplaceTarget
Parameters:
start - the start offset of the text that is found.
end - the end offset of the text that is found.

getCurrentPosition

public int getCurrentPosition(boolean forward)
Description copied from interface: FindAndReplaceTarget
Gets the current position where the next search will start. Usually in a CodeEditor, it will be the caret position.

Specified by:
getCurrentPosition in interface FindAndReplaceTarget
Overrides:
getCurrentPosition in class CodeEditorFindAndReplaceTarget
Parameters:
forward - true or false.
Returns:
the current position.

selectionChanged

public void selectionChanged(SelectionEvent e)
Description copied from interface: SelectionListener
Called when selection changed.

Specified by:
selectionChanged in interface SelectionListener

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

replaceAllStarts

public void replaceAllStarts()
Description copied from interface: FindAndReplaceTarget
Replace all starts. This is used by undo feature so that when undo this operation, it undoes all string that were replaced.

Specified by:
replaceAllStarts in interface FindAndReplaceTarget
Overrides:
replaceAllStarts in class CodeEditorFindAndReplaceTarget

replaceAllEnds

public void replaceAllEnds()
Description copied from interface: FindAndReplaceTarget
Replace all ends. This is used by undo feature so that when undo this operation, it undoes all string that were replaced.

Specified by:
replaceAllEnds in interface FindAndReplaceTarget
Overrides:
replaceAllEnds in class CodeEditorFindAndReplaceTarget

JIDE 3.5.15