Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320852 - [EditPolicy] Refactoring of ConstrainedLayoutEditPolicy and XYLayoutEditPolicy to remove duplicate code and ensure consistency
Summary: [EditPolicy] Refactoring of ConstrainedLayoutEditPolicy and XYLayoutEditPolic...
Status: RESOLVED FIXED
Alias: None
Product: GEF
Classification: Tools
Component: GEF-Legacy GEF (MVC) (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7.1 (Indigo) M2   Edit
Assignee: Alexander Nyßen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 67541
  Show dependency tree
 
Reported: 2010-07-25 14:21 EDT by Alexander Nyßen CLA
Modified: 2011-01-26 03:48 EST (History)
0 users

See Also:
nyssen: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Nyßen CLA 2010-07-25 14:21:01 EDT
ConstrainedLayoutEditPolicy and XYLayoutEditPolicy contain a lot of duplicate code, some TODO's, as well as an inconsistency w.r.t of calculating constraints for clone requests (in difference to getConstraintFor, which is used by ChangeBoundsRequest, getConstraintForClone misses a translateFromParent() call on the layout container). A refactoring is necessary.
Comment 1 Alexander Nyßen CLA 2010-07-25 14:40:24 EDT
Performed a major refactoring, which removes all todos and duplicate code and better aligns ConstrainedLayoutEditPolicy and XYLayoutEditPolicy. Ensured API remains consistent and backwards compatibility is achieved. Validated refactoring by manual testing with Logic Editor.

In detail, the following was changed:

- Introduced createAddCommand(ChangeBoundsRequest, EditPart, Object) to ConstrainedLayoutEditPolicy, which is now by default called by getAddCommand(EditPart) and delegates to createAddCommand(EditPart, Object). Removed overwritten getAddCommand(EditPart) within LogicXYLayoutEditPolicy, which performed just the same.

- Introduced translateToLayoutRelative to ConstrainedEditPolicy to comprise all duplicate code fragments that were related to this calculation procedure. It is now used from getConstraintFor(ChangeBoundsRequest, GraphicalEditPart) and getConstraintFor(CreateRequest). Fixed inconsistency within getConstraintForClone in this context as well, deprecated it, and made its single caller LogicXYLayoutEditPolicy use getConstraintFor instead.

- Introduced getChangeConstraintCommand method for clarity. It is used from within getResizeChildrenCommand (getMoveChildrenCommand and getAlignChildrenCommand still delegate to getResizeChildrenCommand only for purpose of backwards compatibility, but should be changed to delegate to getChangeConstraintCommand in future as well).

- Introduced new constructor to PrecisionRectangle, taking Point and Dimension, which is now used in getConstraintFor(CreateRequest). 

- Introduced getConstraintFor(Request, GraphicalEditPart, Rectangle), which is now directly called by getConstraintFor(ChangeBoundsRequest, GraphicalEditPart) and getConstraintFor(CreateRequest) and performs the delegation to getConstraintFor(Point) and getConstraintFor(Rectangle). Changed that XYLayoutEditPolicy overwrites this method to ensure that preferred sizes and minimum sizes are maintained, instead of overwriting getConstraintFor(ChangeBoundsRequest, GraphicalEditPart) directly. This way, calculation from superclass can be used and duplicate code could be removed. 

- Increased version number of org.eclipse.gef plug-in, org.eclipse.gef.examples.logic, as well as related features to 3.7.0.