|
Re: Best practices: Where should I maintain my model status? [message #884841 is a reply to message #884838] |
Mon, 11 June 2012 23:39 |
Eclipse User |
|
|
|
Your parts first search their context, then go up to their perspective's context and then up to the MApplication's context and then up to the OSGi layer. If your Model is shared among perspectives it would be good to put it in the MApplication's context. Also you can give it a name and put it in the context like MApplication.getContext().set("my.app.data.model",modelObject); and inject it from anywhere (any part or handler) with
@Inject
@Named("my.app.data.model")
|
|
|
|
|
|
|
|
Re: Best practices: Where should I maintain my model status? [message #885350 is a reply to message #885283] |
Tue, 12 June 2012 21:17 |
Eclipse User |
|
|
|
Mauro,
you are trying to do some really weird things.
First and foremost the MPart and MPerspective cannot be cast to each other. They are completely different interfaces. The method findPart will find a MPart for you and not a MPerspective and thus the p==null. I guess you can use the EModelService's find to find perspectives. p instanceof MPerspective will NEVER be true (will throw a CCE if you force the cast). Tell eclipse to do a type hierarchy on each of those (CTRL+T) and you will get the idea.
Also DON'T use internals like PerspectiveStackImpl. Stick to interfaces.
The menu items are kept in sync with their command. If you create your command on the fly with the command and handler service you should take care to also link the menu items with the newly created commands in order to keep things synced.
|
|
|
Re: Best practices: Where should I maintain my model status? [message #885364 is a reply to message #885350] |
Tue, 12 June 2012 21:55 |
Mauro Condarelli Messages: 428 Registered: September 2009 |
Senior Member |
|
|
On 12/06/2012 23:17, Sopot Cela wrote:
> Mauro,
>
> you are trying to do some really weird things.
I know ;)
Truth is I am unable to find instructions on how to do several things
and thus I resort to experimenting.
Sometimes the experiments get a little wild ;)
> First and foremost the MPart and MPerspective cannot be cast to each
> other. They are completely different interfaces. The method findPart
> will find a MPart for you and not a MPerspective and thus the p==null. I
> guess you can use the EModelService's find to find perspectives. p
> instanceof MPerspective will NEVER be true (will throw a CCE if you
> force the cast). Tell eclipse to do a type hierarchy on each of those
> (CTRL+T) and you will get the idea.
I am still more than a little confused abiut exactly which service I
should use to get the right "piece" (Mpart, MPerspective or whatever).
I hoped there's a unified interface using the id's, but that doesn't
seem true.
> Also DON'T use internals like PerspectiveStackImpl. Stick to interfaces.
My bad.
I debugged and found out that's the actual type returned.
I should have used the Interface, instead.
> The menu items are kept in sync with their command. If you create your
> command on the fly with the command and handler service you should take
> care to also link the menu items with the newly created commands in
> order to keep things synced.
Ok.
What is the magic spell to get the Command already linked with the menu,
instead of creating a new one?
Use EModelService, I presume, but how do I add the parameter?
Can You suggest some specific documentation?
I am mainly using Lars's excellent site, but even that is rather terse
on many subjects.
Wiki seems to be lagging way behind, or I'm unable to navigate it properly.
Thanks for Your time
Mauro
|
|
|
|
Powered by
FUDForum. Page generated in 0.02336 seconds