diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java index 2253a40689..46c9031a2e 100644 --- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java +++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/refresh/GMFHelper.java @@ -19,6 +19,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; +import java.util.ListIterator; import java.util.Map; import java.util.Optional; import java.util.stream.Stream; @@ -104,9 +105,6 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.ui.IEditorPart; -import com.google.common.collect.Iterables; -import com.google.common.collect.Iterators; - /** * GMF Helper. * @@ -244,16 +242,18 @@ public static Point getAbsoluteLocation(Node node, boolean insetsAware, boolean return location; } - private static Node getPreviousChild(Node node) { + private static Node getPreviousChild(Node searchedNode) { Node previousChild = null; boolean found = false; - if (node.eContainer() instanceof Node container) { - for (Iterator children = Iterators.filter(container.getChildren().iterator(), Node.class); children.hasNext() && !found; /* */) { - Node child = children.next(); - if (node == child) { - found = true; - } else { - previousChild = child; + if (searchedNode.eContainer() instanceof Node container) { + for (Iterator children = container.getChildren().iterator(); children.hasNext() && !found; /* */) { + View child = children.next(); + if (child instanceof Node nodeChild) { + if (searchedNode == nodeChild) { + found = true; + } else { + previousChild = nodeChild; + } } } } @@ -489,8 +489,8 @@ private static boolean hasFullLabelBorder(DDiagramElementContainer ddec) { private static boolean isFirstRegion(DDiagramElementContainer ddec) { EObject potentialRegionContainer = ddec.eContainer(); if (potentialRegionContainer instanceof DNodeContainer dNodeContainer) { - Iterable regions = Iterables.filter((dNodeContainer).getOwnedDiagramElements(), DDiagramElementContainer.class); - return !Iterables.isEmpty(regions) && ddec == Iterables.getFirst(regions, null); + Optional optionalDDiagramElement = dNodeContainer.getOwnedDiagramElements().stream().filter(DDiagramElementContainer.class::isInstance).findFirst(); + return optionalDDiagramElement.isPresent() && ddec == optionalDDiagramElement.get(); } return false; } @@ -907,10 +907,10 @@ private static void replaceAutoSize(Node node, PrecisionRectangle bounds, boolea private static int getBorderNodesSides(Node container, Rectangle containerChildrenBounds) { int result = PositionConstants.NONE; - for (Iterator children = Iterators.filter(container.getChildren().iterator(), Node.class); children.hasNext(); /* */) { - Node child = children.next(); - if (new NodeQuery(child).isBorderedNode()) { - Rectangle borderNodeBounds = getAbsoluteBounds(child, true, false, false, false); + for (ListIterator children = container.getChildren().listIterator(); children.hasNext(); /* */) { + View child = children.next(); + if (child instanceof Node nodeChild && new NodeQuery(nodeChild).isBorderedNode()) { + Rectangle borderNodeBounds = getAbsoluteBounds(nodeChild, true, false, false, false); if (borderNodeBounds.preciseX() == containerChildrenBounds.preciseX()) { result = result | PositionConstants.LEFT; } @@ -986,11 +986,11 @@ private static Rectangle getChildrenBounds(Node container, boolean considerBorde result = getAbsoluteBounds(lastChild, true, false, true, false); } } else { - for (Iterator children = Iterators.filter(container.getChildren().iterator(), Node.class); children.hasNext(); /* */) { - Node nodeChild = children.next(); + for (ListIterator children = container.getChildren().listIterator(); children.hasNext(); /* */) { + View child = children.next(); // The border nodes are ignored, except if it is expected to consider it (auto-size of a container with // children having border nodes) - if (considerBorderNodes || !(new NodeQuery(nodeChild).isBorderedNode())) { + if (child instanceof Node nodeChild && (considerBorderNodes || !(new NodeQuery(nodeChild).isBorderedNode()))) { Rectangle childAbsoluteBounds = getAbsoluteBounds(nodeChild, true, false, true, false); if (result == null) { result = childAbsoluteBounds.getCopy();