Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Barbin2014-10-03 14:41:15 +0000
committerFlorian Barbin2014-10-13 15:05:11 +0000
commit976ea09d8e54e2e50be3537d2360a595faf0e30b (patch)
treea79efc6385fc7b980b5d8af3394b7eb9119afa18
parenta82a4b1018b7922b7a1772c03533eb888e9c75d9 (diff)
downloadorg.eclipse.sirius-976ea09d8e54e2e50be3537d2360a595faf0e30b.tar.gz
org.eclipse.sirius-976ea09d8e54e2e50be3537d2360a595faf0e30b.tar.xz
org.eclipse.sirius-976ea09d8e54e2e50be3537d2360a595faf0e30b.zip
[444569] Fix issue with hidden edges because of scroll bar.
* Some edges can be masked because of a scrollbar on a container. If one of the edge end is masked by the scroll size, the edge is masked too. The OrthogonalLayout doesn't relocate the masked edges and that causes wrong diagram bounds computation and persistent scroll bar if the old edge location is out of the current bounds. Bug: 444569 Change-Id: If9e00cdc273f05cd897c6fb22d6080f53aececd0 Signed-off-by: Florian Barbin <florian.barbin@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/ResetOriginEditPolicy.java5
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ResetOriginChangeModelOperation.java62
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/ResetOriginHandler.java8
3 files changed, 58 insertions, 17 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/ResetOriginEditPolicy.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/ResetOriginEditPolicy.java
index 2dfd2ffeec..9441fb8e39 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/ResetOriginEditPolicy.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/graphical/edit/policies/ResetOriginEditPolicy.java
@@ -17,6 +17,7 @@ import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.AbstractEditPolicy;
import org.eclipse.gmf.runtime.common.core.command.ICommand;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.IDDiagramEditPart;
import org.eclipse.sirius.diagram.ui.internal.operation.ResetOriginChangeModelOperation;
import org.eclipse.sirius.diagram.ui.tools.api.requests.RequestConstants;
@@ -39,8 +40,8 @@ public class ResetOriginEditPolicy extends AbstractEditPolicy {
public Command getCommand(Request request) {
if (understandsRequest(request)) {
EditPart editPart = getHost();
- if (editPart instanceof IDDiagramEditPart) {
- ResetOriginChangeModelOperation operation = new ResetOriginChangeModelOperation((IDDiagramEditPart) editPart);
+ if (editPart instanceof DiagramEditPart) {
+ ResetOriginChangeModelOperation operation = new ResetOriginChangeModelOperation((DiagramEditPart) editPart);
ICommand command = CommandFactory.createICommand(((IDDiagramEditPart) editPart).getEditingDomain(), operation);
return new ICommandProxy(command);
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ResetOriginChangeModelOperation.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ResetOriginChangeModelOperation.java
index 4623626eed..094f6a0304 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ResetOriginChangeModelOperation.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/internal/operation/ResetOriginChangeModelOperation.java
@@ -11,24 +11,28 @@
package org.eclipse.sirius.diagram.ui.internal.operation;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PolylineConnection;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.editparts.AbstractConnectionEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.render.util.DiagramImageUtils;
import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Location;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.sirius.diagram.ui.business.internal.operation.AbstractModelChangeOperation;
-import org.eclipse.sirius.diagram.ui.edit.api.part.IDDiagramEditPart;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -41,10 +45,12 @@ import com.google.common.collect.Lists;
*/
public class ResetOriginChangeModelOperation extends AbstractModelChangeOperation<Void> {
- private IDDiagramEditPart diagramEditPart;
+ private DiagramEditPart diagramEditPart;
private int MARGIN = 20;
+ private List<Connection> maskedConnections = new ArrayList<Connection>();
+
/**
* Constructor to perform this operation by using the displayed figures
* bounds.
@@ -52,7 +58,7 @@ public class ResetOriginChangeModelOperation extends AbstractModelChangeOperatio
* @param diagramEditPart
* the root Diagram EditPart.
*/
- public ResetOriginChangeModelOperation(IDDiagramEditPart diagramEditPart) {
+ public ResetOriginChangeModelOperation(DiagramEditPart diagramEditPart) {
this.diagramEditPart = diagramEditPart;
}
@@ -63,11 +69,48 @@ public class ResetOriginChangeModelOperation extends AbstractModelChangeOperatio
@Override
public Void execute() {
+ routeInvalidEdges();
Point topLeft = getTopLeftCoordinates();
shiftAllTopDiagramElements(topLeft);
+ if (!topLeft.equals(new Point(0, 0))) {
+ for (Connection currentConnection : maskedConnections) {
+ // we use this workaround because of the masked edges which are
+ // not
+ // routed when we perform the reset origin. If we do not
+ // translate masked edges points, the figure is still located as
+ // before the reset origin and that causes persistent scroll-bar
+ // if the old location is out of the viewer bounds.
+ currentConnection.getPoints().performTranslate(-topLeft.x, -topLeft.y);
+ }
+ }
return null;
}
+ /**
+ * Layout masked edges to have the correct bounds.<br />
+ * Some edges can be masked because of a scrollbar on a container. If one of
+ * the edge end is masked by the scroll size, the edge is masked too. The
+ * OrthogonalLayout doesn't relocate the masked edges and that causes wrong
+ * diagram bounds computation and persistent scroll bar if the old edge
+ * location is out of the current bounds.
+ */
+ private void routeInvalidEdges() {
+ List<ConnectionEditPart> connections = diagramEditPart.getConnections();
+ for (ConnectionEditPart connection : connections) {
+ IFigure figure = connection.getFigure();
+ Object model = connection.getModel();
+ if (figure instanceof PolylineConnection && model instanceof Edge) {
+ if (!figure.isVisible() && ((Edge) model).isVisible()) {
+ figure.setVisible(true);
+ ((PolylineConnection) figure).layout();
+ figure.setVisible(false);
+ maskedConnections.add((Connection) figure);
+ }
+ }
+ }
+
+ }
+
private void shiftAllTopDiagramElements(Point topLeft) {
Object model = this.diagramEditPart.getModel();
if (model instanceof Diagram) {
@@ -86,14 +129,11 @@ public class ResetOriginChangeModelOperation extends AbstractModelChangeOperatio
}
private Point getTopLeftCoordinates() {
- if (diagramEditPart instanceof DiagramEditPart) {
- List<?> primaryEditParts = ((DiagramEditPart) diagramEditPart).getPrimaryEditParts();
- removeInvalidEdges(primaryEditParts);
- Iterable<IGraphicalEditPart> iterable = Iterables.filter(primaryEditParts, IGraphicalEditPart.class);
- Rectangle bounds = DiagramImageUtils.calculateImageRectangle(Lists.newArrayList(iterable), MARGIN, new Dimension(0, 0));
- return bounds.getLocation();
- }
- return new Point(MARGIN, MARGIN);
+ List<?> primaryEditParts = diagramEditPart.getPrimaryEditParts();
+ removeInvalidEdges(primaryEditParts);
+ Iterable<IGraphicalEditPart> iterable = Iterables.filter(primaryEditParts, IGraphicalEditPart.class);
+ Rectangle bounds = DiagramImageUtils.calculateImageRectangle(Lists.newArrayList(iterable), MARGIN, new Dimension(0, 0));
+ return bounds.getLocation();
}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/ResetOriginHandler.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/ResetOriginHandler.java
index e767a66d0e..18d7fd2544 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/ResetOriginHandler.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/handler/ResetOriginHandler.java
@@ -17,10 +17,10 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CommandStack;
+import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramCommandStack;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.sirius.diagram.ui.edit.api.part.IDDiagramEditPart;
import org.eclipse.sirius.diagram.ui.tools.api.requests.RequestConstants;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -39,14 +39,14 @@ public class ResetOriginHandler extends AbstractHandler {
IWorkbenchPart workbenchPart = HandlerUtil.getActivePart(event);
if (selection instanceof StructuredSelection) {
Object firstElement = ((StructuredSelection) selection).getFirstElement();
- if (firstElement instanceof IDDiagramEditPart) {
- getAndExecuteCmd((IDDiagramEditPart) firstElement, workbenchPart);
+ if (firstElement instanceof DiagramEditPart) {
+ getAndExecuteCmd((DiagramEditPart) firstElement, workbenchPart);
}
}
return null;
}
- private void getAndExecuteCmd(IDDiagramEditPart selection, IWorkbenchPart workbenchPart) {
+ private void getAndExecuteCmd(DiagramEditPart selection, IWorkbenchPart workbenchPart) {
Command command = selection.getCommand(new Request(RequestConstants.REQ_RESET_ORIGIN));
DiagramCommandStack commandStack = getDiagramCommandStack(workbenchPart);
if (commandStack != null) {

Back to the top