Lifecycle events on a window [message #958939] |
Fri, 26 October 2012 10:33 |
Dirk Fauth Messages: 2902 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 |
Thomas Schindl Messages: 6651 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
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03478 seconds