Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Sending Events bottom up, over all layers?
Sending Events bottom up, over all layers? [message #1039993] Fri, 12 April 2013 22:46 Go to next message
Alex Kipling is currently offline Alex Kipling
Messages: 255
Registered: July 2012
Senior Member
I would like to pass an Event to all the Layers, on top of my Layer.

Passing infos top-down is possible by doing AbstractLayer.doCommand

Is there an analogue for doing it bottom-up?



Greets
Re: Sending Events bottom up, over all layers? [message #1040225 is a reply to message #1039993] Sat, 13 April 2013 07:43 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1301
Registered: July 2012
Senior Member
Commands are passed the layer stack top-down, events bottom-up

http://www.eclipse.org/nattable/documentation.php?page=basics
Re: Sending Events bottom up, over all layers? [message #1040260 is a reply to message #1040225] Sat, 13 April 2013 09:01 Go to previous messageGo to next message
Alex Kipling is currently offline Alex Kipling
Messages: 255
Registered: July 2012
Senior Member
Yeah, it is written in the Docu that the events are passed bottom-up,
but as far as I can see the method AbstractLayer.fireLayerEvent(event) just triggers the listeners - it does not pass events to the layer one level higher.

And I would like to pass an Event bottom-up to ALL LAYERS above my actual layer.

First I thought, that there is a listener, which will pass the event up, but when I tried out on my AbstractLayer implementation - there were no listeners at all.


What do I miss? Is it a wrong method for sending events?

	/**
	 * Pass the event to all the {@link ILayerListener} registered on this layer.
	 * A cloned copy is passed to each listener.
	 */
	public void fireLayerEvent(ILayerEvent event) {
		if (listeners.size() > 0) {
			Iterator<ILayerListener> it = listeners.iterator();
			boolean isLastListener = false;
			do {
				ILayerListener l = it.next();
				isLastListener = !it.hasNext();  // Lookahead
				
				// Fire cloned event to first n-1 listeners; fire original event to last listener
				ILayerEvent eventToFire = isLastListener ? event : event.cloneEvent();
				l.handleLayerEvent(eventToFire);
			} while (!isLastListener);
		}
	}

[Updated on: Sat, 13 April 2013 09:12]

Report message to a moderator

Re: Sending Events bottom up, over all layers? [message #1040314 is a reply to message #1040260] Sat, 13 April 2013 10:57 Go to previous message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1301
Registered: July 2012
Senior Member
Yes passing events up is done by calling the listeners. The layers need to register as listener to the underlying layer. This is how it is implemented by the NatTable layers. IMHO this should be implemented in the abstract implementations. Possibly by setUnderlyingLayer(). I think there is also a comment saying that you need to ensure this on implementing a custom layer. So if this does not word for you, you should ensure that you implemented your layer correctly
Previous Topic:Selected columns indexes in collapsed groups
Next Topic:Bug PaddingDecorator?
Goto Forum:
  


Current Time: Wed Oct 01 16:29:18 GMT 2014

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

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