| Summary: | DragEditPartsTracker NullPointerException in updateTargetRequest | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Eric Kop <koperic> | ||||
| Component: | GEF-Legacy GEF (MVC) | Assignee: | Anthony Hunter <ahunter.eclipse> | ||||
| Status: | RESOLVED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P2 | CC: | ahunter.eclipse, hudsonr | ||||
| Version: | 3.2 | ||||||
| Target Milestone: | 3.2.2 (Callisto SR2) | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Can you provide steps to reproduce the problem? Did you select both a child and its parent, and drag from the child? Steps:
1) Create circuit containing an LED
2) Select both circuit and LED
3) Drag starting from LED
Possible workaround. In your editpart's getDragTracker() method, find the highest parent or ancestor editpart that is part of the viewer's selection, and forward getDragTracker() to that editpart.
EditPart walker = getParent();
EditPart highestSelected = this;
while (walker != null) {
if (walker.getSelected() != EditPart.SELECTED_NONE)
highestSelected = walker;
walker = walker.getParent();
}
return new DragEditPartsTracker(highestSelected);
Please let us know if this workaround works, so we can adjust the priority as appropriate.
(In reply to comment #2) > Steps: > 1) Create circuit containing an LED > 2) Select both circuit and LED > 3) Drag starting from LED > Possible workaround. In your editpart's getDragTracker() method, find the > highest parent or ancestor editpart that is part of the viewer's selection, and > forward getDragTracker() to that editpart. > EditPart walker = getParent(); > EditPart highestSelected = this; > while (walker != null) { > if (walker.getSelected() != EditPart.SELECTED_NONE) > highestSelected = walker; > walker = walker.getParent(); > } > return new DragEditPartsTracker(highestSelected); > Please let us know if this workaround works, so we can adjust the priority as > appropriate. I need a selection for dragging (highest parent) and a selection to activate a properties page (child) The workaround is fine, although I needed to do more than that. The piece of code that was removed, I had added that originally as a fail-safe. But then I couldn't think of a case where the selected part wouldn't be in the operation set, and marked it as to be removed, not realizing that the operation set didn't include children of selected editparts. I think we can just add that code back again. There is a place where the sourceRectangle is *sometimes* assigned. I think the best fix is to make sure it is always assigned. This makes the code easier to understand, and avoids the same code getting removed again in the future. I saw that GEF 3.2.2 was released yesterday. Is it possible to re-run that build with the fix for this bug included? Or a 3.2.2.1? At the very least, this should be fixed in HEAD. Yes, I can apply this fix to 3.2.2 and respin the final 3.2.2 build. I have attached a patch, please confirm this is what we want just so we are all on the same page. Created attachment 58561 [details]
DragEditPartsTracker patch
Committed to R32_Maintenance (3.2.2) and HEAD (3.3) |
I get a NullPointerException in the method updateTargetRequest, because the sourceRectangle = null. In 3.1.1 the sourceLocation was always set in the method captureSourceDimensions, but that piece of code has been removed. Why? In updateTargetRequest: "if (snapToHelper != null && !getCurrentInput().isModKeyDown(MODIFIER_IGNORE_SNAP)) { PrecisionRectangle baseRect = sourceRectangle.getPreciseCopy();" In captureSourceDimensions of 3.1.1 (not in 3.2): "/* @TODO:Pratik Remove this for 3.2 */ if (sourceRectangle == null) { IFigure figure = ((GraphicalEditPart)getSourceEditPart()).getFigure(); if (figure instanceof HandleBounds) sourceRectangle = new PrecisionRectangle( ((HandleBounds)figure).getHandleBounds()); else sourceRectangle = new PrecisionRectangle(figure.getBounds()); figure.translateToAbsolute(sourceRectangle); }"