Java Code Examples for org.eclipse.swt.custom.StyledText#notifyListeners()

The following examples show how to use org.eclipse.swt.custom.StyledText#notifyListeners() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAutoEditTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void pressKey(XtextEditor editor, char c) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Event e = new Event();
	e.character = c;
	e.type = SWT.KeyDown;
	e.doit = true;
	//XXX Hack!
	if (c == SWT.ESC) {
		e.keyCode = 27;
	}
	textWidget.notifyListeners(SWT.KeyDown, e);
}
 
Example 2
Source File: AbstractAutoEditTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void pasteText(XtextEditor editor, String text) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Point selection = textWidget.getSelection();
	Event event = new Event();
	event.start = selection.x;
	event.end = selection.y;
	event.text = text;
	event.keyCode = KeyLookupFactory.getDefault().getCtrl();
	textWidget.notifyListeners(SWT.KeyDown, event);
	Method sendKeyEvent = textWidget.getClass().getDeclaredMethod("sendKeyEvent", Event.class);
	sendKeyEvent.setAccessible(true);
	sendKeyEvent.invoke(textWidget, event);
}
 
Example 3
Source File: AbstractLinkedEditingIntegrationTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void pressKey(XtextEditor editor, char c) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Event e = new Event();
	e.character = c;
	e.type = SWT.KeyDown;
	e.doit = true;
	//XXX Hack!
	if (c == SWT.ESC) {
		e.keyCode = 27;
	}
	textWidget.notifyListeners(SWT.KeyDown, e);
}
 
Example 4
Source File: AbstractAutoEditTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void pressKey(XtextEditor editor, char c) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Event e = new Event();
	e.character = c;
	e.type = SWT.KeyDown;
	e.doit = true;
	//XXX Hack!
	if (c == SWT.ESC) {
		e.keyCode = 27;
	}
	textWidget.notifyListeners(SWT.KeyDown, e);
}
 
Example 5
Source File: AbstractAutoEditTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void pasteText(XtextEditor editor, String text) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Point selection = textWidget.getSelection();
	Event event = new Event();
	event.start = selection.x;
	event.end = selection.y;
	event.text = text;
	event.keyCode = KeyLookupFactory.getDefault().getCtrl();
	textWidget.notifyListeners(SWT.KeyDown, event);
	Method sendKeyEvent = textWidget.getClass().getDeclaredMethod("sendKeyEvent", Event.class);
	sendKeyEvent.setAccessible(true);
	sendKeyEvent.invoke(textWidget, event);
}
 
Example 6
Source File: AbstractLinkedEditingIntegrationTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected void pressKey(XtextEditor editor, char c) throws Exception {
	StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
	Event e = new Event();
	e.character = c;
	e.type = SWT.KeyDown;
	e.doit = true;
	//XXX Hack!
	if (c == SWT.ESC) {
		e.keyCode = 27;
	}
	textWidget.notifyListeners(SWT.KeyDown, e);
}
 
Example 7
Source File: Bug493784Test.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
private void pressKey(final XtextEditor editor, final char c) throws Exception {
  final StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
  final Event e = new Event();
  e.character = c;
  e.type = SWT.KeyDown;
  e.doit = true;
  textWidget.notifyListeners(SWT.KeyDown, e);
}
 
Example 8
Source File: InsertStringHandler.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	XtextEditor editor = EditorUtils.getActiveXtextEditor(event);
	if (editor != null) {
		// Hack, would be nicer with document edits, but this way we don't loose auto edit
		StyledText textWidget = editor.getInternalSourceViewer().getTextWidget();
		Event e = new Event();
		e.character = replaceChar;
		e.type = SWT.KeyDown;
		e.doit = true;
		textWidget.notifyListeners(SWT.KeyDown, e);
	}
	return null;
}