use of org.eclipse.jface.text.IFindReplaceTargetExtension in project cubrid-manager by CUBRID.
the class TextEditorFindReplaceMediator method findAndSelect.
/**
* Find and select the searched string
*
* @param start start position.
* @param isWrap is warp search.
* @param isForward is forward
* @return the location of string.
*/
public static int findAndSelect(int start, boolean isForward, FindReplaceOption option) {
TextViewer st = getCurrentTextEditor();
if (st == null) {
return -1;
}
IFindReplaceTargetExtension findReplace = getFindAndReplaceInterface1();
if (findReplace == null) {
return -1;
}
if (option.isSearchAll()) {
findReplace.setScope(null);
} else {
findReplace.setScope(new Region(st.getSelectedRange().x, st.getSelectedRange().y));
}
int widgetOffset = start >= 0 ? start : st.getTextWidget().getCaretOffset();
widgetOffset = isForward ? widgetOffset : (widgetOffset - option.getSearchedStr().length() - 1);
IFindReplaceTargetExtension3 target = getFindAndReplaceInterface2();
if (target == null) {
return -1;
}
int result = target.findAndSelect(widgetOffset, option.getSearchedStr(), isForward, option.isCaseSensitive(), option.isWholeWord(), option.isRegularExpressions());
if (result < 0 && option.isWrapSearch()) {
result = target.findAndSelect(isForward ? 0 : st.getTextWidget().getText().length() - 1, option.getSearchedStr(), isForward, option.isCaseSensitive(), option.isWholeWord(), option.isRegularExpressions());
}
return result;
}
Aggregations