Skip to content

Commit

Permalink
[426] Fix border nodes tests regression
Browse files Browse the repository at this point in the history
Analysis: It seems that before, the code with comment "manage location
of bordered node with closest side", in GMFHelper.getAbsoluteLocation,
is called only in specific circumstances. Since recent changes, it was
called systematically, but that shouldn't be the case.

This commit also reduces the number of getAbsoluBounds methods to ease
the impact analysis.

Bug: #426
  • Loading branch information
lredor committed Sep 11, 2024
1 parent f002c92 commit 466d537
Show file tree
Hide file tree
Showing 16 changed files with 103 additions and 99 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Range getVerticalRange() {
result = CacheHelper.getViewToRangeCache().get(node);
}
if (result == null) {
Rectangle absoluteBounds = GMFHelper.getAbsoluteBounds(node);
Rectangle absoluteBounds = GMFHelper.getAbsoluteBounds(node, false, false, false, true);
int y = absoluteBounds.y;
int height = absoluteBounds.height;
// GMFHelper.getAbsoluteBounds() use default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private void updateEdge(DEdge dEdge) {

private void computeEdgeDataWithoutEdgeLayoutData() {
Point firstClick = new Point(0, 0);
Rectangle sourceBounds = GMFHelper.getAbsoluteBounds((Node) source);
Rectangle sourceBounds = GMFHelper.getAbsoluteBounds((Node) source, false, false, false, true);
if (source.getElement() instanceof AbstractDNode) {
AbstractDNode sourceDNode = (AbstractDNode) source.getElement();
if (sourceDNode.eContainer() instanceof AbstractDNode) {
Expand Down Expand Up @@ -181,7 +181,7 @@ private void computeEdgeDataWithoutEdgeLayoutData() {
sourceTerminal = "(" + sourceRelativeLocation.preciseX() + "," + sourceRelativeLocation.preciseY() + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$

Point secondClick = new Point(0, 0);
Rectangle targetBounds = GMFHelper.getAbsoluteBounds((Node) target);
Rectangle targetBounds = GMFHelper.getAbsoluteBounds((Node) target, false, false, false, true);

if (target.getElement() instanceof AbstractDNode) {
AbstractDNode targetDNode = (AbstractDNode) target.getElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ private Option<Rectangle> getParentBorder() {
* @return The rectangle used for handles
*/
public Rectangle getHandleBounds() {
return GMFHelper.getAbsoluteBounds(node, true, true);
return GMFHelper.getAbsoluteBounds(node, true, true, false, false);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private void avoidOverlaps(Diagram diagram) {
Location location = (Location) layoutConstraint;
constraint = new Rectangle(location.getX(), location.getY(), -1, -1);
}
Point parentAbsoluteLocation = GMFHelper.getAbsoluteLocation(parentNode);
Point parentAbsoluteLocation = GMFHelper.getAbsoluteLocation(parentNode, false, false);
constraint.translate(parentAbsoluteLocation.x, parentAbsoluteLocation.y);
final Point realLocation = borderItemLocator.getValidLocation(constraint, node, otherBorderedNodesToIgnore);
final Dimension d = realLocation.getDifference(parentAbsoluteLocation);
Expand Down Expand Up @@ -215,7 +215,7 @@ private void migrateGraphicalFiltersAndGMFBounds(Diagram diagram) {
LayoutConstraint layoutConstraint = node.getLayoutConstraint();
if (layoutConstraint instanceof Bounds) {
Bounds bounds = (Bounds) layoutConstraint;
Rectangle rectBounds = GMFHelper.getAbsoluteBounds(node);
Rectangle rectBounds = GMFHelper.getAbsoluteBounds(node, false, false, false, true);
// The GMF node size must be stored in collapse
// filter (to can set this size
// when this node is expanded).
Expand Down Expand Up @@ -287,6 +287,7 @@ private void migrateChildrenOfCollapsedNode(Diagram diagram) {
* </UL>
*/
private static class IsStandardDiagramPredicate implements Predicate<Diagram> {
@Override
public boolean apply(Diagram input) {
boolean apply = false;
if (input.getElement() instanceof DDiagram) {
Expand All @@ -311,6 +312,7 @@ public boolean apply(Diagram input) {
*/
private static class IsBorderedNodePredicate implements Predicate<Node> {

@Override
public boolean apply(Node input) {
// Is this node the main view of a DNode and a border
// node ?
Expand All @@ -327,6 +329,7 @@ public boolean apply(Node input) {
*/

private static class IsDirectlyCollapsedNodePredicate implements Predicate<Node> {
@Override
public boolean apply(Node input) {
boolean apply = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ private boolean isOverlapped(Node node, StraightenToCommandData data) {
// the move. It should be the same as the one stored in GMF but
// sometimes, probably caused by some bugs, it could be wrong in
// GMF.
Point parentAbsoluteLocation = GMFHelper.getAbsoluteLocation(parentNode);
Point parentAbsoluteLocation = GMFHelper.getAbsoluteLocation(parentNode, false, true);
Rectangle initialAsboluteConstraint = initialRelativeConstraint.getTranslated(parentAbsoluteLocation);
Point validInitialAbsoluteLocation = borderItemLocator.getValidLocation(initialAsboluteConstraint, node, new ArrayList<Node>(Arrays.asList(node)));
Rectangle validInitialAbsoluteConstraint = initialAsboluteConstraint.getCopy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ private LayoutDataResult updateAbstractDNode_ownedBorderedNodes_Bounds(View crea
locator.setConstraint(constraint);
dummyFigure.setVisible(true);
final Rectangle rect = new Rectangle(constraint);
Point parentAbsoluteLocation = GMFHelper.getAbsoluteLocation(parentNode, true);
Point parentAbsoluteLocation = GMFHelper.getAbsoluteLocation(parentNode, true, false);
rect.translate(parentAbsoluteLocation.x, parentAbsoluteLocation.y);
dummyFigure.setBounds(rect);
final Point realLocation = locator.getValidLocation(rect, createdNode, new ArrayList<Node>(Arrays.asList(createdNode)));
Expand Down Expand Up @@ -666,7 +666,7 @@ private LayoutDataResult updateAbstractDNode_ownedBorderedNodes_Bounds(View crea

// CanonicalDBorderItemLocator works with absolute GMF parent
// location so we need to translate BorderedNode absolute location.
final org.eclipse.draw2d.geometry.Point parentAbsoluteLocation = GMFHelper.getAbsoluteBounds(parentNode).getTopLeft();
final org.eclipse.draw2d.geometry.Point parentAbsoluteLocation = GMFHelper.getAbsoluteBounds(parentNode, false, false, false, false).getTopLeft();
final Point realLocation = locator.getValidLocation(new Rectangle(location.getTranslated(parentAbsoluteLocation), size), createdNode, Collections.singleton(createdNode));

// Compute the new relative position to the parent
Expand Down
Loading

0 comments on commit 466d537

Please sign in to comment.