本文整理匯總了Java中org.eclipse.jface.text.source.ISourceViewer.getTextWidget方法的典型用法代碼示例。如果您正苦於以下問題:Java ISourceViewer.getTextWidget方法的具體用法?Java ISourceViewer.getTextWidget怎麽用?Java ISourceViewer.getTextWidget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.source.ISourceViewer
的用法示例。
在下文中一共展示了ISourceViewer.getTextWidget方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: computeHighlightRange
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
/**
* Computes and returns the source reference that includes the caret and serves as provider for the
* outline pageModel selection and the editor range indication.
*
* @return the computed source reference
*/
public ISourceReference computeHighlightRange() {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null) return null;
StyledText styledText = sourceViewer.getTextWidget();
if (styledText == null) return null;
int caret = 0;
if (sourceViewer instanceof ITextViewerExtension5) {
ITextViewerExtension5 extension = (ITextViewerExtension5) sourceViewer;
caret = extension.widgetOffset2ModelOffset(styledText.getSelection().x);
} else {
int offset = sourceViewer.getVisibleRegion().getOffset();
caret = offset + styledText.getSelection().x;
}
PagePart part = getPagePartAt(caret, false);
return (ISourceReference) part;
}
示例2: draw
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
private void draw() {
XtextEditor editor = EditorUtils.getActiveXtextEditor();
if (editor != null && (hoveredElement != null || !selectedElements.isEmpty())) {
ISourceViewer isv = editor.getInternalSourceViewer();
styledText = isv.getTextWidget();
drawSelection();
} else {
clear();
}
}
示例3: getStyledText
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
/**
* Obtains the styled text of an editor.
* @param editor the editor
* @return the styled text of the editor
*/
public static StyledText getStyledText(IEditorPart editor) {
ISourceViewer viewer = getSourceViewer(editor);
if (viewer != null) {
return viewer.getTextWidget();
}
return null;
}
示例4: ensureColorsFetched
import org.eclipse.jface.text.source.ISourceViewer; //導入方法依賴的package包/類
private void ensureColorsFetched() {
if (bgColor == null || fgColor == null) {
ISourceViewer sourceViewer = getSourceViewer();
if (sourceViewer == null) {
return;
}
StyledText textWidget = sourceViewer.getTextWidget();
if (textWidget == null) {
return;
}
/*
* TODO ATR, 03.02.2017: there should be an easier approach to get
* editors back and foreground, without syncexec
*/
EclipseUtil.getSafeDisplay().syncExec(new Runnable() {
@Override
public void run() {
bgColor = ColorUtil.convertToHexColor(textWidget.getBackground());
fgColor = ColorUtil.convertToHexColor(textWidget.getForeground());
}
});
}
}
示例5: 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);
}