Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 343522 - TextViewer post Selection does not seem to fire if text is changed
Summary: TextViewer post Selection does not seem to fire if text is changed
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.6.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-21 08:52 EDT by Artur Kronenberg CLA
Modified: 2011-04-21 09:15 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Artur Kronenberg CLA 2011-04-21 08:52:24 EDT
Hi,

In my application, I have a validation going on where I validate against a database. To not do that on every ModifyEvent I registered a PostSelectionListener to my TextViewer. Everything seems to work except for one thing which I think should be working too:

If you modify the text and the  previous and future text are not of equal length, a SelectionEvent is fired. However if you remove 1 character and add 1 character right away there is no even fired for that.

So doing this quickly:

1234 // 1st input
123  // 2nd input
1235 // 3rd input 

will not fire a selection event even though selection has changed.

Is this behavior intended? If it is, can I work around that or do I have to implement my own PostSelectionListener for the TextViewer's modify event? 

Kind regards,

-- Artur
Comment 1 Dani Megert CLA 2011-04-21 09:15:26 EDT
This works as designed: the post selection listener fires if the selection changed after the given delay. If the selection is the same, then nothing happens.

It looks like what you want is to trigger the work after the text has been changed but not on each keystroke. To do that you should use a reconciler. See org.eclipse.jface.text.source.SourceViewerConfiguration.getReconciler(ISourceViewer) for details. You might also want to look at:
http://www.eclipse.org/eclipse/platform-text/eclipseCon/2006/texteditorrecipes.zip