Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 335955 - synchronized connections don't become visible/invisible
Summary: synchronized connections don't become visible/invisible
Status: RESOLVED DUPLICATE of bug 314670
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 2.3.0   Edit
Hardware: PC Windows 7
: P5 blocker
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-01 08:51 EST by Christian Waniek CLA
Modified: 2011-02-11 08:56 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Waniek CLA 2011-02-01 08:51:30 EST
I have a simple diagram, where I have nodes (all of the same type) and between these nodes there can be a links (). The diagram is synchronized.

First scenario:
I create two nodes. Then I create a link between them in the model file and save the model file. The diagram is now marked as dirty but even if I save the diagram, the link doesn't appear in the diagram. Closing and reopening the diagram marks the diagram as dirty again.
-> If I edit the method createConnections() in the CanonicalEditPolicy so the links are created as persisted connections, afer closing and reopening the diagram the link is visible.

Second scenario:
Same thing happens when I delete an existing link in the model file. The link in the diagram is only marked with a cross with a circle around it. If I close and reopen the diagram the link has gone, no matter whether I have edited the CanonicalEditpolicy before or not.

This is very annoying, 'cause we rely on this behavior.
Comment 1 Christian Waniek CLA 2011-02-01 09:10:29 EST
If anyone knows a workaraound for this problem (e.g. overwrite a template), then it would be great if this workaraound could be posted here, so I can adapt it until the bug is fixed in GMF directly.
Comment 2 Christian Waniek CLA 2011-02-02 10:31:24 EST
Because we need a solution for this problem fast, I set the priority to P5.
Comment 3 Christian Waniek CLA 2011-02-08 07:09:51 EST
As a workaround for the first scenario you can include the following code in the handleNotifications() method of the DiagramEditPart. Maybe yu have to replace Connector by Edge.


@Override
protected void handleNotificationEvent(Notification event) {
    super.handleNotificationEvent(event);

    // FIXME Workaround for the case that there exists an Edge 
    // in the semantic model, but not yet in the notation
    // model. So we need to render the Edge on the fly.
    Object newValue = event.getNewValue();
    if (newValue instanceof Connector) {
        Map<View, EditPart> registry = getViewer().getEditPartRegistry();
        Connector connector = (Connector) newValue;
        // if the connection edit part already exists, 
        //just do nothing and return
        if (registry.get(connector) != null) {
            return;
        }
        EditPart sourceEditPart = registry.get(connector.getSource());
        EditPart targetEditPart = registry.get(connector.getTarget());
        // trigger an explicit refresh to create the connection edit part 
        // and draw the link
        if (sourceEditPart != null && targetEditPart != null) {
            sourceEditPart.refresh();
            targetEditPart.refresh();
        }
    }
}


With this workaround links, which doesn't exist in the diagram but in the model file, are synchronized to the diagram. Once the link exists it can be edited in the diagram editor as you would expect it.
Comment 4 Christian Waniek CLA 2011-02-11 08:56:32 EST
The problem has been fixed in the 2.4.0M5 build.

*** This bug has been marked as a duplicate of bug 314670 ***