本文整理汇总了Java中org.eclipse.jface.text.ITextViewer.getTextWidget方法的典型用法代码示例。如果您正苦于以下问题:Java ITextViewer.getTextWidget方法的具体用法?Java ITextViewer.getTextWidget怎么用?Java ITextViewer.getTextWidget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jface.text.ITextViewer
的用法示例。
在下文中一共展示了ITextViewer.getTextWidget方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// create the widget's shell
Shell shell = new Shell();
shell.setLayout(new FillLayout());
shell.setSize(500, 500);
Display display = shell.getDisplay();
Composite parent = new Composite(shell, SWT.NONE);
parent.setLayout(new GridLayout(2, false));
ITextViewer textViewer = new TextViewer(parent, SWT.V_SCROLL | SWT.BORDER);
textViewer.setDocument(new Document(""));
StyledText styledText = textViewer.getTextWidget();
styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
ViewZoneChangeAccessor viewZones = new ViewZoneChangeAccessor(textViewer);
Button add = new Button(parent, SWT.NONE);
add.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 0, 0));
add.setText("Add Zone");
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
InputDialog dlg = new InputDialog(Display.getCurrent().getActiveShell(), "", "Enter view zone content",
"Zone " + viewZones.getSize(), null);
if (dlg.open() == Window.OK) {
int line = styledText.getLineAtOffset(styledText.getCaretOffset());
IViewZone zone = new DefaultViewZone(line, 20, dlg.getValue());
viewZones.addZone(zone);
viewZones.layoutZone(zone);
}
}
});
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
示例2: main
import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
// create the widget's shell
Shell shell = new Shell();
shell.setLayout(new FillLayout());
shell.setSize(500, 500);
Display display = shell.getDisplay();
Composite parent = new Composite(shell, SWT.NONE);
parent.setLayout(new GridLayout(2, false));
ITextViewer textViewer = new TextViewer(parent, SWT.V_SCROLL | SWT.BORDER);
String delim = textViewer.getTextWidget().getLineDelimiter();
textViewer.setDocument(new Document(delim + " class A" + delim + "new A" + delim + "new A" + delim + "class B"
+ delim + "new B" + delim + "interface I" + delim + "class C implements I"));
StyledText styledText = textViewer.getTextWidget();
styledText.setLayoutData(new GridData(GridData.FILL_BOTH));
CodeLensProviderRegistry registry = CodeLensProviderRegistry.getInstance();
registry.register(CONTENT_TYPE_ID, new ClassReferencesCodeLensProvider());
registry.register(CONTENT_TYPE_ID, new ClassImplementationsCodeLensProvider());
CodeLensStrategy codelens = new CodeLensStrategy(new DefaultCodeLensContext(textViewer), false);
codelens.addTarget(CONTENT_TYPE_ID).reconcile(null);
styledText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
codelens.reconcile(null);
}
});
shell.open();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
}
示例3: connect
import org.eclipse.jface.text.ITextViewer; //导入方法依赖的package包/类
private void connect() {
Assert.isNotNull(fCurrentTarget);
ITextViewer viewer = fCurrentTarget.getViewer();
Assert.isNotNull(viewer);
fCurrentTarget.fWidget = viewer.getTextWidget();
if (fCurrentTarget.fWidget == null)
leave(ILinkedModeListener.EXIT_ALL);
if (fCurrentTarget.fKeyListener == null) {
fCurrentTarget.fKeyListener = new KeyListener();
((ITextViewerExtension) viewer).prependVerifyKeyListener(fCurrentTarget.fKeyListener);
} else
fCurrentTarget.fKeyListener.setEnabled(true);
registerAutoEditVetoer(viewer);
((IPostSelectionProvider) viewer).addPostSelectionChangedListener(fSelectionListener);
createAnnotationModel();
showSelection();
fCurrentTarget.fShell = fCurrentTarget.fWidget.getShell();
if (fCurrentTarget.fShell == null)
leave(ILinkedModeListener.EXIT_ALL);
fCurrentTarget.fShell.addShellListener(fCloser);
fAssistant.install(viewer);
viewer.addTextInputListener(fCloser);
viewer.getDocument().addDocumentListener(fDocumentListener);
}