本文整理匯總了Java中org.eclipse.jface.text.source.ISourceViewer.getSelectedRange方法的典型用法代碼示例。如果您正苦於以下問題:Java ISourceViewer.getSelectedRange方法的具體用法?Java ISourceViewer.getSelectedRange怎麽用?Java ISourceViewer.getSelectedRange使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.source.ISourceViewer
的用法示例。
在下文中一共展示了ISourceViewer.getSelectedRange方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getSignedSelection
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
protected final IRegion getSignedSelection(ISourceViewer sourceViewer) {
Point viewerSelection = sourceViewer.getSelectedRange();
StyledText text = sourceViewer.getTextWidget();
Point selection = text.getSelectionRange();
if (text.getCaretOffset() == selection.x) {
viewerSelection.x = viewerSelection.x + viewerSelection.y;
viewerSelection.y = -viewerSelection.y;
}
return new Region(viewerSelection.x, viewerSelection.y);
}
示例2: setFocusToElementId
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
public void setFocusToElementId(String elementId) {
File currentFile = getCurrentFile();
ISourceViewer viewer = this.getSourceViewer();
int previousOffset = viewer.getSelectedRange().x;
String nclText = viewer.getDocument().get();
NCLContentHandler nclContentHandler = new NCLContentHandler();
NCLDocument nclDocument = new NCLDocument();
nclDocument.setParentURI(currentFile.getParentFile().toURI());
nclContentHandler.setNclDocument(nclDocument);
NCLParser parser = new NCLParser();
parser.setContentHandler(nclContentHandler);
parser.doParse(nclText);
NCLElement el = nclDocument.getElementById(elementId);
int line = el.getLineNumber();
int lineOffset, lineLength;
try {
lineOffset = viewer.getDocument().getLineOffset(line);
lineLength = viewer.getDocument().getLineLength(line);
// Move cursor to new position
resetHighlightRange();
setHighlightRange(lineOffset, lineLength, true);
setFocus();
} catch (BadLocationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}