Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Change connection target in the model, but diagram not updated
Change connection target in the model, but diagram not updated [message #100627] Fri, 02 February 2007 10:40 Go to next message
Eclipse UserFriend
Originally posted by: claudiu_popescu.rogers.com

In a diagram with nodes A,B,C and a connection M (A to B), I select the
connection M, then I change the target from B to C in the properties tab.

I want the diagram to redraw the connection to the new target node, but I
don't know what API to use.

For a GraphicalEditPart or ConnectionEditPart, this could be solved with
handleMajorSemanticChange(),

but for the DiagramEditPart there is no such method.

I tried refresh() on the DiagramEditPart , but nothing happens.

I looked in the news group and I could not find answer.

The only workaround is to close and reopen the diagram.

The diagram is not updated as such in the mindmap, neither in the Taipan
examples.

Thank you
Re: Change connection target in the model, but diagram not updated [message #100735 is a reply to message #100627] Fri, 02 February 2007 11:38 Go to previous messageGo to next message
Eclipse UserFriend
Hi ;
If your connections are canonical, there was bugzilla

https://bugs.eclipse.org/bugs/show_bug.cgi?id=170328

that reported a similar problem, it had been fixed in M5

This fix might help


Claude Popescu wrote:
> In a diagram with nodes A,B,C and a connection M (A to B), I select the
> connection M, then I change the target from B to C in the properties tab.
>
> I want the diagram to redraw the connection to the new target node, but I
> don't know what API to use.
>
> For a GraphicalEditPart or ConnectionEditPart, this could be solved with
> handleMajorSemanticChange(),
>
> but for the DiagramEditPart there is no such method.
>
> I tried refresh() on the DiagramEditPart , but nothing happens.
>
> I looked in the news group and I could not find answer.
>
> The only workaround is to close and reopen the diagram.
>
> The diagram is not updated as such in the mindmap, neither in the Taipan
> examples.
>
> Thank you
>
>
Re: Change connection target in the model, but diagram not updated [message #100865 is a reply to message #100627] Fri, 02 February 2007 17:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

You need to override this method in canonicalEditPolicy. You must copy the
code for its implementation because the method is either private or final
I don't remember.

Basically, what you have to do is orphan certain connection views if their
endpoint views do not match the semantic ends of the connection.

For that given semantic connection, you leave it in semanticChildren so a
new view gets created for it.

-vlad

protected List cleanCanonicalSemanticChildren(Collection viewChildren, Collection semanticChildren) {
View viewChild;
EObject semanticChild;
Iterator viewChildrenIT = viewChildren.iterator();
List orphaned = new ArrayList();
Map viewToSemanticMap = new HashMap();
while( viewChildrenIT.hasNext() ) {
viewChild = (View)viewChildrenIT.next();
semanticChild = viewChild.getElement();
if (semanticChildren.contains(semanticChild)) {

semanticChildren.remove(semanticChild);
viewToSemanticMap.put(semanticChild, viewChild);
}
else {
orphaned.add(viewChild);
}

View viewInMap = (View)viewToSemanticMap.get(semanticChild);
if (viewInMap != null && !viewChild.equals(viewInMap)) {
if (viewInMap.isMutable()) {
orphaned.remove(viewChild);
orphaned.add(viewInMap);
viewToSemanticMap.put(semanticChild, viewChild);
}
}
}
return orphaned;
}


On Fri, 02 Feb 2007 10:40:18 -0500, Claude Popescu wrote:

> In a diagram with nodes A,B,C and a connection M (A to B), I select the
> connection M, then I change the target from B to C in the properties tab.
>
> I want the diagram to redraw the connection to the new target node, but I
> don't know what API to use.
>
> For a GraphicalEditPart or ConnectionEditPart, this could be solved with
> handleMajorSemanticChange(),
>
> but for the DiagramEditPart there is no such method.
>
> I tried refresh() on the DiagramEditPart , but nothing happens.
>
> I looked in the news group and I could not find answer.
>
> The only workaround is to close and reopen the diagram.
>
> The diagram is not updated as such in the mindmap, neither in the Taipan
> examples.
>
> Thank you
Re: Change connection target in the model, but diagram not updated [message #100994 is a reply to message #100865] Mon, 05 February 2007 12:01 Go to previous message
Eclipse UserFriend
Hi Vlad ;

As i pointed out in my reply,

bugzilla https://bugs.eclipse.org/bugs/show_bug.cgi?id=170328

had been raised and fixed to handle a similar issue

if you get the latest CanonicalEditPolicy and
CanonicalConnectionEditPolicy you will notice that
there is a new protected method introduced on the CanonicalEditPolicy level:

protected boolean isOrphaned(Collection semanticChildren, View view)

the implementation of this method in the canonicalConnectionEditPolicy
looks like this :

protected boolean isOrphaned(Collection semanticChildren, View view) {
EObject element = view.getElement();
if (semanticChildren.contains(element)) {
if (view instanceof Edge) {
Edge edge = (Edge) view;
if (edge.getSource().getElement() !=
getSourceElement(element)
|| edge.getTarget().getElement() !=
getTargetElement(element))
return true;
}
} else
return true;
return false;
}

This should take care or the re-orient use case, if this is does fix the
issue please raise a bugzilla against the GMF runtime.



Vlad Ciubotariu wrote:
> You need to override this method in canonicalEditPolicy. You must copy the
> code for its implementation because the method is either private or final
> I don't remember.
>
> Basically, what you have to do is orphan certain connection views if their
> endpoint views do not match the semantic ends of the connection.
>
> For that given semantic connection, you leave it in semanticChildren so a
> new view gets created for it.
>
> -vlad
>
> protected List cleanCanonicalSemanticChildren(Collection viewChildren, Collection semanticChildren) {
> View viewChild;
> EObject semanticChild;
> Iterator viewChildrenIT = viewChildren.iterator();
> List orphaned = new ArrayList();
> Map viewToSemanticMap = new HashMap();
> while( viewChildrenIT.hasNext() ) {
> viewChild = (View)viewChildrenIT.next();
> semanticChild = viewChild.getElement();
> if (semanticChildren.contains(semanticChild)) {
>
> semanticChildren.remove(semanticChild);
> viewToSemanticMap.put(semanticChild, viewChild);
> }
> else {
> orphaned.add(viewChild);
> }
>
> View viewInMap = (View)viewToSemanticMap.get(semanticChild);
> if (viewInMap != null && !viewChild.equals(viewInMap)) {
> if (viewInMap.isMutable()) {
> orphaned.remove(viewChild);
> orphaned.add(viewInMap);
> viewToSemanticMap.put(semanticChild, viewChild);
> }
> }
> }
> return orphaned;
> }
>
>
> On Fri, 02 Feb 2007 10:40:18 -0500, Claude Popescu wrote:
>
>> In a diagram with nodes A,B,C and a connection M (A to B), I select the
>> connection M, then I change the target from B to C in the properties tab.
>>
>> I want the diagram to redraw the connection to the new target node, but I
>> don't know what API to use.
>>
>> For a GraphicalEditPart or ConnectionEditPart, this could be solved with
>> handleMajorSemanticChange(),
>>
>> but for the DiagramEditPart there is no such method.
>>
>> I tried refresh() on the DiagramEditPart , but nothing happens.
>>
>> I looked in the news group and I could not find answer.
>>
>> The only workaround is to close and reopen the diagram.
>>
>> The diagram is not updated as such in the mindmap, neither in the Taipan
>> examples.
>>
>> Thank you
>
Previous Topic:Coordinationsystem and GMF
Next Topic:disable _diagram file
Goto Forum:
  


Current Time: Tue Jun 10 01:44:37 EDT 2025

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

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

Back to the top