本文整理匯總了Java中org.eclipse.jface.text.source.ISourceViewer.revealRange方法的典型用法代碼示例。如果您正苦於以下問題:Java ISourceViewer.revealRange方法的具體用法?Java ISourceViewer.revealRange怎麽用?Java ISourceViewer.revealRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.source.ISourceViewer
的用法示例。
在下文中一共展示了ISourceViewer.revealRange方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: run
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public void run(IAction action) {
if (targetEditor == null) return;
ISourceViewer sourceViewer= targetEditor.getViewer();
IDocument document= sourceViewer.getDocument();
if (document == null)
return;
ITextSelection selection = (ITextSelection) targetEditor.getSelectionProvider().getSelection();
SubStatusLineManager slm =
(SubStatusLineManager) targetEditor.getEditorSite().getActionBars().getStatusLineManager();
int selectionLength= Math.abs(selection.getLength());
if (selectionLength > 1) {
slm.setErrorMessage(TexlipsePlugin.getResourceString("gotoMatchingBracketNotSelected"));
slm.setVisible(true);
sourceViewer.getTextWidget().getDisplay().beep();
return;
}
int sourceCaretOffset= selection.getOffset() + selection.getLength();
TexPairMatcher fBracketMatcher = new TexPairMatcher("{}[]()");
IRegion region= fBracketMatcher.match(document, sourceCaretOffset);
if (region == null) {
slm.setErrorMessage(TexlipsePlugin.getResourceString("gotoMatchingBracketNotFound"));
slm.setVisible(true);
sourceViewer.getTextWidget().getDisplay().beep();
return;
}
int offset= region.getOffset();
int length= region.getLength();
if (length < 1) return;
int anchor = fBracketMatcher.getAnchor();
int targetOffset= (ICharacterPairMatcher.RIGHT == anchor) ? offset + 1: offset + length;
if (selection.getLength() < 0)
targetOffset -= selection.getLength();
sourceViewer.setSelectedRange(targetOffset, selection.getLength());
sourceViewer.revealRange(targetOffset, selection.getLength());
}