Search in sources :

Example 1 with IFindReplaceTargetExtension3

use of org.eclipse.jface.text.IFindReplaceTargetExtension3 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;
}
Also used : IFindReplaceTargetExtension3(org.eclipse.jface.text.IFindReplaceTargetExtension3) Region(org.eclipse.jface.text.Region) IFindReplaceTargetExtension(org.eclipse.jface.text.IFindReplaceTargetExtension) TextViewer(org.eclipse.jface.text.TextViewer)

Aggregations

IFindReplaceTargetExtension (org.eclipse.jface.text.IFindReplaceTargetExtension)1 IFindReplaceTargetExtension3 (org.eclipse.jface.text.IFindReplaceTargetExtension3)1 Region (org.eclipse.jface.text.Region)1 TextViewer (org.eclipse.jface.text.TextViewer)1