{
context( SapphireDiagramEditorPagePart.class ).setShowGuides(showGuides);
}
ElementList<DiagramNodeLayout> nodes = this.layoutModel.getDiagramNodesLayout();
ConnectionService connService = context(SapphireDiagramEditorPagePart.class).service(ConnectionService.class);
for (DiagramNodeLayout node : nodes)
{
String nodeId = node.getNodeId().content();
DiagramNodePart nodePart = getNodePart(nodeId);
int x = node.getX().content();
int y = node.getY().content();
int width = node.getWidth().content();
int height = node.getHeight().content();
if (nodePart != null)
{
nodePart.setNodeBounds(new DiagramNodeBounds(x, y, width, height, false, false));
}
ElementList<DiagramConnectionLayout> connList = node.getEmbeddedConnectionsLayout();
for (DiagramConnectionLayout connLayout : connList)
{
String connId = connLayout.getConnectionId().content();
ElementList<DiagramBendPointLayout> bps = connLayout.getConnectionBendpoints();
DiagramConnectionPart connPart = getConnectionPart(connService, ConnectionHashKey.createKey(nodeId, connId));
if (connPart != null)
{
int index = 0;
for (DiagramBendPointLayout pt : bps)
{
connPart.addBendpoint(index++, pt.getX().content(), pt.getY().content());
}
if (connLayout.getLabelX().content(false) != null && connLayout.getLabelY().content(false) != null)
{
Point labelPos = new Point(connLayout.getLabelX().content(), connLayout.getLabelY().content());
connPart.setLabelPosition(labelPos);
}
}
}
}
ElementList<DiagramConnectionLayout> connList = this.layoutModel.getDiagramConnectionsLayout();
for (DiagramConnectionLayout connLayout : connList)
{
String connId = connLayout.getConnectionId().content();
DiagramConnectionPart connPart = getConnectionPart(connService, ConnectionHashKey.createKey(null, connId));
ElementList<DiagramBendPointLayout> bps = connLayout.getConnectionBendpoints();
if (connPart != null)
{
int index = 0;
for (DiagramBendPointLayout pt : bps)
{
connPart.addBendpoint(index++, pt.getX().content(), pt.getY().content());
}
List<Point> bendPoints = new ArrayList<Point>();
bendPoints.addAll(connPart.getBendpoints());
if (connLayout.getLabelX().content(false) != null &&
connLayout.getLabelY().content(false) != null)
{
Point labelPos = new Point(connLayout.getLabelX().content(),
connLayout.getLabelY().content());
connPart.setLabelPosition(labelPos);
}
}
}
// Listen on existing connection parts
for (DiagramConnectionPart connPart : connService.list())
{
connPart.attach(this.connectionPartListener);
}
}