Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Connections disappear between shortcut elements on refresh/reload
Connections disappear between shortcut elements on refresh/reload [message #207741] Fri, 03 October 2008 00:34 Go to next message
Jevon  is currently offline Jevon Friend
Messages: 164
Registered: July 2009
Senior Member
Hello,

I am working on a diagram editor with shortcuts. It used to work well
when I had a model like so:

- Page
- 0..* Edge to DomainAttribute
- DomainObject
- 0..* DomainAttribute [0..* outEdges, 0..* inEdges]

But I had to change my model like so, making Edges top-level:

- Page
- DomainObject
- 0..* DomainAttribute [0..* outEdges, 0..* inEdges]
- 0..* Edge from Page to DomainAttribute

If I go into the editor for Page, and drag and drop DomainAttributes
into the Page editor, they render fine as shortcuts. But if I create an
Edge between the two DomainAttributes, it accepts the link and renders
it - until I try to refresh the diagram (by pressing F5 or
closing/opening the diagram).

I'm not sure how to tackle this problem. I am guessing that some policy
or provider is not providing all of the necessary edges that need to be
rendered in the Page diagram editor, but I'm not sure where this would
be? Is there something that is missing in my .gmfmap or .gmfgen? Or is
it an EMF attribute that needs to be set?

Thanks for any help,

Jevon
Re: Connections disappear between shortcut elements on refresh/reload [message #207752 is a reply to message #207741] Fri, 03 October 2008 05:00 Go to previous messageGo to next message
Jevon  is currently offline Jevon Friend
Messages: 164
Registered: July 2009
Senior Member
Hi,

I've done a lot of in-the-dark debugging and haven't come any closer to
a solution. However, based on a thread below, it appears that it is
something to do with the EMF model - it appears that GMF will only
render links that are contained within the diagram model element, and
not those that aren't contained in the model element. Am I correct?

That is, it calls Node.getEdges() to find all Edges that should appear
in the Node, and will delete all connections that are not in this return
value.

In more detail, if I create a Node with two shortcuts to two other Nodes
and create an Edge between them, save the diagram, and then press F5:

[NodeCanonicalEditPolicy.java]
protected void refreshSemantic() {
List createdViews = new LinkedList();
createdViews.addAll(refreshSemanticChildren()); // empty
List createdConnectionViews = new LinkedList();
createdConnectionViews.addAll(refreshSemanticConnections()); //
still empty
createdConnectionViews.addAll(refreshConnections()); // still empty

...
}

I thought that if you have two shortcut elements on the model that are
connected elsewhere, the link would normally be automatically rendered
when the diagram refreshed (F5)?

I found some other threads that haven't really been that helpful either:

http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg07294.html
(2007)
http://dev.eclipse.org/newslists/news.eclipse.modeling.gmf/m sg10196.html
(2008)

Some of the stack trace of what occurs when I press F5 is attached.

Cheers
Jevon

Stacktrace:

Thread [main] (Suspended)
my.model.diagram.visual.edit.policies.VisibleThingCanonicalE ditPolicy.refreshConnections()
line: 194

my.model.diagram.visual.edit.policies.VisibleThingCanonicalE ditPolicy.refreshSemantic()
line: 166

my.model.diagram.visual.edit.policies.VisibleThingCanonicalE ditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.Ca nonicalEditPolicy).refresh()
line: 962

my.model.diagram.visual.part.IamlDiagramUpdateCommand.execut e(org.eclipse.core.commands.ExecutionEvent)
line: 57

org.eclipse.ui.internal.handlers.HandlerProxy.execute(org.ec lipse.core.commands.ExecutionEvent)
line: 239

org.eclipse.core.commands.Command.executeWithChecks(org.ecli pse.core.commands.ExecutionEvent)
line: 475

org.eclipse.core.commands.ParameterizedCommand.executeWithCh ecks(java.lang.Object,
java.lang.Object) line: 429


Jevon Wright wrote:
> Hello,
>
> I am working on a diagram editor with shortcuts. It used to work well
> when I had a model like so:
>
> - Page
> - 0..* Edge to DomainAttribute
> - DomainObject
> - 0..* DomainAttribute [0..* outEdges, 0..* inEdges]
>
> But I had to change my model like so, making Edges top-level:
>
> - Page
> - DomainObject
> - 0..* DomainAttribute [0..* outEdges, 0..* inEdges]
> - 0..* Edge from Page to DomainAttribute
>
> If I go into the editor for Page, and drag and drop DomainAttributes
> into the Page editor, they render fine as shortcuts. But if I create an
> Edge between the two DomainAttributes, it accepts the link and renders
> it - until I try to refresh the diagram (by pressing F5 or
> closing/opening the diagram).
>
> I'm not sure how to tackle this problem. I am guessing that some policy
> or provider is not providing all of the necessary edges that need to be
> rendered in the Page diagram editor, but I'm not sure where this would
> be? Is there something that is missing in my .gmfmap or .gmfgen? Or is
> it an EMF attribute that needs to be set?
>
> Thanks for any help,
>
> Jevon
Re: Connections disappear between shortcut elements on refresh/reload [message #207794 is a reply to message #207752] Fri, 03 October 2008 09:44 Go to previous messageGo to next message
Alexander Shatalin is currently offline Alexander ShatalinFriend
Messages: 2928
Registered: July 2009
Senior Member
Hello Jevon,

I suggest you to debug refreshConnections() method to see the reason why
corresponding link disappears from the diagram. I general, there can be some
updating problems in case link source/target nodes are shortcuts, so if you
can localize this problem and submitt a request to correat it that will be
great.

-----------------
Alex Shatalin
Re: Connections disappear between shortcut elements on refresh/reload [message #207844 is a reply to message #207794] Mon, 06 October 2008 02:02 Go to previous messageGo to next message
Jevon  is currently offline Jevon Friend
Messages: 164
Registered: July 2009
Senior Member
Hi Alex,

Thank you for your help. I did a debug referring to a working editor and
found the culprit:

public static List getElement_1007ContainedLinks(View view) {
return Collections.EMPTY_LIST;
}

This is for a model like so:

- interface EdgeSource
- interface EdgeTarget
- class Edge
- source: EdgeSource
- target: EdgeTarget

- interface ContainsEdges
- edges: 0..* Edges (containment = true)

- class Element <- EdgeSource, EdgeDestination
- class Container <- ContainsEdges
- elements: 0..* Element (containment = true)

This model is by design - I want the edges (which represent behavioural
logic) to be stored _outside_ of the Element, in the Container.

In this model, you can create edges between Elements in a Container.
However, when the Elements are edges in a different Container and are
represented with shortcuts, you cannot currently create the edges.

I submitted bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=249717
with information about how to reproduce this.

Thanks :)

Jevon

Alex Shatalin wrote:
> Hello Jevon,
>
> I suggest you to debug refreshConnections() method to see the reason why
> corresponding link disappears from the diagram. I general, there can be
> some updating problems in case link source/target nodes are shortcuts,
> so if you can localize this problem and submitt a request to correat it
> that will be great.
>
> -----------------
> Alex Shatalin
>
>
Re: Connections disappear between shortcut elements on refresh/reload [message #235773 is a reply to message #207844] Thu, 09 July 2009 12:28 Go to previous message
Jevon  is currently offline Jevon Friend
Messages: 164
Registered: July 2009
Senior Member
Hi Alex,

I spent a few days working on this and I came up with a solution which
rewrites most of the content in XXXCanonicalEditPolicy and
XXXDiagramUpdater. My solution will render:

- Directly contained nodes (GMF default)
- Directly contained edges (GMF default)
- Edges not directly contained in the nodes or its parents, up to the
diagram node
- "Shortcut" nodes connected to directly contained elements, even if the
edge is not directly contained
- Edges to these shortcut nodes

This solution appears to work with my installation of GMF 2.0.1, and
I've implemented them as dynamic templates:

http://code.google.com/p/iaml/source/browse/branches/2009-06 -issue-47/org.openiaml.model/templates/aspects/xpt/diagram/e ditpolicies/DiagramCanonicalEditPolicy.xpt?spec=svn793&r =793
http://code.google.com/p/iaml/source/browse/branches/2009-06 -issue-47/org.openiaml.model/templates/aspects/xpt/diagram/u pdater/DiagramUpdater.xpt?r=792

It achieves this by copying a lot of the existing code in
SemanticEditPolicy and essentially replacing the refresh method
(refreshSemantic()). I add new methods to DiagramUpdater to select all
of the elements and relationships that should be added to the view, even
if they are not directly contained. It does this by iterating over the
model itself and using domain-specific selection code.

I also modify createConnectionView() to return an adapter that also
adapts to IElementType.class, which just returns the IElementType from
the parent diagram code (XXXElementTypes.getElementType(EClass)).

Some methods and classes (AsyncCommand) had to be copied because they
were marked 'private' in SemanticEditPolicy. I also disable
refreshConnections() and createConnections().

I had to add a null check to addListenersToContainers(List) because in
some instances, View.eContainer() was returning null. Not sure why.

I expect a lot of use cases of GMF are broken by this change (multiple
views? Multiple models?) and it's probably quite slow.

Hardly ideal or elegant, but it seems to work. You can still place
elements and relationships fine it seems. And it seems a more reliable
way of creating shortcuts and links than my previous attempt. Any
suggestions?

The next step is to upgrade to the latest GMF, and hopefully not too
many of these changes are rendered useless ;)

Jevon

Jevon Wright wrote:
> Hi Alex,
>
> Thank you for your help. I did a debug referring to a working editor and
> found the culprit:
>
> public static List getElement_1007ContainedLinks(View view) {
> return Collections.EMPTY_LIST;
> }
>
> This is for a model like so:
>
> - interface EdgeSource
> - interface EdgeTarget
> - class Edge
> - source: EdgeSource
> - target: EdgeTarget
>
> - interface ContainsEdges
> - edges: 0..* Edges (containment = true)
>
> - class Element <- EdgeSource, EdgeDestination
> - class Container <- ContainsEdges
> - elements: 0..* Element (containment = true)
>
> This model is by design - I want the edges (which represent behavioural
> logic) to be stored _outside_ of the Element, in the Container.
>
> In this model, you can create edges between Elements in a Container.
> However, when the Elements are edges in a different Container and are
> represented with shortcuts, you cannot currently create the edges.
>
> I submitted bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=249717
> with information about how to reproduce this.
>
> Thanks :)
>
> Jevon
>
> Alex Shatalin wrote:
>> Hello Jevon,
>>
>> I suggest you to debug refreshConnections() method to see the reason
>> why corresponding link disappears from the diagram. I general, there
>> can be some updating problems in case link source/target nodes are
>> shortcuts, so if you can localize this problem and submitt a request
>> to correat it that will be great.
>>
>> -----------------
>> Alex Shatalin
>>
>>
Previous Topic:Diagram Partitioning, problems at saving and synchronization
Next Topic:method creation/deletion inside model
Goto Forum:
  


Current Time: Tue Apr 23 17:37:08 GMT 2024

Powered by FUDForum. Page generated in 0.03417 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top