Browse Source

Bugfix: transition text not updated when used with direct editing

Andreas Mülder 13 years ago
parent
commit
9f2d88f490

+ 12 - 0
de.itemis.xtext.utils/plugins/de.itemis.xtext.utils.jface/src/de/itemis/xtext/utils/jface/viewers/XtextStyledTextCellEditor.java

@@ -12,6 +12,8 @@
 package de.itemis.xtext.utils.jface.viewers;
 
 import org.eclipse.jface.bindings.keys.KeyStroke;
+import org.eclipse.jface.text.ITextListener;
+import org.eclipse.jface.text.TextEvent;
 import org.eclipse.jface.text.contentassist.IContentAssistant;
 import org.eclipse.jface.text.source.SourceViewer;
 import org.eclipse.jface.viewers.CellEditor;
@@ -101,10 +103,20 @@ public class XtextStyledTextCellEditor extends StyledTextCellEditor {
 		// configure content assist
 		final IContentAssistant contentAssistant = xtextAdapter
 				.getContentAssistant();
+
 		completionProposalAdapter = new CompletionProposalAdapter(styledText,
 				contentAssistant, KeyStroke.getInstance(SWT.CTRL, SWT.SPACE),
 				null);
 
+		// This listener notifies the modification, when text is selected via
+		// proposal. A ModifyEvent is not thrown by the StyledText in this case.
+		xtextAdapter.getXtextSourceviewer().addTextListener(
+				new ITextListener() {
+					public void textChanged(TextEvent event) {
+						editOccured(null);
+					}
+				});
+
 		if ((styledText.getStyle() & SWT.SINGLE) != 0) {
 			// The regular key down event is too late (after popup is closed
 			// again).