Community
Participate
Working Groups
NodeFigure.getSourceConnectionAnchorAt(Point) and NodeFigure.getTargetConnectionAnchor(Point) accept a null value and return the center of the figure if this is the case (see NodeFigure.createConnectionAnchor(Point)). But ShapeNodeEditPart, that invokes them via their getSourceConnectionAnchor(Request) and getTargetConnectionAnchor(Request) method implementations, throws an NPE if no anchors are specified. This is because these methods try to make a copy of the anchor location: ShapeNodeEditPart line 143 and 191: Point pt = ((DropRequest) request).getLocation().getCopy(); I think this copy is useless since NodeFigure.createConnectionAnchor(Point) already creates a copy of the point given as an argument. Furthermore, if you still prefer to work with a copy, please support the null location use case.
Created attachment 100895 [details] Null anchor support for the ShapeNodeEditPart
Created attachment 100897 [details] Null anchor support for the ShapeNodeEditPart This patch removes the copy done on the location point, what makes the null case ok. This copy is useless since getNodeFigure().getSourceConnectionAnchorAt(pt) and getNodeFigure().getTargetConnectionAnchorAt(pt) already (indirectly) make a copy if the given point is not null.
It is critical for us that this (minor) fix is included in Ganymede release. Can you include it? Thanks,
A workaround consists on overriding the methods getSourceConnectionAnchor(Request request) and getTargetConnectionAnchor(Request request) in your ShapeNodeEditPart implementations to support this case. @Override public ConnectionAnchor getSourceConnectionAnchor(Request request) { // Workaround for bug 225353 if (request instanceof ReconnectRequest) { if (((DropRequest) request).getLocation() == null) { return getNodeFigure().getSourceConnectionAnchorAt(null); } } return super.getSourceConnectionAnchor(request); } @Override public ConnectionAnchor getTargetConnectionAnchor(Request request) { // Workaround for bug 225353 if (request instanceof ReconnectRequest) { if (((DropRequest) request).getLocation() == null) { return getNodeFigure().getTargetConnectionAnchorAt(null); } } return super.getTargetConnectionAnchor(request); }
(In reply to comment #0) > > Furthermore, if you still prefer to work with a copy, please support the null > location use case. > Just to be completely paranoid, I would rather leave the getCopy() and just add the additional null check. Can you create a patch for this and we will get into GMF 2.1.2?
Created attachment 111932 [details] Null anchor support for the ShapeNodeEditPart
Committed to HEAD and R2_1_maintenance
[GMF Restructure] Bug 319140 : product GMF and component Runtime Diagram was the original product and component for this bug