Bug 209416 - DirectEditManager incorrectly follows EditParts Figure
Summary: DirectEditManager incorrectly follows EditParts Figure
Status: NEW
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: 3.3.1   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: gef-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-10 11:04 EST by Rene CLA
Modified: 2013-10-17 09:49 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rene CLA 2007-11-10 11:04:59 EST
Build ID: M20071023-1652

Steps To Reproduce:
1. create an EditPart derivative with a Figure that has a Label as child
2. create a CellEditorLocator derivative that uses the Label's bounds as location information.
3. enable direct edit on the EditPart
4. call performRequest( new DirectEditRequest() ) from the EditPart's activate()


More information:
DirectEditManager.hookListeners() registers an ancestorListener with the EditPart's Figure:
	getEditPart().getFigure().addAncestorListener(ancestorListener);

The ancestor listener moves the CellEditor when the EditPart's Figure is moved.
However, in common cases, the EditPart consist of a compound figure, and you actually want to edit one of the children of  the EditPart's figure. That is, the location of the CellEditor is dependent on the location of the child, not the parent. Therefor, it should register an ancestorListener  on the child, not on the parent.

Due to the way layoutManagers work, the ancestorListener for the parent is called before the children are layed out. Therefore, the CellEditor's Locator may have incorrect information about the location of children.

I run into this bug when I wanted to do an automatic direct edit after creation of an EditPart. So I called performRequest(new DirectEditRequest()) from the EditPart's activate().
The bug may also occur in designs where the location of the child within the parent can vary.

One possible solution could be to pass the Label as a parameter to the DirectEditManager (either in the constructor or in show()). Another would be to let the CellEditorLocator register the ancestorListener. In the latter case, a "dispose()" should be added to the CellEditorLocator interface, so it has a chance to remove the listener again.
Comment 1 Randy Hudson CLA 2007-11-10 15:59:12 EST
We just encountered the same problem 2 weeks ago with a nested Label centered inside the editpart's main figure.

Our workaround was to subclass DirectEditManager, and add a layoutListener to the editpart's figure, and on postLayout callback, call placeCellEditor().

I prefer the new constructor parameter, along with some refactoring of the class in general.

Pratik, can you work with Marc on merging our code into a patch for GEF?
Comment 2 Pratik Shah CLA 2008-01-15 09:36:08 EST
Randy, do you remember what editpart was causing this problem?
Comment 3 Alexander Nyßen CLA 2013-10-17 09:49:43 EDT
Assigning back to gef-inbox (and state to new), as specified assignee is no current GEF committer.