Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse 4 » Lifecycle events on a window
Lifecycle events on a window [message #958939] Fri, 26 October 2012 10:33 Go to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
Hi,

on migrating my Eclipse 3.x application to Eclipse 4 I came across something I don't know how to solve in a clean way. I haven't found a bug or another forum topic on it yet, so if there is already one, please let me know and I will add my question/discussion there.

So what I'm trying to achieve is to connect to a window lifecycle, like it was possible in Eclipse 3.x with the ApplicationWorkbenchWindowAdvisor. Two scenarios:

1. My application can be started with a startup parameter pointing to a file. The filename should be added to the shell title. In Eclipse 3.x I used postWindowOpen() to modify the shell title after loading is finished. I tried to achieve this by using the lifecycle hook mechanism, but of course this doesn't succeed because it is too early.

2. I want to add special behaviour on closing the app. For this I added my custom code to preWindowShellClose() in Eclipse 3.x. As I read in the book from Lars Vogel, in Eclipse 4 you have to set a custom IWindowCloseHandler to the context. This is great, but when in terms of the lifecycle? Because the IWindowCloseHandler will be overriden on rendering by the WBWRenderer.

The only solution I found on this was to add my custom behaviour in some code within a part that gets rendered at startup. Or I could listen to part events like activation. But modifying window state and behaviour by listening to part events can't be a clean solution regarding a modular system like Eclipse 4. Do I miss anything there?

At least I thought of some workaround for the IWindowCloseHandler after I attended Sopot Cela's talk about context functions at the EclipseCon yesterday. If the WBWRenderer would set the IWindowCloseHandler by ContextFactory, it would be possible for users to override this. But unfortunately the WBWRenderer doesn't use a ContextFactory but creates anonymous inner classes, set in a private method. So there is no choice of overriding it. But this is just an idea. As I'm not yet really familiar with the context functions, this might be a silly idea.

Please let me know what you think about this.

Greez,
Dirk
Re: Lifecycle events on a window [message #958955 is a reply to message #958939] Fri, 26 October 2012 10:43 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5330
Registered: July 2009
Senior Member
On the window stuff. See
https://bugs.eclipse.org/bugs/show_bug.cgi?id=376821

On the more general topic. Take a look at my comments in
https://bugs.eclipse.org/bugs/show_bug.cgi?id=389063 it outlines a for
specific elements (comment 5).

I've just filed https://bugs.eclipse.org/bugs/show_bug.cgi?id=389063 for
this general use case. I think it is not going to be hard to implement
so I'll try to take a look at it.

Tom

Am 26.10.12 12:33, schrieb Dirk Fauth:
> Hi,
>
> on migrating my Eclipse 3.x application to Eclipse 4 I came across
> something I don't know how to solve in a clean way. I haven't found a
> bug or another forum topic on it yet, so if there is already one, please
> let me know and I will add my question/discussion there.
>
> So what I'm trying to achieve is to connect to a window lifecycle, like
> it was possible in Eclipse 3.x with the
> ApplicationWorkbenchWindowAdvisor. Two scenarios:
>
> 1. My application can be started with a startup parameter pointing to a
> file. The filename should be added to the shell title. In Eclipse 3.x I
> used postWindowOpen() to modify the shell title after loading is
> finished. I tried to achieve this by using the lifecycle hook mechanism,
> but of course this doesn't succeed because it is too early.
>
> 2. I want to add special behaviour on closing the app. For this I added
> my custom code to preWindowShellClose() in Eclipse 3.x. As I read in the
> book from Lars Vogel, in Eclipse 4 you have to set a custom
> IWindowCloseHandler to the context. This is great, but when in terms of
> the lifecycle? Because the IWindowCloseHandler will be overriden on
> rendering by the WBWRenderer.
> The only solution I found on this was to add my custom behaviour in some
> code within a part that gets rendered at startup. Or I could listen to
> part events like activation. But modifying window state and behaviour by
> listening to part events can't be a clean solution regarding a modular
> system like Eclipse 4. Do I miss anything there?
>
> At least I thought of some workaround for the IWindowCloseHandler after
> I attended Sopot Cela's talk about context functions at the EclipseCon
> yesterday. If the WBWRenderer would set the IWindowCloseHandler by
> ContextFactory, it would be possible for users to override this. But
> unfortunately the WBWRenderer doesn't use a ContextFactory but creates
> anonymous inner classes, set in a private method. So there is no choice
> of overriding it. But this is just an idea. As I'm not yet really
> familiar with the context functions, this might be a silly idea.
>
> Please let me know what you think about this.
>
> Greez,
> Dirk
Re: Lifecycle events on a window [message #959014 is a reply to message #958955] Fri, 26 October 2012 11:39 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1289
Registered: July 2012
Senior Member
Thanks Tom, this is indeed what I was talking about. Reading your comments, your solution is the more general and more easy to use approach for users than the one with context functions.

Your last link is duplicated, but the correct one can be found at the end of the bug linked before.

So I will solve my issues with the ugly workaround in a part/part event for the moment, waiting for the clean solution with additional lifecycle events for ui elements.
Re: Lifecycle events on a window [message #959032 is a reply to message #959014] Fri, 26 October 2012 11:54 Go to previous message
Thomas Schindl is currently offline Thomas Schindl
Messages: 5330
Registered: July 2009
Senior Member
You are right the generic bug I created is at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=392903

Tom

Am 26.10.12 13:39, schrieb Dirk Fauth:
> Thanks Tom, this is indeed what I was talking about. Reading your
> comments, your solution is the more general and more easy to use
> approach for users than the one with context functions.
>
> Your last link is duplicated, but the correct one can be found at the
> end of the bug linked before.
>
> So I will solve my issues with the ugly workaround in a part/part event
> for the moment, waiting for the clean solution with additional lifecycle
> events for ui elements.
Previous Topic:Progress Bar on Splash Screen
Next Topic:Handler does not execute
Goto Forum:
  


Current Time: Sat Sep 20 18:15:54 GMT 2014

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

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