本文整理汇总了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);
}