Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to listen for RowReorderEvents?
How to listen for RowReorderEvents? [message #1129459] Tue, 08 October 2013 16:51 Go to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
I need to listen for reordering of rows. The following does not work (the handleLayerEvent does not get called):

final RowHeaderLayerStack rows = new RowHeaderLayerStack(...);
rows.registerEventHandler(new ILayerEventHandler<RowReorderEvent>() {

    @Override
    public Class<RowReorderEvent> getLayerEventClass() {
        return RowReorderEvent.class;
    }

    @Override
    public void handleLayerEvent(final RowReorderEvent arg0) {
        // Do stuff
    }

});


Also adding this handler to the body layer stack does not work. A RowReorderLayer was added. What additional things am I missing?
Re: How to listen for RowReorderEvents? [message #1129527 is a reply to message #1129459] Tue, 08 October 2013 18:29 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Try to add an ILayerListener via addLayerListener() on any layer that is set on top of the RowReorderLayer.
Re: How to listen for RowReorderEvents? [message #1130048 is a reply to message #1129527] Wed, 09 October 2013 07:18 Go to previous messageGo to next message
Jens Rabe is currently offline Jens RabeFriend
Messages: 81
Registered: September 2013
Member
I finally got it to work using the first approach. I did not know why the handleLayerEvent was not called in the first place, maybe Eclipse still thought my project was up-to-date. Had this strange behaviour in the past sometimes. Re-implementing it and cleaning the whole project made it work.

If anyone else needs to accomplish this, here is how I got it to work:


  1. Created an event handler which implements ILayerEventHandler<RowReorderEvent>
  2. Made the getLayerEventClass() method return RowReorderEvent.class
  3. Implemented the handling code in handleLayerEvent(RowReorderEvent evt)
  4. registered the event handler on the Body layer stack
  5. Constructed the Body layer stack the following way: ViewportLayer -> SelectionLayer -> RowReorderLayer -> ColumnHideShowLayer -> ColumnReorderLayer -> DataLayer


Maybe I should have a look at GlazedLists... In my case, I have to propagate model changes via EMF commands on an EditingDomain, is this possible with GlazedLists?
Re: How to listen for RowReorderEvents? [message #1130058 is a reply to message #1130048] Wed, 09 October 2013 07:31 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Two things:

1. There is one big limitation to your approach in the current architecture. The ILayerEventHandler is used internally to add typed event handling support in the layers themselves. As internally only one handler for events is necessary (e.g. performing transformations) it is only possible to register ONE such handler to a layer.
If another handler was registered before, you replace it with your approach.
If you ever want to add another listener, you will replace your listener.

Therefore you shouldn't use the ILayerEventHandler to listen to NatTable events. You should use the ILayerListener and add checks for the event type for your use cases.

This is just another reason why the NatTable architecture needs to be revised in the near future.

2. GlazedLists is a list implementation for high performance operations with lists like filtering, sorting, tree building and more. It also supports event handling. That means GlazedLists are firing ListChangeEvents similar to WritableLists in JFace or ObservableLists in JavaFX. If that is your question than yes it is possible with GlazedLists. If your question is about the properties of a value in your list, than no, you need to add this yourself. The GlazedListsEventLayer in NatTable adds a PropertyChangeListener approach. But you need to attach your listeners yourself. This is for example used to implement blinking.

Greez,
Dirk
Previous Topic:When selecting in NatTable only Rowheaders should change the background color
Next Topic:Problem with RowReorderLayer and indexes.
Goto Forum:
  


Current Time: Thu Apr 25 19:40:30 GMT 2024

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

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

Back to the top