Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpguilet2018-01-19 17:17:25 +0000
committerPierre Guilet2018-02-15 09:13:09 +0000
commitc74b96f51098514fc53e4ac91022891d77486fe4 (patch)
tree4ada7994a00e8a9e020ccfa9f36af32da664aa45
parent42ee8ff9babc9d50ff3e7a700c1b18bc3007e7bf (diff)
downloadorg.eclipse.sirius-c74b96f51098514fc53e4ac91022891d77486fe4.tar.gz
org.eclipse.sirius-c74b96f51098514fc53e4ac91022891d77486fe4.tar.xz
org.eclipse.sirius-c74b96f51098514fc53e4ac91022891d77486fe4.zip
[530051] Fix decorators messing with zoom
Lock and synchronization decorators don't interfere anymore with zoom functionality. Add corresponding test. Bug: 530051 Change-Id: I86b1e6ab5228987f37bc977896737bb91bdd761f Signed-off-by: pguilet <pierre.guilet@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java22
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/IFixedFigure.java28
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/SynchronizeStatusFigure.java10
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusAnimatableZoomManager.java69
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DiagramZoomTest.java203
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java14
6 files changed, 301 insertions, 45 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java
index 38f0bf8f89..fcf9eaa504 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/DiagramSemanticElementLockedNotificationFigure.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 THALES GLOBAL SERVICES.
+ * Copyright (c) 2011, 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -38,12 +38,11 @@ import org.eclipse.swt.graphics.RGB;
import com.google.common.collect.Iterables;
/**
- * A figure to display a lock notification for the semantic element represented
- * by a diagram.
+ * A figure to display a lock notification for the semantic element represented by a diagram.
*
* @author <a href="mailto:steve.monnier@obeo.fr">Steve Monnier</a>
*/
-public class DiagramSemanticElementLockedNotificationFigure extends Ellipse {
+public class DiagramSemanticElementLockedNotificationFigure extends Ellipse implements IFixedFigure {
/**
* Border color of the notification figure when locked by me.
@@ -116,6 +115,7 @@ public class DiagramSemanticElementLockedNotificationFigure extends Ellipse {
this.add(label);
propListener = new PropertyChangeListener() {
+ @Override
public void propertyChange(PropertyChangeEvent evt) {
updateLocation();
}
@@ -137,7 +137,8 @@ public class DiagramSemanticElementLockedNotificationFigure extends Ellipse {
this(rootEditPart, message, lockStatus, DEFAULT_HEIGHT, DEFAULT_WIDTH);
}
- private void updateLocation() {
+ @Override
+ public void updateLocation() {
Point viewLocation = viewport.getViewLocation().getCopy();
viewLocation.performScale(1.0d / rootEditPart.getZoomManager().getZoom());
@@ -161,12 +162,12 @@ public class DiagramSemanticElementLockedNotificationFigure extends Ellipse {
public void removeNotify() {
super.removeNotify();
viewport.removePropertyChangeListener(Viewport.PROPERTY_VIEW_LOCATION, propListener);
- viewport = null;
}
/**
* Override to use local coordinates. .{@inheritDoc}
*/
+ @Override
protected boolean useLocalCoordinates() {
return true;
}
@@ -237,7 +238,8 @@ public class DiagramSemanticElementLockedNotificationFigure extends Ellipse {
final LayeredPane pane = (LayeredPane) rootEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
List<IFigure> figuresToRemove = new ArrayList<>();
// Collects notification figures that needs to be removed
- for (DiagramSemanticElementLockedNotificationFigure diagramSemanticElementLockedNotificationFigure : Iterables.filter(pane.getChildren(), DiagramSemanticElementLockedNotificationFigure.class)) {
+ for (DiagramSemanticElementLockedNotificationFigure diagramSemanticElementLockedNotificationFigure : Iterables.filter(pane.getChildren(),
+ DiagramSemanticElementLockedNotificationFigure.class)) {
figuresToRemove.add(diagramSemanticElementLockedNotificationFigure);
}
// Removes these notation figures from Layer
@@ -251,6 +253,7 @@ public class DiagramSemanticElementLockedNotificationFigure extends Ellipse {
*
* @see org.eclipse.draw2d.Shape#paintFigure(org.eclipse.draw2d.Graphics)
*/
+ @Override
public void paintFigure(Graphics g) {
applyTransparency(g);
super.paintFigure(g);
@@ -297,9 +300,8 @@ public class DiagramSemanticElementLockedNotificationFigure extends Ellipse {
}
/**
- * Converts transparency value from percent range [0, 100] to alpha range
- * [0, 255] and applies converted value. 0% corresponds to alpha 255 and
- * 100% corresponds to alpha 0.
+ * Converts transparency value from percent range [0, 100] to alpha range [0, 255] and applies converted value. 0%
+ * corresponds to alpha 255 and 100% corresponds to alpha 0.
*
* @param g
* The Graphics used to paint
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/IFixedFigure.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/IFixedFigure.java
new file mode 100644
index 0000000000..d598c94878
--- /dev/null
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/IFixedFigure.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2018 THALES GLOBAL SERVICES and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.diagram.ui.tools.internal.figure;
+
+import org.eclipse.draw2d.IFigure;
+
+/**
+ *
+ * A fixed figure is a figure that has always the same position in a Sirius Diagram like {@link SynchronizeStatusFigure}
+ * and {@link DiagramSemanticElementLockedNotificationFigure}. This interface provides methods to update those figures.
+ *
+ * @author <a href=mailto:pierre.guilet@obeo.fr>Pierre Guilet</a>
+ *
+ */
+public interface IFixedFigure extends IFigure {
+ /**
+ * Update this figure location regarding its graphic context.
+ */
+ void updateLocation();
+}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/SynchronizeStatusFigure.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/SynchronizeStatusFigure.java
index 044a0de165..93e4577299 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/SynchronizeStatusFigure.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/figure/SynchronizeStatusFigure.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2017 THALES GLOBAL SERVICES.
+ * Copyright (c) 2017, 2018 THALES GLOBAL SERVICES.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -47,7 +47,7 @@ import org.eclipse.swt.graphics.RGB;
*
* @author <a href="mailto:laurent.fasani@obeo.fr">Laurent Fasani</a>
*/
-public class SynchronizeStatusFigure extends Ellipse {
+public class SynchronizeStatusFigure extends Ellipse implements IFixedFigure {
/**
* Border color of the notification figure when diagram is sync.
@@ -141,9 +141,7 @@ public class SynchronizeStatusFigure extends Ellipse {
}
}
- /**
- * Update the location of the figure according to viewport size and location.
- */
+ @Override
public void updateLocation() {
updateLocation(false);
}
@@ -190,9 +188,7 @@ public class SynchronizeStatusFigure extends Ellipse {
public void removeNotify() {
super.removeNotify();
viewport.removePropertyChangeListener(Viewport.PROPERTY_VIEW_LOCATION, propListener);
- viewport = null;
zoomManager.removeZoomListener(zoomListener);
- zoomManager = null;
executor.shutdown();
executor = null;
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusAnimatableZoomManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusAnimatableZoomManager.java
index 30aea8ab5f..730dd3ee24 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusAnimatableZoomManager.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusAnimatableZoomManager.java
@@ -1,5 +1,5 @@
/******************************************************************************
- * Copyright (c) 2004, 2016 IBM Corporation and others.
+ * Copyright (c) 2004, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,10 @@ package org.eclipse.sirius.diagram.ui.tools.internal.handler;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import org.eclipse.draw2d.FreeformLayeredPane;
import org.eclipse.draw2d.ScalableFigure;
import org.eclipse.draw2d.Viewport;
import org.eclipse.draw2d.geometry.Dimension;
@@ -24,18 +27,16 @@ import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.gmf.runtime.draw2d.ui.geometry.LineSeg;
import org.eclipse.gmf.runtime.draw2d.ui.internal.figures.AnimationModel;
import org.eclipse.gmf.runtime.gef.ui.internal.editparts.AnimatedZoomListener;
+import org.eclipse.sirius.diagram.ui.tools.internal.figure.IFixedFigure;
/**
- * Sirius zoom manager zooming on given point and not on view center. The code
- * is the same than
- * {@link org.eclipse.gmf.runtime.gef.ui.internal.editparts.AnimatableZoomManager}
- * except the method primAnimateSetZoom() that has been updated to zoom on point
- * and not center of view.
+ * Sirius zoom manager zooming on given point and not on view center. The code is the same than
+ * {@link org.eclipse.gmf.runtime.gef.ui.internal.editparts.AnimatableZoomManager} except the method
+ * primAnimateSetZoom() that has been updated to zoom on point and not center of view.
*
- * We don't extend AnimatableZoomManager because the updated method contains a
- * call to super that would make super super code duplication. Moreover due to
- * private method using the updated method a lot of override must be done if we
- * were extending this class.
+ * We don't extend AnimatableZoomManager because the updated method contains a call to super that would make super super
+ * code duplication. Moreover due to private method using the updated method a lot of override must be done if we were
+ * extending this class.
*
* @author <a href="mailto:pierre.guilet@obeo.fr">Pierre Guilet</a>
*
@@ -60,6 +61,29 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
super(pane, viewport);
}
+ @Override
+ public void setZoomAsText(String zoomString) {
+ List<IFixedFigure> removedFigures = removeSynchronizationFigureFromDiagram();
+ super.setZoomAsText(zoomString);
+ reAttachedFiguresOnDiagram(removedFigures);
+ }
+
+ private void reAttachedFiguresOnDiagram(List<IFixedFigure> removedFigures) {
+ FreeformLayeredPane freeformLayeredPane = (FreeformLayeredPane) getScalableFigure().getChildren().stream().filter(FreeformLayeredPane.class::isInstance).findFirst().get();
+ removedFigures.stream().forEach(fig -> {
+ freeformLayeredPane.add(fig);
+ fig.updateLocation();
+ });
+ }
+
+ private List<IFixedFigure> removeSynchronizationFigureFromDiagram() {
+ FreeformLayeredPane freeformLayeredPane = (FreeformLayeredPane) getScalableFigure().getChildren().stream().filter(FreeformLayeredPane.class::isInstance).findFirst().get();
+ Stream<IFixedFigure> volatileFigureStream = freeformLayeredPane.getChildren().stream().filter(IFixedFigure.class::isInstance).map(IFixedFigure.class::cast);
+ List<IFixedFigure> removedFigures = volatileFigureStream.collect(Collectors.toList());
+ removedFigures.stream().forEach((fig) -> freeformLayeredPane.remove(fig));
+ return removedFigures;
+ }
+
/**
* Returns the zoom animation style.
*
@@ -113,30 +137,30 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
}
/**
- * Allows implementators to zoom to a certain level centered around a given
- * point.
+ * Allows implementators to zoom to a certain level centered around a given point.
*
* @param zoom
* <code>double</code> value where 1.0 represents 100%.
* @param zoomedPoint
- * <code>Point</code> around which the zoom will be centered in
- * absolute coordinates
+ * <code>Point</code> around which the zoom will be centered in absolute coordinates
*/
public void zoomTo(double zoom, Point zoomedPoint) {
+ List<IFixedFigure> removedFigures = removeSynchronizationFigureFromDiagram();
Point zoomedPointCopy = zoomedPoint.getCopy();
getScalableFigure().translateToRelative(zoomedPointCopy);
primSetZoom(zoom, zoomedPointCopy);
+ reAttachedFiguresOnDiagram(removedFigures);
}
/**
* Allows implementors to zoom into or out to a rectangular area.
*
* @param rect
- * <code>Rectangle</code> that the edit part will zoom into our
- * out to in absolute coordinates.
+ * <code>Rectangle</code> that the edit part will zoom into our out to in absolute coordinates.
*/
@Override
public void zoomTo(Rectangle rect) {
+ List<IFixedFigure> removedFigures = removeSynchronizationFigureFromDiagram();
Dimension available = getViewport().getClientArea().getSize();
Dimension desired = rect.getSize();
@@ -145,6 +169,7 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
double zoom = Math.min(getMaxZoom(), Math.max(getMinZoom(), Math.min(scaleX, scaleY)));
zoomTo(zoom, rect.getCenter());
+ reAttachedFiguresOnDiagram(removedFigures);
}
/**
@@ -160,12 +185,11 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
}
/**
- * Calculate the animation duration based on the number of zoom increments
- * being traversed.
+ * Calculate the animation duration based on the number of zoom increments being traversed.
*
* @param zoom
- * @return <code>AnimationModel</code> that is appropriate for the zoom
- * difference between requested and the current zoom level.
+ * @return <code>AnimationModel</code> that is appropriate for the zoom difference between requested and the current
+ * zoom level.
*/
private AnimationModel calculateAnimationModel(double zoom) {
double dmod = Math.pow(zoom / getZoom(), (double) 1 / 8);
@@ -188,8 +212,8 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
}
/**
- * Performs the zoom with animation on the given point. I.e the given point
- * stay at the same position in the viewport after zoom.
+ * Performs the zoom with animation on the given point. I.e the given point stay at the same position in the
+ * viewport after zoom.
*
* @param zoomLevel
* the zoom level.
@@ -199,7 +223,6 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
* the animation model to use when doing the zoom.
*/
private void primAnimateSetZoom(double zoomLevel, Point pointToZoom, AnimationModel animationModel) {
-
double initialZoom = getZoom();
double finalZoom = zoomLevel;
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DiagramZoomTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DiagramZoomTest.java
new file mode 100644
index 0000000000..491dc05dde
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DiagramZoomTest.java
@@ -0,0 +1,203 @@
+/*******************************************************************************
+ * Copyright (c) 2016, 2018 THALES GLOBAL SERVICES.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.tests.swtbot;
+
+import java.util.Optional;
+
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.palette.ToolEntry;
+import org.eclipse.gef.ui.palette.PaletteViewer;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramRootEditPart;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.sirius.diagram.DDiagram;
+import org.eclipse.sirius.diagram.ui.tools.api.preferences.SiriusDiagramUiPreferencesKeys;
+import org.eclipse.sirius.diagram.ui.tools.internal.figure.SynchronizeStatusFigure;
+import org.eclipse.sirius.tests.support.api.ICondition;
+import org.eclipse.sirius.tests.support.api.TestsUtil;
+import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCase;
+import org.eclipse.sirius.tests.swtbot.support.api.business.UIDiagramRepresentation.ZoomLevel;
+import org.eclipse.sirius.tests.swtbot.support.api.business.UILocalSession;
+import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource;
+import org.eclipse.sirius.tests.swtbot.support.api.condition.CheckDiagramSelected;
+import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor;
+import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
+import org.eclipse.swt.SWT;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+
+/**
+ * Tests that diagram editor zooming is unaffected by synchronized decorator.
+ *
+ * @author <a href="mailto:pierre.guilet@obeo.fr">Pierre Guilet</a>
+ *
+ */
+public class DiagramZoomTest extends AbstractSiriusSwtBotGefTestCase {
+ /**
+ * Maximum distance on Y axis between the part at the lower position and the
+ * decorator.
+ */
+ private static final int MAX_DISTANCE_Y = 210;
+
+ /**
+ * Maximum distance on X axis between the part at the lower position and the
+ * decorator.
+ */
+ private static final int MAX_DISTANCE_X = 1100;
+
+ private static final String FILE_DIR = "/";
+
+ private static final String DIAGRAM_INSTANCE_NAME = "zoomMouseDiagram";
+
+ private static final String DIAGRAM_DESCRIPTION = "Diagram";
+
+ private static final String MODEL_FILE = "mouseZoomTest.ecore";
+
+ private static final String SESSION_FILE = "mouseZoomTest.aird";
+
+ private static final String VSM_FILE = "VSMForMouseZoomTest.odesign";
+
+ private static final String DATA_UNIT_DIR = "data/unit/mouseZoom/";
+
+ private SWTBotSiriusDiagramEditor editor;
+
+ private UIResource sessionAirdResource;
+
+ private UILocalSession localSession;
+
+ @Override
+ protected void onSetUpBeforeClosingWelcomePage() throws Exception {
+ copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL_FILE, SESSION_FILE, VSM_FILE);
+ }
+
+ @Override
+ protected void onSetUpAfterOpeningDesignerPerspective() throws Exception {
+ sessionAirdResource = new UIResource(designerProject, FILE_DIR, SESSION_FILE);
+ localSession = designerPerspective.openSessionFromFile(sessionAirdResource, true);
+
+ }
+
+ private void openDiagram(String descriptionName, String instanceName, ZoomLevel zoomLevel) {
+ editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), descriptionName, instanceName, DDiagram.class);
+ editor.zoom(zoomLevel);
+ SWTBotUtils.waitAllUiEvents();
+ }
+
+ /**
+ * Tests that the viewport is shifted to the right position after zoom done
+ * with constant when the synchronized decorator is present. The decorator
+ * should not impact the zoom.
+ */
+ public void testZoomWithSynchronizedDecoratorConstant() {
+ DiagramEditPart diagramPart = openDiagramEditorAndCheckDecorator();
+ editor.zoom(ZoomLevel.ZOOM_100);
+ checkExpected(diagramPart);
+ }
+
+ /**
+ * Checks that the zoom was done correctly.
+ *
+ * @param diagramPart
+ */
+ private void checkExpected(DiagramEditPart diagramPart) {
+ SWTBotUtils.waitAllUiEvents();
+ SWTBotGefEditPart bottomEditPart = editor.getEditPart("E");
+
+ TestsUtil.waitUntil(new ICondition() {
+
+ private int distanceBetweenPartAndDecoratorOnXaxis;
+
+ private int distanceBetweenPartAndDecoratorOnYaxis;
+
+ @Override
+ public boolean test() throws Exception {
+ // We test that the distance between the lower part and the
+ // decorator on X and Y axis is not too big that would be the
+ // sign it impacts zoom functionality.
+ int viewportWidth = diagramPart.getViewport().getHorizontalRangeModel().getMaximum();
+ int viewportHeight = diagramPart.getViewport().getVerticalRangeModel().getMaximum();
+ int bottomEditPartXPosition = ((GraphicalEditPart) bottomEditPart.part()).getFigure().getBounds().x;
+ int bottomEditPartYPosition = ((GraphicalEditPart) bottomEditPart.part()).getFigure().getBounds().y;
+ distanceBetweenPartAndDecoratorOnXaxis = viewportWidth - bottomEditPartXPosition;
+ distanceBetweenPartAndDecoratorOnYaxis = viewportHeight - bottomEditPartYPosition;
+ if (distanceBetweenPartAndDecoratorOnXaxis < MAX_DISTANCE_X && distanceBetweenPartAndDecoratorOnYaxis < MAX_DISTANCE_Y) {
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public String getFailureMessage() {
+ return "viewport after zoom is not correct. Synchronization decorator could have impacted the computing. Width is " + diagramPart.getViewport().getHorizontalRangeModel().getMaximum()
+ + ". And y is " + diagramPart.getViewport().getVerticalRangeModel().getMaximum() + ". Distance between E part and the decorator on x position is: "
+ + distanceBetweenPartAndDecoratorOnXaxis + " but should be lower. Distance between E part and the decorator on y position is: " + distanceBetweenPartAndDecoratorOnYaxis
+ + " but should be lower";
+ }
+ });
+ }
+
+ /**
+ * Tests that the viewport is shifted to the right position after zoom done
+ * with the mouse when the synchronized decorator is present. The decorator
+ * should not impact the zoom.
+ */
+ public void testMouseZoomWithSynchronizedDecorator() {
+ DiagramEditPart diagramPart = openDiagramEditorAndCheckDecorator();
+
+ editor.mouseScrollWithKey(diagramPart.getViewport().getHorizontalRangeModel().getMaximum(), diagramPart.getViewport().getVerticalRangeModel().getMaximum(), SWT.CTRL, 1);
+ editor.mouseScrollWithKey(diagramPart.getViewport().getHorizontalRangeModel().getMaximum(), diagramPart.getViewport().getVerticalRangeModel().getMaximum(), SWT.CTRL, 1);
+ editor.mouseScrollWithKey(diagramPart.getViewport().getHorizontalRangeModel().getMaximum(), diagramPart.getViewport().getVerticalRangeModel().getMaximum(), SWT.CTRL, 1);
+ checkExpected(diagramPart);
+ }
+
+ /**
+ * Tests that the viewport is shifted to the right position after zoom done
+ * with mouse rectangular selection when the synchronized decorator is
+ * present. The decorator should not impact the zoom.
+ */
+ public void testRectangularMouseZoomWithSynchronizedDecorator() {
+ DiagramEditPart diagramPart = openDiagramEditorAndCheckDecorator();
+
+ SWTBotGefEditPart paletteRootEditPartBot = editor.getPaletteRootEditPartBot();
+ SWTBotGefEditPart swtBotGefEditPart = null;
+ swtBotGefEditPart = paletteRootEditPartBot.children().iterator().next().children().get(0).children().get(1);
+ assertEquals("The wrong tool is used.", "ToolEntryEditPart( Palette Entry (Zoom In) )", swtBotGefEditPart.part().toString());
+ EditPart part = swtBotGefEditPart.part();
+ final PaletteViewer viewer = (PaletteViewer) swtBotGefEditPart.part().getViewer();
+ final ToolEntry toolEntry = (ToolEntry) part.getModel();
+ editor.bot().getDisplay().asyncExec(() -> {
+ viewer.setActiveTool(toolEntry);
+ });
+ editor.drag(new Point(0, 0), new Point(176, 176));
+ checkExpected(diagramPart);
+ }
+
+ /**
+ * Open the diagram editor and verify the synchronized decorator is present.
+ *
+ * @return the {@link DiagramEditPart} of the opened diagram.
+ */
+ private DiagramEditPart openDiagramEditorAndCheckDecorator() {
+ changeDiagramUIPreference(SiriusDiagramUiPreferencesKeys.PREF_SHOW_SYNCHRONIZE_STATUS_DECORATOR.name(), true);
+ openDiagram(DIAGRAM_DESCRIPTION, DIAGRAM_INSTANCE_NAME, ZoomLevel.ZOOM_25);
+
+ CheckDiagramSelected condition = new CheckDiagramSelected(editor);
+ editor.click(new Point(0, 0));
+ bot.waitUntil(condition);
+
+ DiagramEditPart diagramPart = (DiagramEditPart) ((IStructuredSelection) editor.getSelection()).getFirstElement();
+ Optional<SynchronizeStatusFigure> diagramSynchronizeStatusFigure = SynchronizeStatusFigure.getDiagramSynchronizeStatusFigure((DiagramRootEditPart) diagramPart.getParent());
+ assertTrue("The synchronization decorator is missing.", diagramSynchronizeStatusFigure.isPresent());
+ SWTBotUtils.waitAllUiEvents();
+ return diagramPart;
+ }
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
index c6d0d84ddb..fd86d9bc09 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/suite/AllTestSuite.java
@@ -162,6 +162,7 @@ public class AllTestSuite extends TestCase {
suite.addTestSuite(CompartmentsDragAndDropTest.class);
suite.addTestSuite(EdgeSelectionTest.class);
suite.addTestSuite(DiagramMouseZoomTest.class);
+ suite.addTestSuite(DiagramZoomTest.class);
suite.addTestSuite(EdgeLabelsMoveFromEdgeMoveTest.class);
suite.addTestSuite(OpeningContextTest.class);
suite.addTestSuite(NodeWithDecoratorSelectionTest.class);
@@ -228,8 +229,9 @@ public class AllTestSuite extends TestCase {
}
/**
- * Add the first part of the SWTbot tests to the specified suite. This corresponds roughly to the first half of the
- * execution time of the complete suite.
+ * Add the first part of the SWTbot tests to the specified suite. This
+ * corresponds roughly to the first half of the execution time of the
+ * complete suite.
*
* @param suite
* the suite into which to add the tests.
@@ -306,8 +308,9 @@ public class AllTestSuite extends TestCase {
}
/**
- * Add the second part of the SWTbot tests to the specified suite. This corresponds roughly to the second half of
- * the execution time of the complete suite.
+ * Add the second part of the SWTbot tests to the specified suite. This
+ * corresponds roughly to the second half of the execution time of the
+ * complete suite.
*
* @param suite
* the suite into which to add the tests.
@@ -437,7 +440,8 @@ public class AllTestSuite extends TestCase {
}
/**
- * Creates the {@link junit.framework.TestSuite TestSuite} for all the disabled test.
+ * Creates the {@link junit.framework.TestSuite TestSuite} for all the
+ * disabled test.
*
* @return The test suite containing all the disabled tests.
*/

Back to the top