accessing current model from other plugin [message #158530] |
Tue, 06 November 2007 15:17 |
Eclipse User |
|
|
|
Originally posted by: anchorman.gmx.net
Ho folks,
I have a generated GMF editor for a simple EMF model. The graphical
editor is just a small part of my app and I want to add more
functionality and logic for the model in other plugins. Now I'm a bit
confused how to access the current model that the user is editing in the
graphical editor. Most tutorials are on creating new elements with the
factories and so on or on using the generated Content/LabelProviders in
standard views. But how do I access the underlying model, i.e. the
instances of my generated model classes of the model that is being
modified in the editor from other plugins? A simple example: Say I want
to show the current number of nodes in the model in another view and
want it updated as soon as the user modifies the graphical model
representation?! Any hint or reference?
Thx,
Max
|
|
|
Re: accessing current model from other plugin [message #158552 is a reply to message #158530] |
Tue, 06 November 2007 16:22 |
Eclipse User |
|
|
|
Originally posted by: trommas.yahoo.com
Max Power wrote:
> how do I access the underlying model, i.e. the
> instances of my generated model classes of the model that is being
> modified in the editor from other plugins?
Everything in the diagram is contained in a Resource Set. Accessing
attributes of the underlaying model is simple as long as your "inside"
the editor/plugin. If you want external access, it's not so simple. One
option is have your model elements wrap external objects - I do this
because my editor works with an OWL file. Another approach, I guess,
would be to parse the generated diagram (XML) file.
A simple example: Say I want
> to show the current number of nodes in the model in another view and
> want it updated as soon as the user modifies the graphical model
> representation?! Any hint or reference?
Well, as long as you're only working with gmf/emf editors, you can use
"Load Resource" to gain access across diagrams. Getting the number of
nodes should be a simple operation from there.
HTH
Tomas Zijdemans
|
|
|
|
Re: accessing current model from other plugin [message #158648 is a reply to message #158560] |
Wed, 07 November 2007 12:38 |
Eclipse User |
|
|
|
Originally posted by: anchorman.gmx.net
Hi Alex,
thanks, that looks quite promising. For now I added a new plugin with an
action that shows a MessageDialog with the current number of nodes and
relations for testing. Nice. Just a short question about getting the
XXXDiagramEditor: In the action I have the ExecutionEvent object and
currently use
MyDiagramEditor mde = (MyDiagramEditor) HandlerUtil
..getActiveEditor(event);
Supposing I am not inside an action I would have to go all the way from
the workbench ti the current editor like
workbench.getActiveWorkbenchWindow().getActivePage().getActi veEditor()
It this the preferred way to access the current DiagramEditor or is
there something more elegant?
Thanks a lot,
Max
Alex Shatalin wrote:
> Hello Max,
>
> Try calling ???DiagramEditor.getDiagram().getElement() and you should
> get diagram element to start with..
>
> -----------------
> Alex Shatalin
>
>
|
|
|
|
Powered by
FUDForum. Page generated in 0.03232 seconds