本文整理汇总了Java中org.eclipse.jface.text.IFindReplaceTarget类的典型用法代码示例。如果您正苦于以下问题:Java IFindReplaceTarget类的具体用法?Java IFindReplaceTarget怎么用?Java IFindReplaceTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IFindReplaceTarget类属于org.eclipse.jface.text包,在下文中一共展示了IFindReplaceTarget类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: open
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
public void open()
{
try
{
final IFileStore store = EFS.getStore(document);
// Now open an editor to this file (and highlight the occurrence if possible)
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart part = IDE.openEditorOnFileStore(page, store);
// Now select the occurrence if we can
IFindReplaceTarget target = (IFindReplaceTarget) part.getAdapter(IFindReplaceTarget.class);
if (target != null && target.canPerformFind())
{
target.findAndSelect(0, searchString, true, caseSensitive, wholeWord);
}
}
catch (Exception e)
{
IdeLog.logError(CommonEditorPlugin.getDefault(), e);
}
}
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:21,代码来源:EditorSearchHyperlink.java
示例2: findNext
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
/**
* Find the next occurrence of empty line(s)
* Will match all valid lines except single ^$
*
* @param editor
* @param forward true if moving forward
* @return -1 if not found, else offset of match in widget coords
*/
protected int findNext(ITextEditor editor, boolean forward) {
IFindReplaceTarget frt = getTarget(editor);
Point selection = frt.getSelection();
// don't move past eob
int offset = Math.min(MarkUtils.getCharCount(editor), Math.max(0,MarkUtils.getCaretOffset(editor) + (forward ? 1 : -2)));
int result = ((IFindReplaceTargetExtension3)frt).findAndSelect(offset, PARAGRAPH_START, forward, false, false, true);
if (result != -1) {
if ((forward && offset > result) || (!forward && offset < result)) {
// reset if we've wrapped around in the search
MarkUtils.setWidgetSelection(editor, selection.x, selection.x + selection.y);
result = -1;
}
}
return result;
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:25,代码来源:ParagraphHandler.java
示例3: findTarget
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
/**
* Refine target search to not proceed beyond a region limit, if present
*
* @see com.mulgasoft.emacsplus.minibuffer.SearchMinibuffer#findTarget(org.eclipse.jface.text.IFindReplaceTarget, java.lang.String, int, boolean)
*/
protected int findTarget(IFindReplaceTarget target, String searchStr, int searchIndex, boolean forward) {
int result = WRAP_INDEX;
StyledText text = getTextWidget();
try {
text.setRedraw(false);
result = super.findTarget(target,searchStr,searchIndex,forward);
// if present, check if we've gone past the end of the region
if (getLimit() != WRAP_INDEX && result != WRAP_INDEX) {
int pos = MarkUtils.widget2ModelOffset(getViewer(), result);
// include length of search result in check
if (pos + target.getSelection().y > getLimit()) {
result = WRAP_INDEX;
// restore last position the region
setSelection(searchIndex);
}
}
} finally {
text.setRedraw(true);
}
return result;
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:27,代码来源:SearchReplaceMinibuffer.java
示例4: getAdapter
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
/**
* makes shure that the correct find/replace target is returned.
* the actual viewer is returned if an adapter of type
* FindReplaceTarget is searched
*/
@SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) {
Object object = super.getAdapter(adapter);
if(object != null) {
return object;
}
if(adapter.equals(IFindReplaceTarget.class)) {
return viewer.getActualViewer().getFindReplaceTarget();
}
return null;
}
开发者ID:anb0s,项目名称:LogViewer,代码行数:17,代码来源:LogViewer.java
示例5: resetScope
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
void resetScope()
{
scope = null;
IFindReplaceTarget findReplaceTarget = (IFindReplaceTarget) textEditor.getAdapter(IFindReplaceTarget.class);
if (findReplaceTarget instanceof IFindReplaceTargetExtension)
{
((IFindReplaceTargetExtension) findReplaceTarget).endSession();
}
}
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:10,代码来源:FindBarFinder.java
示例6: caseReplace
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
/**
* Case-based replacement - after the initial find has already happened
*
* @param replacer - the replacement string (may be regexp)
* @param index - offset of find
* @param all - all if true, else initial
* @return - the replacement region
*
* @throws BadLocationException
*/
private IRegion caseReplace(String replacer, int index, boolean all) throws BadLocationException {
IRegion result = null;
IDocumentUndoManager undoer = DocumentUndoManagerRegistry.getDocumentUndoManager(getDocument());
try {
if (!isReplaceAll() && undoer != null) {
undoer.beginCompoundChange();
}
IFindReplaceTarget target = getTarget();
// first replace with (possible regexp) string
((IFindReplaceTargetExtension3)target).replaceSelection(replacer, isRegexp());
// adjust case of actual replacement string
replacer = target.getSelectionText();
String caseReplacer = replacer;
if (all) {
caseReplacer = caseReplacer.toUpperCase();
} else {
caseReplacer = caseReplacer.trim();
caseReplacer = Character.toUpperCase(caseReplacer.charAt(0)) +
caseReplacer.substring(1,caseReplacer.length()).toString();
// now update the replacement string with the re-cased part
caseReplacer = replacer.replaceFirst(replacer.trim(), caseReplacer);
}
int ind = target.findAndSelect(index, replacer, true, false, false);
if (ind > -1) {
target.replaceSelection(caseReplacer);
}
} finally {
if (!isReplaceAll() && undoer != null) {
undoer.endCompoundChange();
}
}
return result;
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:44,代码来源:SearchReplaceMinibuffer.java
示例7: getSelectionText
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
protected String getSelectionText() {
String result = null;
IFindReplaceTarget target = getTarget();
if (target != null) {
result = target.getSelectionText();
}
return result;
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:9,代码来源:SearchMinibuffer.java
示例8: getSelection
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
protected Point getSelection() {
Point result = null;
IFindReplaceTarget target = getTarget();
if (target != null) {
result = target.getSelection();
}
return result;
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:9,代码来源:SearchMinibuffer.java
示例9: getAdapter
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) {
if (IFindReplaceTarget.class.equals(adapter)) {
if (fFindReplaceTarget == null) {
fFindReplaceTarget = (textViewer == null ? null : textViewer.getFindReplaceTarget());
}
return fFindReplaceTarget;
}
return super.getAdapter(adapter);
}
开发者ID:agusevas,项目名称:logan,代码行数:13,代码来源:SearchResultView.java
示例10: getAdapter
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
@Override
@SuppressWarnings("rawtypes")
public Object getAdapter( Class required ) {
if ( required.equals(IFindReplaceTarget.class) ) {
return _i18nPage.getReplaceTarget();
}
return super.getAdapter(required);
}
开发者ID:allati,项目名称:eclipse-rbe,代码行数:9,代码来源:I18nPageEditor.java
示例11: getFindReplaceTarget
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
public IFindReplaceTarget getFindReplaceTarget() {
return originalTextViewer.getFindReplaceTarget();
}
开发者ID:gwt-plugins,项目名称:gwt-eclipse-plugin,代码行数:4,代码来源:DelegatingTextViewer.java
示例12: open
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
public void open()
{
AbstractThemeableEditor editor = getEditor();
if (editor != null)
{
// grab AST, making sure the file has been parsed
IParseNode ast = editor.getAST();
// assume no target identifier
JSIdentifierNode targetIdentifier = null;
// try to locate the target identifier in the AST
if (ast instanceof JSParseRootNode)
{
// collect all identifiers that match the search string
JSIdentifierCollector collector = new JSIdentifierCollector(searchString);
((JSParseRootNode) ast).accept(collector);
List<JSIdentifierNode> identifiers = collector.getIdentifiers();
// try to refine the selection based on link type
if (INVOCATION_TYPE.equals(getTypeLabel()))
{
for (JSIdentifierNode identifier : identifiers)
{
if (identifier.getParent().getNodeType() == IJSNodeTypes.FUNCTION)
{
targetIdentifier = identifier;
break;
}
}
}
// assume first item in list, as a fallback. This is only slightly better than performing a plain-text
// search
if (targetIdentifier == null && !CollectionsUtil.isEmpty(identifiers))
{
targetIdentifier = identifiers.get(0);
}
}
if (targetIdentifier != null)
{
// show the identifier we ended up with
editor.selectAndReveal(targetIdentifier.getStart(), targetIdentifier.getLength());
}
else
{
IFindReplaceTarget target = (IFindReplaceTarget) editor.getAdapter(IFindReplaceTarget.class);
if (target != null && target.canPerformFind())
{
// do a standard search (forward from 0 offset, case sensitive, whole word)
target.findAndSelect(0, searchString, true, true, true);
}
else
{
// as a last resort, show the editor. Not sure this will ever happen, but here just in case
editor.selectAndReveal(0, 0);
}
}
}
}
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:64,代码来源:JSSearchStringHyperlink.java
示例13: CopiedFromFindReplaceDialog
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
public CopiedFromFindReplaceDialog(IFindReplaceTarget target, IEditorStatusLine statusLineManager)
{
this.fTarget = target;
this.fStatusLineManager = statusLineManager;
}
开发者ID:apicloudcom,项目名称:APICloud-Studio,代码行数:7,代码来源:CopiedFromFindReplaceDialog.java
示例14: getFindReplaceTarget
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
@Override
public IFindReplaceTarget getFindReplaceTarget() {
return null;
}
开发者ID:aleksandr-m,项目名称:strutsclipse,代码行数:5,代码来源:MockTextViewer.java
示例15: getTarget
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
protected IFindReplaceTarget getTarget(ITextEditor editor) {
return (IFindReplaceTarget)editor.getAdapter(IFindReplaceTarget.class);
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:4,代码来源:ParagraphHandler.java
示例16: findNextEmpty
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
/**
* Find the next occurrence of empty line consisting of ^$
* Since findNext will find multiple sequential ^$'s, we only need find one
*
* @param editor
* @param forward
* @return offset of match in widget coords
*/
protected int findNextEmpty(ITextEditor editor, boolean forward) {
IFindReplaceTarget frt = getTarget(editor);
Point selection = frt.getSelection();
int count = MarkUtils.getCharCount(editor);
int coffset = MarkUtils.getCaretOffset(editor);
// don't move past EOB
int offset = Math.min(count,coffset + (forward ? 1 : -1)); //(forward ? selection.x + selection.y+1 : selection.x-2);
int next = 0;
int prev = -1;
do {
next = ((IFindReplaceTargetExtension3)frt).findAndSelect(offset, REGEX_BOL_HACK, forward, false, false, true);
if (next == -1 || prev == next){
// we've run out of buffer
offset = (forward ? count : 0);
MarkUtils.setWidgetSelection(editor, offset, offset);
return offset;
} else if (forward && offset > next) {
// protect against overrun
MarkUtils.setWidgetSelection(editor, count, count);
return count;
} else if (!forward && offset < next) {
// protect against overrun
MarkUtils.setWidgetSelection(editor, 0, 0);
return 0;
} else {
selection = frt.getSelection();
// Eclipse internals (frda) return different regions depending on whether the file has a
// single or double line delimiter e.g. \r\n or \n. In the former it returns a 0 length
// region, and in the latter a length of 1
if (selection.y == 0 || (!forward && selection.x == 0)) {
// found it, or reached the top
return selection.x;
} if (selection.y == 1) {
// check for single line delimiter
char c = frt.getSelectionText().charAt(0);
if (c == '\n' || c == '\r'){
return selection.x;
}
}
// the widget count could change if a folded region expands automatically
count = MarkUtils.getCharCount(editor);
// don't move past EOB
offset = Math.min(count,(forward ? selection.x + selection.y+1 : selection.x-1));
prev = next;
}
} while (next != -1);
return next;
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:57,代码来源:ParagraphHandler.java
示例17: getTarget
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
protected IFindReplaceTarget getTarget() {
return (IFindReplaceTarget)getEditor().getAdapter(IFindReplaceTarget.class);
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:4,代码来源:WithMinibuffer.java
示例18: replaceIt
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
/**
* Perform one replacement
*
* @return the replacement index
*/
private boolean replaceIt() {
boolean result = false;
boolean forward = true;
if (!checkPaused()) {
findCount++;
try {
result = true;
int index = getSearchOffset();
IFindReplaceTarget target = getTarget();
int fpos = findTarget(target,getSearchStr(), index, forward);
if (fpos > -1) {
boolean initial = false;
boolean all = false;
String replacer = replaceStr;
if (!isCaseSensitive() && replacer.length() > 0) {
// Preserve case using the emacs definition
// - Preserving case means that if the string matched is all caps, or capitalized,
// then its replacement is upper cased or capitalized.)
String replacee = target.getSelectionText().trim();
if (replacee != null && replacee.length() > 0) {
initial = Character.isUpperCase(replacee.charAt(0));
all = initial;
if (initial) {
for (int i = 1; i < replacee.length(); i++) {
if (!Character.isUpperCase(replacee.charAt(i))) {
all = false;
break;
}
}
}
}
}
int adjust = 0;
if (all || initial) {
caseReplace(replacer,index,all);
} else {
if (isRegexLD()) {
adjust = replacer.length(); // prevents repetitious find of same EOL
// now we need the offset in model coords
ITextSelection sel = (ITextSelection)getEditor().getSelectionProvider().getSelection();
// use document 'insert' instead of broken target replace
getDocument().replace(sel.getOffset(),0,replacer);
// search uses cursor position - s/r is always forward
MarkUtils.setCursorOffset(getEditor(), sel.getOffset()+adjust);
} else {
((IFindReplaceTargetExtension3)target).replaceSelection(replacer, isRegexp());
}
}
Point p = target.getSelection();
int rIndex = p.x + p.y + adjust;
setSearchOffset(rIndex);
}
} catch (Exception e) {
setResultString(e.getLocalizedMessage(), true);
finish();
beep();
}
}
return result;
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:66,代码来源:SearchReplaceMinibuffer.java
示例19: findNext
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
/**
* Find the next instance of the search string in the buffer
*
* @param searchStr
* @param addit - true when just added text to search string
* @return true if we found a match
*/
protected boolean findNext(String searchStr,boolean addit) {
if (isSearchEnabled()) {
setRegexLD(false);
StyledText text = getTextWidget();
IFindReplaceTarget target = getTarget();
if (text != null && target != null) {
int searchIndex = getSearchOffset();
if (searchIndex != WRAP_INDEX) {
Point p = getSelection();
// if not building the string (or wrapping) search from caret position
if (!addit) {
if (isFound() && p != null) {
searchIndex = p.x;
if (isForward()) {
// increment index by (actual or implicit) selection width
searchIndex += (p.y == 0 ? getEol().length() : p.y);
}
} else {
// Cannot use target.getSelection since that does not return which side of the
// selection the caret is on.
searchIndex = text.getCaretOffset();
}
}
if (!forward && p != null) {
// if at beginning of line, back up by full eol, else just 1
searchIndex -= ((p.x == text.getOffsetAtLine(text.getLineAtOffset(p.x))) ? getEol().length() : 1);
}
}
int index = findTarget(target,searchStr,searchIndex, forward);
boolean justFound = (index != WRAP_INDEX);
if (isFound() && !justFound && (addit && !isRegexp())) {
beep();
} else if (!addit) {
setSearchOffset(index);
}
setFound(justFound);
}
}
return isFound();
}
开发者ID:MulgaSoft,项目名称:e4macs,代码行数:48,代码来源:SearchMinibuffer.java
示例20: getFindReplaceTarget
import org.eclipse.jface.text.IFindReplaceTarget; //导入依赖的package包/类
@Override
public IFindReplaceTarget getFindReplaceTarget() {
return viewer.getFindReplaceTarget();
}
开发者ID:fabioz,项目名称:Pydev,代码行数:5,代码来源:ScriptConsoleViewerWrapper.java
注:本文中的org.eclipse.jface.text.IFindReplaceTarget类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论