Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Guilet2018-05-25 10:02:14 +0000
committerPierre-Charles David2018-05-28 12:31:04 +0000
commit91c0e6d93c910c0f6fac439a3d0384e2a73d005f (patch)
treec5c79b62a3b97605a24719be7ee88196e026c366
parenta9de3742c427de4cc28e434ea9f7a0852cacd8ee (diff)
downloadorg.eclipse.sirius-91c0e6d93c910c0f6fac439a3d0384e2a73d005f.tar.gz
org.eclipse.sirius-91c0e6d93c910c0f6fac439a3d0384e2a73d005f.tar.xz
org.eclipse.sirius-91c0e6d93c910c0f6fac439a3d0384e2a73d005f.zip
[530051] Fix decorator messing with tabbar zoom button
Zooming with tabbar zoom in or out button now ignores the synchronized decorator to make a correct zoom. Bug: 530051 Change-Id: Id9f67e7eb045c1cccf060bd5f7480b6f9a16a22f Signed-off-by: Pierre Guilet <pierre.guilet@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/part/DDiagramRootEditPart.java13
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusAnimatableZoomManager.java18
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusMouseWheelZoomHandler.java9
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/DiagramZoomTest.java35
4 files changed, 45 insertions, 30 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/part/DDiagramRootEditPart.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/part/DDiagramRootEditPart.java
index 6831b5b87a..5a329e0489 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/part/DDiagramRootEditPart.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/graphical/edit/part/DDiagramRootEditPart.java
@@ -42,8 +42,7 @@ public class DDiagramRootEditPart extends RenderedDiagramRootEditPart {
private SiriusAnimatableZoomManager siriusZoomManager;
/**
- * Copy of org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramRootEditPart.
- * zoomLevels
+ * Copy of org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramRootEditPart. zoomLevels
*/
private double[] siriusZoomLevels = { .05, .1, .25, .5, .75, 1, 1.25, 1.5, 1.75, 2, 4 };
@@ -58,9 +57,7 @@ public class DDiagramRootEditPart extends RenderedDiagramRootEditPart {
}
/**
- * Installs the
- * {@link org.eclipse.sirius.diagram.ui.tools.internal.routers.DForestRouter}
- * .
+ * Installs the {@link org.eclipse.sirius.diagram.ui.tools.internal.routers.DForestRouter} .
* <p>
* {@inheritDoc}
*/
@@ -114,7 +111,7 @@ public class DDiagramRootEditPart extends RenderedDiagramRootEditPart {
@Override
public void zoomIn(Point center) {
if (getZoomManager() instanceof SiriusAnimatableZoomManager) {
- ((SiriusAnimatableZoomManager) getZoomManager()).zoomTo(getZoomManager().getNextZoomLevel(), center);
+ ((SiriusAnimatableZoomManager) getZoomManager()).zoomTo(getZoomManager().getNextZoomLevel(), center, true);
}
}
@@ -126,14 +123,14 @@ public class DDiagramRootEditPart extends RenderedDiagramRootEditPart {
@Override
public void zoomOut(Point center) {
if (getZoomManager() instanceof SiriusAnimatableZoomManager) {
- ((SiriusAnimatableZoomManager) getZoomManager()).zoomTo(getZoomManager().getPreviousZoomLevel(), center);
+ ((SiriusAnimatableZoomManager) getZoomManager()).zoomTo(getZoomManager().getPreviousZoomLevel(), center, true);
}
}
@Override
public void zoomTo(double zoom, Point center) {
if (getZoomManager() instanceof SiriusAnimatableZoomManager) {
- ((SiriusAnimatableZoomManager) getZoomManager()).zoomTo(zoom, center);
+ ((SiriusAnimatableZoomManager) getZoomManager()).zoomTo(zoom, center, true);
}
}
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 730dd3ee24..49c84a0dec 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
@@ -143,13 +143,21 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
* <code>double</code> value where 1.0 represents 100%.
* @param zoomedPoint
* <code>Point</code> around which the zoom will be centered in absolute coordinates
+ * @param considerVolatileFigure
+ * true if volatile figures should be taken in consideration when computing the the new zoom area. False
+ * otherwise.
*/
- public void zoomTo(double zoom, Point zoomedPoint) {
- List<IFixedFigure> removedFigures = removeSynchronizationFigureFromDiagram();
+ public void zoomTo(double zoom, Point zoomedPoint, boolean considerVolatileFigure) {
+ List<IFixedFigure> removedFigures = null;
+ if (considerVolatileFigure) {
+ removedFigures = removeSynchronizationFigureFromDiagram();
+ }
Point zoomedPointCopy = zoomedPoint.getCopy();
getScalableFigure().translateToRelative(zoomedPointCopy);
primSetZoom(zoom, zoomedPointCopy);
- reAttachedFiguresOnDiagram(removedFigures);
+ if (considerVolatileFigure) {
+ reAttachedFiguresOnDiagram(removedFigures);
+ }
}
/**
@@ -168,7 +176,7 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
double scaleY = available.height * getZoom() / desired.height;
double zoom = Math.min(getMaxZoom(), Math.max(getMinZoom(), Math.min(scaleX, scaleY)));
- zoomTo(zoom, rect.getCenter());
+ zoomTo(zoom, rect.getCenter(), false);
reAttachedFiguresOnDiagram(removedFigures);
}
@@ -180,8 +188,10 @@ public class SiriusAnimatableZoomManager extends ZoomManager {
*/
@Override
protected void primSetZoom(double zoom) {
+ List<IFixedFigure> removedFigures = removeSynchronizationFigureFromDiagram();
Point center = getViewport().getClientArea().getCenter();
primSetZoom(zoom, center);
+ reAttachedFiguresOnDiagram(removedFigures);
}
/**
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusMouseWheelZoomHandler.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusMouseWheelZoomHandler.java
index cd1fcdade4..aa9d0cab7d 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusMouseWheelZoomHandler.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/SiriusMouseWheelZoomHandler.java
@@ -17,9 +17,8 @@ import org.eclipse.gef.editparts.ZoomManager;
import org.eclipse.swt.widgets.Event;
/**
- * A Sirius mouse wheel handler to zoom around the mouse location. This class is
- * a copy of {@link org.eclipse.gef.MouseWheelZoomHandler} to correctly handle
- * SiriusAnimatableZoomManager.
+ * A Sirius mouse wheel handler to zoom around the mouse location. This class is a copy of
+ * {@link org.eclipse.gef.MouseWheelZoomHandler} to correctly handle SiriusAnimatableZoomManager.
*
* @author fbarbin
* @author <a href="mailto:pierre.guilet@obeo.fr">Pierre Guilet</a>
@@ -52,7 +51,7 @@ public class SiriusMouseWheelZoomHandler implements MouseWheelHandler {
private void zoomOut(ZoomManager zoomMgr, Event event) {
if (zoomMgr instanceof SiriusAnimatableZoomManager) {
- ((SiriusAnimatableZoomManager) zoomMgr).zoomTo(zoomMgr.getPreviousZoomLevel(), new Point(event.x, event.y));
+ ((SiriusAnimatableZoomManager) zoomMgr).zoomTo(zoomMgr.getPreviousZoomLevel(), new Point(event.x, event.y), true);
} else {
zoomMgr.zoomOut();
}
@@ -61,7 +60,7 @@ public class SiriusMouseWheelZoomHandler implements MouseWheelHandler {
private void zoomIn(ZoomManager zoomMgr, Event event) {
if (zoomMgr instanceof SiriusAnimatableZoomManager) {
- ((SiriusAnimatableZoomManager) zoomMgr).zoomTo(zoomMgr.getNextZoomLevel(), new Point(event.x, event.y));
+ ((SiriusAnimatableZoomManager) zoomMgr).zoomTo(zoomMgr.getNextZoomLevel(), new Point(event.x, event.y), true);
} else {
zoomMgr.zoomIn();
}
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
index 491dc05dde..07883a950a 100644
--- 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
@@ -34,6 +34,7 @@ import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEdi
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
import org.eclipse.swt.SWT;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarButton;
/**
* Tests that diagram editor zooming is unaffected by synchronized decorator.
@@ -43,14 +44,12 @@ import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
*/
public class DiagramZoomTest extends AbstractSiriusSwtBotGefTestCase {
/**
- * Maximum distance on Y axis between the part at the lower position and the
- * decorator.
+ * 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.
+ * Maximum distance on X axis between the part at the lower position and the decorator.
*/
private static final int MAX_DISTANCE_X = 1100;
@@ -93,9 +92,21 @@ public class DiagramZoomTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
- * 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.
+ * Tests that the viewport is shifted to the right position after zoom done with constant with tabbar buttons when
+ * the synchronized decorator is present. The decorator should not impact the zoom.
+ */
+ public void testZoomWithSynchronizedDecoratorConstantWithTabbarZoomButtons() {
+ DiagramEditPart diagramPart = openDiagramEditorAndCheckDecorator();
+ SWTBotToolbarButton toolbarButton = editor.bot().toolbarButtonWithTooltip("Zoom In (Ctrl+=)");
+ toolbarButton.click();
+ toolbarButton.click();
+ toolbarButton.click();
+ checkExpected(diagramPart);
+ }
+
+ /**
+ * 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();
@@ -146,9 +157,8 @@ public class DiagramZoomTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
- * 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.
+ * 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();
@@ -160,9 +170,8 @@ public class DiagramZoomTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
- * 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.
+ * 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();

Back to the top