Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 124862

Summary: DragEditPartsTracker falls on null pointer exception in method getOperationSet()
Product: [Tools] GEF Reporter: Martin Kollar <KollarM>
Component: GEF-Legacy GEF (MVC)Assignee: gef-inbox <gef-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: nyssen
Version: 3.2   
Target Milestone: 3.2.0 (Callisto) RC1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Martin Kollar CLA 2006-01-23 10:28:57 EST
I have my own TextDragTracker that extends DragEditPartsTracker.
When I create in instnace of this TextEditPart, I call at first super(EditPart)
and then setTargetEditPart(EditPart)

public TextDragTracker(EditPart owner, Point startLocation) {
        super(owner);
        setTargetEditPart(getSourceEditPart());
        setDefaultCursor(Cursors.IBEAM);
        if (startLocation != null)
            setStartLocation(startLocation);
    }

But setTargetEditPart(...) calls getOperationSet() and that calls createOperationSet() and this falls on null pointer exception because getCurrentViewer() returns null. In GEF3.1 this worked becasue there was no updating of "the current snap-to strategy"
Comment 1 Pratik Shah CLA 2006-01-25 13:44:37 EST
The tracker expects the target editpart to be set only when something's happening (button down, key down, etc), which implies that there's a current viewer.  Why do you need to set the target editpart, right away?  What does your TextDragTracker do?  Something similar to the SelectionRangeDragTracker in the text example?
Comment 2 Alexander Nyßen CLA 2010-04-09 17:01:43 EDT
Current implementation of createOperationSet method is as follows:

protected List createOperationSet() {
    if (getCurrentViewer() != null) {
       List list = ToolUtilities.getSelectionWithoutDependants(
               getCurrentViewer());
       ToolUtilities.filterEditPartsUnderstanding(list, getTargetRequest());
       return list;
    }

    return new ArrayList();
}

The NULL-check (getCurrentViewer() != null) was introduced as part of the fix for bug #106780. It obviously also solved this issue, so marking it as fixed in 3.2RC1 as well.