Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Detect Part moved to different PartStack
Detect Part moved to different PartStack [message #1766582] Fri, 23 June 2017 09:47 Go to next message
Roman Flueckiger is currently offline Roman FlueckigerFriend
Messages: 3
Registered: January 2015
Junior Member
I'm trying to achieve the following:
Whenever a Part moves or is moved (e.g. by the user via drag an drop) to a different PartStack, certain SWT widgets in the part need to change their style (currently only the background color) to match the "style" of the PartStack.

The problem:
There seems to be no way of detecting when a Part has moved to a new PartStack!

What I tried:
- Using events from the EPartService. However, the events are not suitable to detect the required cases. In many cases of moving a Part there is no event at all generated by this service.
- Using events from subscribing to the IEventBroker. Most notably I tried to subscribe to the topic UIEvents.UIElement.TOPIC_PARENT and waited for SET events. For a short time, this seemed to be the solution. But it turns out that there are certain cases, where NO event is sent (i.e. when a Part is moved in a way that a new PartStack with a PartSashContainer is generated). Additionally, in many cases the SET event only contained an "old value" which was null, but no new value. In other words, at the point in time when I receive the event the parent of the Part (the PartStack) is null. However, to figure out which style I should apply to the Part I need the new PartStack stack at this time...
- I also tried to cast the Part to an EObject to somehow "listen" directly to the event when the parent is set on the Part. But, as far as I could tell there is no event sent their either...

So what is my question:
- What am I doing wrong? Is there really no way of receiving an event when a Part is "added" to a new PartStack? What am I missing?
- Is there some other way of achieving the same thing? I thought along the lines of somehow "binding" my widgets background color directly a specific css property of the parent MParkStack (note, that this would have to be the completely resolved css properties for the specific PartStack that is the current parent of the Part). So that the style would be "automatically" up to date whenever the part's rendering is updated? If this is even possible, how would I do something like this?

Thanks for any input.
Re: Detect Part moved to different PartStack [message #1766884 is a reply to message #1766582] Wed, 28 June 2017 14:14 Go to previous messageGo to next message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 655
Registered: January 2012
Senior Member

I noticed the parent pointer doesn't work either, but haven't tried to dig into it. Listen for children changes instead: the CleanupAddon has an example that closes part stacks with no children.

Brian.


Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Re: Detect Part moved to different PartStack [message #1766988 is a reply to message #1766884] Thu, 29 June 2017 10:04 Go to previous messageGo to next message
Roman Flueckiger is currently offline Roman FlueckigerFriend
Messages: 3
Registered: January 2015
Junior Member
Thanks for the reply.

I did some initial tests with subscribing to child events. But, as with subscribing to parent changes, some events are "good", while others are not so nice, or seem to be missing.

i.e. if I move a part in a way that does not place it in an existing stack but forces e4 to create a new container (sash container or the like), the only event I get is "a MPartSashContainer has been added". With just that information it gets really difficult to find out what actually happened - in may case: which part has been moved and to which stack it has been added. Because, the part sash container I receive essentially can contain a big part of the workbench model in this case. And I'm at a loss to find out what has changed in this tree structure...

I've a workaround in place now that seems to solve the issue for now. For every part I process all incoming events (more or less without restriction) and update the style as soon as my part has a parent set (I check the member variable not the event). This works currently for all cases I could think of. So, there seem to be "enough" events to eventually be notified when something changed... even if the events by themselves in many cases don't transport this information or "obscure" it somehow.
Re: Detect Part moved to different PartStack [message #1767403 is a reply to message #1766988] Wed, 05 July 2017 16:00 Go to previous message
Brian de Alwis is currently offline Brian de AlwisFriend
Messages: 655
Registered: January 2012
Senior Member

That's true, you may get a big model piece added to the model: in this case you need to process the contents of that piece. E4 only notifies of changes to the actual application model instance being rendered, and not to independent pieces. On loading the application model, E4 installs a listener on the model instance to listen for changes; there's no way to listen for new unconnected model instances.

Eclipse Platform committer. Ask me about Eclipse support, training, and consulting.
Previous Topic:Why can't my RCP 3 fragment resolve any classes in my host?
Next Topic:WorkbenchPage doesn't fire perspectiveSavedAs
Goto Forum:
  


Current Time: Tue Sep 26 11:11:54 GMT 2017

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

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