Community
Participate
Working Groups
Build Identifier: I20110519-1138 A NullpointerException is thrown when moving an EditPart from a FlowLayout or ToolbarLayout to XYLayout. In this case, GEFs XYLayoutEditPolicy return null in getCurrentConstraintFor() which is not handled in GMF XYLayoutEditPolicy. This can be reproduced in GMFs logic example. This is related to GEF bug #86473 Reproducible: Always Steps to Reproduce: 1. Create alogic example diagram 2. Create a Logic flow with a LED in it. 3. drag the LED outside of the logic flow -> the exception is thrown.
Created attachment 197790 [details] Patch for bug 349042 Patch attached...
There is a similar issue with edit parts that have a non-Rectangle constraint: java.lang.ClassCastException: org.eclipse.gmf.runtime.diagram.ui.figures.LabelLocator cannot be cast to org.eclipse.draw2d.geometry.Rectangle at org.eclipse.gef.editpolicies.XYLayoutEditPolicy.getCurrentConstraintFor(XYLayoutEditPolicy.java:102) at org.eclipse.gef.editpolicies.XYLayoutEditPolicy.getConstraintFor(XYLayoutEditPolicy.java:55) at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getConstraintFor(ConstrainedLayoutEditPolicy.java:244) at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getConstraintFor(XYLayoutEditPolicy.java:226) at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getAddCommand(ConstrainedLayoutEditPolicy.java:184) at org.eclipse.gef.editpolicies.LayoutEditPolicy.getCommand(LayoutEditPolicy.java:216) at org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy.getCommand(ConstrainedLayoutEditPolicy.java:214) at org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy.getCommand(XYLayoutEditPolicy.java:325) at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:502) at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1) at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482) at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328) at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477) at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy.getDropCommand(DragDropEditPolicy.java:112) at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DiagramDragDropEditPolicy.getDropCommand(DiagramDragDropEditPolicy.java:151) at org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy.getCommand(DragDropEditPolicy.java:75) at org.eclipse.gef.editparts.AbstractEditPart.getCommand(AbstractEditPart.java:502) at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.access$1(GraphicalEditPart.java:1) at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart$1.run(GraphicalEditPart.java:482) at org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl.runExclusive(TransactionalEditingDomainImpl.java:328) at org.eclipse.gmf.runtime.diagram.ui.editparts.GraphicalEditPart.getCommand(GraphicalEditPart.java:477) at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.getCommand(DragEditPartsTrackerEx.java:63) at org.eclipse.gef.tools.DragEditPartsTracker.handleDragInProgress(DragEditPartsTracker.java:370) at org.eclipse.gmf.runtime.diagram.ui.tools.DragEditPartsTrackerEx.handleDragInProgress(DragEditPartsTrackerEx.java:177) at org.eclipse.gef.tools.AbstractTool.mouseDrag(AbstractTool.java:1114) at org.eclipse.gef.tools.SelectionTool.mouseDrag(SelectionTool.java:538) at org.eclipse.gef.EditDomain.mouseDrag(EditDomain.java:259) You can reproduce this, for example, in the Tai Pan diagram editor: 1. Create a port and give it a name. 2. Click on the name to select it. 3. Move the cursor to the name's boundaries until the cursor changes into a cross with arrowheads. 4. Now grab the label and drag it around. 5. You will see the above ClassCastException. This issue can be fixed by adding the following to XYLayoutEditPolicy: @Override protected Rectangle getCurrentConstraintFor(GraphicalEditPart child) { IFigure figure = child.getFigure(); Object constraint = figure.getParent().getLayoutManager().getConstraint(figure); return constraint instanceof Rectangle ? (Rectangle) constraint : null; }
commit done 13/03/12