Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to get notation by domain model element?
How to get notation by domain model element? [message #482600] Thu, 27 August 2009 04:54 Go to next message
Vitaly Savicks is currently offline Vitaly Savicks
Messages: 15
Registered: July 2009
Junior Member
Hi,

Can anyone please explain how is domain model linked to notation model of
the GMF? I know there's a link from notation to domain, but is there a way
to traverse in the opposite way, say if I've got a domain model's element
and I need to get the notation or edit part from the current editor that
corresponds to this domain element?

Any help appreciated!
Re: How to get notation by domain model element? [message #482614 is a reply to message #482600] Thu, 27 August 2009 05:45 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Vitaly,

Such link does not exists.
You need to traverse particular diagram structure (or use EMF CrossReferenceAdapter)
to locate notation model elements referencing corresponding domain model one.

-----------------
Alex Shatalin
Re: How to get notation by domain model element? [message #482628 is a reply to message #482614] Thu, 27 August 2009 07:24 Go to previous messageGo to next message
Vitaly Savicks is currently offline Vitaly Savicks
Messages: 15
Registered: July 2009
Junior Member
Thanks Alex,

I have found this bit somewhere (for anyone interested), which kind of
allows to do it:

IDiagramGraphicalViewer viewer = editor.getDiagramGraphicalViewer();
List editParts =
viewer.findEditPartsForElement(EMFCoreUtil.getProxyID(elemen t),
EditPart.class);

but of course it's not an optimal way. I just thought that there exists an
opposite of ViewUtil.resolveSemanticElement(view). Now at least I know
there isn't and no need to spend more time on searching.

In that case can I somehow remove a diagram element just by having a
reference to (and using only) a domain element? I've noticed that the
creation of domain element using pure EMF commands, say
org.eclipse.emf.edit.command.AddCommand automatically creates
corresponding view on the diagram, but removal (RemoveCommand) does not. I
know I can use editpart's getCommand() or to manually create a composite
one using DestroyElementCommand to remove both view and domain elements,
but in my tool's specific listener I only work on the domain model and
don't want to clutter it with many dependencies on GMF front-end.
Re: How to get notation by domain model element? [message #482852 is a reply to message #482628] Fri, 28 August 2009 06:27 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Vitaly,

If you have synchronized diagram then corresponding diagram element will
be automatically removed then you open diagram/save domain model file/commig
corresponding modification to the domain model.

-----------------
Alex Shatalin
Re: How to get notation by domain model element? [message #482945 is a reply to message #482852] Fri, 28 August 2009 12:05 Go to previous messageGo to next message
Vitaly Savicks is currently offline Vitaly Savicks
Messages: 15
Registered: July 2009
Junior Member
Thanks Alex

Yes, that is what I have expected to happen indeed and what I actually
observed on a generated mockup editor. Unfortunately this isn't the case
for the editor I'm working with. I presume it's not synchronising the
diagram automatically. Is there an easy way to force it to synchronise
with a domain model (a programmatic way without modification of the editor
plug-in)? I hope this is my final question:)
Re: How to get notation by domain model element? [message #483141 is a reply to message #482945] Mon, 31 August 2009 06:26 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander Shatalin
Messages: 2928
Registered: July 2009
Senior Member
Hello Vitaly,

You can always call generated ???CaninicalEditPolicy (just like it is done
on pressing F5 button).

-----------------
Alex Shatalin
Re: How to get notation by domain model element? [message #483494 is a reply to message #482628] Tue, 01 September 2009 14:12 Go to previous messageGo to next message
Eclipse User
Originally posted by: bugzillaprince.live.com

Hi,

Saw your workaround and was wondering what editor was

Aaron
Re: How to get notation by domain model element? [message #664463 is a reply to message #482628] Sat, 09 April 2011 00:03 Go to previous message
Abhishek Chakraborty is currently offline Abhishek Chakraborty
Messages: 13
Registered: July 2009
Location: india
Junior Member

thanks the solution helped me...

Regards,
Abhishek Chakraborty
Previous Topic:How to customize GMF editors with nodes to have particular behavior
Next Topic:How to know the position of an element which placed on the edge of a parent element?
Goto Forum:
  


Current Time: Sat Aug 30 22:43:53 EDT 2014

Powered by FUDForum. Page generated in 0.05114 seconds