当前位置: 首页>>代码示例>>Java>>正文


Java IFindReplaceTarget类代码示例

本文整理汇总了Java中org.eclipse.jface.text.IFindReplaceTarget的典型用法代码示例。如果您正苦于以下问题:Java IFindReplaceTarget类的具体用法?Java IFindReplaceTarget怎么用?Java IFindReplaceTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IFindReplaceTarget类属于org.eclipse.jface.text包,在下文中一共展示了IFindReplaceTarget类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.eclipse.jface.text.IFindReplaceTarget类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。