diff --git a/src/org/ntlab/deltaViewer/CollaborationViewer.java b/src/org/ntlab/deltaViewer/CollaborationViewer.java index 2cfe039..d23bfc6 100644 --- a/src/org/ntlab/deltaViewer/CollaborationViewer.java +++ b/src/org/ntlab/deltaViewer/CollaborationViewer.java @@ -541,7 +541,7 @@ } - if (srcClassName != null && fieldName != null && !edgeMap.containsKey(srcClassName + "." + fieldName)) { + if (srcClassName != null && fieldName != null && !edgeMap.containsKey(curAliasObjId + "." + fieldName)) { // Judge AliasList contains relatedPoint. (If contains not to create edge.) if (rpIndex < relatedPoints.size() - 1) { TracePoint rp = relatedPoints.get(rpIndex); @@ -569,7 +569,9 @@ Point2D absPtSrcCell = getAbsolutePointforCell((mxICell)srcCell); Point2D absPtDstCell = getAbsolutePointforCell((mxICell)dstCell); setEdgePoint((mxICell)edge, absPtSrcCell, absPtDstCell); - edgeMap.put(srcClassName + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); + edgeMap.put(curAliasObjId + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); + } else { + edgeMap.put(curAliasObjId + "." + fieldName, new Edge(fieldName, TypeName.PreReference, curAliasObjId, nextAliasObjId)); } } finally { mxgraph.getModel().endUpdate(); diff --git a/src/org/ntlab/deltaViewer/DeltaViewer.java b/src/org/ntlab/deltaViewer/DeltaViewer.java index 7a96622..5087049 100644 --- a/src/org/ntlab/deltaViewer/DeltaViewer.java +++ b/src/org/ntlab/deltaViewer/DeltaViewer.java @@ -585,7 +585,7 @@ System.out.println("ARRAY " + srcClassName + "(" + curAlias.getObjectId() + ") -> " + "(" + nextAlias.getObjectId() + "), " + fieldName); } } - if (srcClassName != null && fieldName != null && srcClassName != null && !edgeMap.containsKey(srcClassName + "." + fieldName)) { + if (srcClassName != null && fieldName != null && srcClassName != null && !edgeMap.containsKey(curAlias.getObjectId() + "." + fieldName)) { // Add a vertex to the graph in a transactional fashion. The vertex is actually a 'cell' in jgraphx terminology. mxgraph.getModel().beginUpdate(); try { @@ -598,7 +598,7 @@ Point2D absPtSrcCell = getAbsolutePointforCell((mxICell)srcCell); Point2D absPtDstCell = getAbsolutePointforCell((mxICell)dstCell); setEdgePoint((mxICell)edge, absPtSrcCell, absPtDstCell); - edgeMap.put(srcClassName + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); + edgeMap.put(curAlias.getObjectId() + "." + fieldName, new Edge(fieldName, TypeName.Reference, edge)); } } finally { mxgraph.getModel().endUpdate(); diff --git a/src/org/ntlab/deltaViewer/Edge.java b/src/org/ntlab/deltaViewer/Edge.java index bcc3c95..8d343a0 100644 --- a/src/org/ntlab/deltaViewer/Edge.java +++ b/src/org/ntlab/deltaViewer/Edge.java @@ -8,9 +8,12 @@ public class Edge { String label; TypeName typeName; - Object cell; + Object cell; // edge cell + String srcObjId; // source object id to create the edge later + String dstObjId; // destination object id to create the edge later protected enum TypeName { + PreReference, // object will be referred later Reference, // object reference Create, // create object reference Call // method call @@ -26,6 +29,13 @@ this.typeName = typeName; this.cell = cell; } + + public Edge(String label, TypeName typeName, String srcObjId, String dstObjId) { + this.label = label; + this.typeName = typeName; + this.srcObjId = srcObjId; + this.dstObjId = dstObjId; + } public String getLabel() { return label; @@ -51,4 +61,19 @@ this.cell = cell; } + public String getSrcObjeId() { + return srcObjId; + } + + public void setSrcObjId(String srcObjId) { + this.srcObjId = srcObjId; + } + + public String getDstObjeId() { + return dstObjId; + } + + public void setDstObjeId(String dstObjId) { + this.dstObjId = dstObjId; + } } diff --git a/src/org/ntlab/deltaViewer/MagnetRONViewer.java b/src/org/ntlab/deltaViewer/MagnetRONViewer.java index 81e5760..d7e7094 100644 --- a/src/org/ntlab/deltaViewer/MagnetRONViewer.java +++ b/src/org/ntlab/deltaViewer/MagnetRONViewer.java @@ -269,7 +269,25 @@ "fillColor=white"); objectVertex.setCell(ovCell); mxICell edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldName, null, srcCell, ovCell); - edgeMap.put(methodExec.getThisClassName() + "." + fieldName, new Edge(fieldName, TypeName.Create, edge)); + edgeMap.put(alias.getObjectId() + "." + fieldName, new Edge(fieldName, TypeName.Create, edge)); + for (String edgeKey: edgeMap.keySet()) { + Edge e = edgeMap.get(edgeKey); + if (edgeKey.startsWith(alias.getObjectId() + ".") && e.getTypeName() == Edge.TypeName.PreReference) { + mxICell dstCell = (mxICell) objectToVertexMap.get(e.getDstObjeId()).getCell(); + String fieldNames[] = edgeKey.split("."); + mxICell edge2 = null; + if (fieldNames.length < 2) { + edge2 = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), "", "", ovCell, dstCell); + } else { + edge2 = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldNames[1], fieldNames[1], ovCell, dstCell); + } + Point2D absPtSrcCell = getAbsolutePointforCell((mxICell)ovCell); + Point2D absPtDstCell = getAbsolutePointforCell((mxICell)dstCell); + setEdgePoint((mxICell)edge2, absPtSrcCell, absPtDstCell); + e.setTypeName(Edge.TypeName.Reference); + e.setCell(edge2); + } + } update(); } finally { mxgraph.getModel().endUpdate(); @@ -321,7 +339,25 @@ "fillColor=white"); objectVertex.setCell(ovCell); mxICell edge = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldName, null, srcCell, ovCell); - edgeMap.put(methodExec.getThisClassName() + "." + fieldName, new Edge(fieldName, TypeName.Create, edge)); + edgeMap.put(alias.getObjectId() + "." + fieldName, new Edge(fieldName, TypeName.Create, edge)); + for (String edgeKey: edgeMap.keySet()) { + Edge e = edgeMap.get(edgeKey); + if (edgeKey.startsWith(alias.getObjectId() + ".") && e.getTypeName() == Edge.TypeName.PreReference) { + mxICell dstCell = (mxICell) objectToVertexMap.get(e.getDstObjeId()).getCell(); + String fieldNames[] = edgeKey.split("."); + mxICell edge2 = null; + if (fieldNames.length < 2) { + edge2 = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), "", "", ovCell, dstCell); + } else { + edge2 = (mxICell) mxgraph.insertDeltaEdge(getMxDefaultParent(), fieldNames[1], fieldNames[1], ovCell, dstCell); + } + Point2D absPtSrcCell = getAbsolutePointforCell((mxICell)ovCell); + Point2D absPtDstCell = getAbsolutePointforCell((mxICell)dstCell); + setEdgePoint((mxICell)edge2, absPtSrcCell, absPtDstCell); + e.setTypeName(Edge.TypeName.Reference); + e.setCell(edge2); + } + } update(); } finally { mxgraph.getModel().endUpdate(); @@ -368,7 +404,7 @@ srcCell, dstCell); edge.setStyle("strokeColor=red;"); // mxgraph.orderCells(true, new Object[] {edge}); - edgeMap.put(fieldUpdateStatement.getFieldName(), new Edge(fieldName, TypeName.Reference, edge)); + edgeMap.put(fieldUpdateStatement.getContainerObjId(), new Edge(fieldName, TypeName.Reference, edge)); } finally { mxgraph.getModel().endUpdate(); }