Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Using PostSelectionListener in Source Editor
Using PostSelectionListener in Source Editor [message #214034] Fri, 02 September 2005 06:47 Go to next message
Eclipse UserFriend
Originally posted by: prasadmpatil.NOSPAM.gmail.com

Hi,

I have added a PostSelectionListener to the source
editor(compilationUnitEditor) to listen for cursor movements. This works
as expected i.e fires selectionChanged event with some delay if the cursor
is moved using keyboard.

However if I highlight some text & then continue with my keyboard
operations, then the selectionChanged event is fired for every key stroke(
the behavior is similar to selectionListener instead of
PostSelectionListener). There are no other listeners registered.

I am unable to figure out this strange behavior. Can somebody help me out?

~Prasad
Re: Using PostSelectionListener in Source Editor [message #214057 is a reply to message #214034] Fri, 02 September 2005 10:59 Go to previous messageGo to next message
Tom Hofmann is currently offline Tom HofmannFriend
Messages: 770
Registered: July 2009
Senior Member
On Fri, 2005-09-02 at 06:47 +0000, Prasad wrote:
> I have added a PostSelectionListener to the source
> editor(compilationUnitEditor) to listen for cursor movements. This works
> as expected i.e fires selectionChanged event with some delay if the cursor
> is moved using keyboard.
>
> However if I highlight some text & then continue with my keyboard
> operations, then the selectionChanged event is fired for every key stroke(
> the behavior is similar to selectionListener instead of
> PostSelectionListener). There are no other listeners registered.
>
> I am unable to figure out this strange behavior. Can somebody help me out?

This should not happen - TextViewer::firePostSelectionChanged is only
called from within the delayed runnable in
TextViewer::queuePostSelectionChanged.

Are you sure you didn't register the same listener twice, once as
selection listener and once as postselection listener?

-tom
Re: Using PostSelectionListener in Source Editor [message #214075 is a reply to message #214057] Fri, 02 September 2005 17:57 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: prasadmpatil.NOSPAMgmail.com

Hi Tom,

There are no other listeners registered on the source editor.

I have registered the listener as follows

ISelectionService service =
editor.getEditorSite().getWorkbenchWindow().getSelectionServ ice();
//editor is CompilationUnitEditor
service.addPostSelectionListener(_listener);


& the listener is as follows

public class ListenerGroup implements ISelectionListener
{

/**
* see org.eclipse.jface.viewers.ISelectionListener#selectionchange d
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection)
{
// Handle listener event
}

}

There are no calls for addSelectionListener() in my code. Besides other
are no other listeners registered either.

Besides if this behavior was due to interference other listeners then this
would happen all the time & not just when I highlight some text in the
source.

~Prasad
Re: Using PostSelectionListener in Source Editor [message #214167 is a reply to message #214075] Mon, 05 September 2005 12:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: daniel.megert.gmx.net

What kind of viewer does your source editor use and which class does
your editor extend?

Dani

Prasad wrote:

> Hi Tom,
>
> There are no other listeners registered on the source editor.
>
> I have registered the listener as follows
>
> ISelectionService service =
> editor.getEditorSite().getWorkbenchWindow().getSelectionServ ice();
> //editor is CompilationUnitEditor
> service.addPostSelectionListener(_listener);
>
>
> & the listener is as follows
>
> public class ListenerGroup implements ISelectionListener
> {
>
> /**
> * see org.eclipse.jface.viewers.ISelectionListener#selectionchange d
> */
> public void selectionChanged(IWorkbenchPart part, ISelection
> selection)
> {
> // Handle listener event
> }
>
> }
>
> There are no calls for addSelectionListener() in my code. Besides
> other are no other listeners registered either.
> Besides if this behavior was due to interference other listeners then
> this would happen all the time & not just when I highlight some text
> in the source.
>
> ~Prasad
>
>
>
>
>
>
>
Re: Using PostSelectionListener in Source Editor [message #214229 is a reply to message #214167] Tue, 06 September 2005 13:41 Go to previous message
Eclipse UserFriend
Originally posted by: prasadmpatil.nospamgmail.com

Hi Tom/Daniel,
Sorry for the posting. There was callback for selectionChanged()(hidden
deep inside) which was causing the problem.

~Prasad

Daniel Megert wrote:

> What kind of viewer does your source editor use and which class does
> your editor extend?

> Dani

> Prasad wrote:

>> Hi Tom,
>>
>> There are no other listeners registered on the source editor.
>>
>> I have registered the listener as follows
>>
>> ISelectionService service =
>> editor.getEditorSite().getWorkbenchWindow().getSelectionServ ice();
>> //editor is CompilationUnitEditor
>> service.addPostSelectionListener(_listener);
>>
>>
>> & the listener is as follows
>>
>> public class ListenerGroup implements ISelectionListener
>> {
>>
>> /**
>> * see org.eclipse.jface.viewers.ISelectionListener#selectionchange d
>> */
>> public void selectionChanged(IWorkbenchPart part, ISelection
>> selection)
>> {
>> // Handle listener event
>> }
>>
>> }
>>
>> There are no calls for addSelectionListener() in my code. Besides
>> other are no other listeners registered either.
>> Besides if this behavior was due to interference other listeners then
>> this would happen all the time & not just when I highlight some text
>> in the source.
>>
>> ~Prasad
>>
>>
>>
>>
>>
>>
>>
Previous Topic:Templates for JUnit tests
Next Topic:Code templates not saved
Goto Forum:
  


Current Time: Fri Dec 27 16:28:26 GMT 2024

Powered by FUDForum. Page generated in 0.03300 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top