|
|
Re: Model persistence - transient? [message #1693912 is a reply to message #1693887] |
Wed, 29 April 2015 09:18 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
Can you show me the @AboutToShow handler addition and removal should be
handled by the renderer system itself - at least in e(fx)clipse renderer
we are doing it and I think we behave the same as SWT.
Tom
On 29.04.15 09:22, Dirk Fauth wrote:
> Hi,
>
> I am trying to use the DynamicMenuContribution to implement an E4 recent
> file mechanism. But I come across an issue with the model persistence.
>
> In the @AboutToShow annotated method, I create MHandledMenuItems that
> are added to the list of MMenuElement. This works fine so far. The issue
> is related to the persistence. If I don't specify -clearPersistedState,
> the menu items are doubled on each startup. Of course this is because of
> the model persistence, as the created menu items are added to the model
> and therefore got persisted. And on starting the application the items
> are already there and with no additional check my
> DynamicMenuContribution adds the items again.
>
> Now I'm wondering if there is an easy way to configure a model element
> to be "transient". Is it possible somehow (e.g. via tag) to specify that
> a model element shouldn't be persisted?
>
> I was searching for an answer and going through the code for a while but
> didn't find anything.
> I currently can think of the following workarounds for this issue:
>
> 1. Add a check to the DynamicMenuContribution to see whether the
> elements are already there. Fine for this scenario, but I'm not sure if
> this is a solution for the issue in general.
>
> 2. On @AboutToHide the items should be removed again. But I don't think
> that is a suitable solution regarding performance.
>
> 3. Implement and register a custom IModelResourceHandler as explained
> here:
> http://www.vogella.com/tutorials/Eclipse4ModelPersistence/article.html
> But I personally think that is a huge workaround for a quite common use
> case.
>
> 4. Add a custom tag to the model element and implement and register a
> lifecycle handler that inspects the model elements for the custom tag
> and removes it in a method annotated with @PreSave
>
> I personally prefer the last one, since it is the most flexible and for
> a user easiest way and should only affect the performance on closing the
> application. Although implementing and registering the lifecycle handler
> is a bit nasty for a user, so it would be nice if that would be a
> platform feature.
>
> I just wonder if this mechanism doesn't already exist somehow and I am
> not able to find it. Maybe EMF itself provides such a feature?
>
> Greez,
> Dirk
|
|
|
|
|
|
|
|
|
Re: Model persistence - transient? [message #1693991 is a reply to message #1693949] |
Wed, 29 April 2015 20:49 |
Eclipse User |
|
|
|
Dirk Fauth wrote on Wed, 29 April 2015 08:44OK, with Mars the dynamic menu contributions are removed and rebuild correctly.
But now I have the issue that the MHandledMenuItems are not executed anymore. The handler for the command is not called. This worked before, so what has changed with Mars?
Are these items in a top-level menu?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02895 seconds