diff options
author | Mickael ADAM | 2014-12-11 10:10:44 +0000 |
---|---|---|
committer | Mickael ADAM | 2014-12-11 10:44:14 +0000 |
commit | 85785b7900e513a0d47ba435349a613f5f8d1ad0 (patch) | |
tree | e5ea20e24c7f756a4383fec17773d776bc61894b | |
parent | e1c761448c1c7f66b5382d6945a9b67b79daa866 (diff) | |
download | org.eclipse.papyrus-85785b7900e513a0d47ba435349a613f5f8d1ad0.tar.gz org.eclipse.papyrus-85785b7900e513a0d47ba435349a613f5f8d1ad0.tar.xz org.eclipse.papyrus-85785b7900e513a0d47ba435349a613f5f8d1ad0.zip |
436547: [Diagram] All shapes shall be refactored
https://bugs.eclipse.org/bugs/show_bug.cgi?id=436547
-Fix tests regression
-Fix bad behavoir for no-refactored port from sysml diagram
Change-Id: I1bd883b0b99bd63f59611e54b7266e9ef421d4fb
Signed-off-by: Mickael ADAM <mickael.adam@ALL4TEC.net>
2 files changed, 22 insertions, 16 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java index 92c28384530..93c1e2ec40f 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/editparts/RoundedBorderNamedElementEditPart.java @@ -1,6 +1,7 @@ package org.eclipse.papyrus.uml.diagram.common.editparts; import org.eclipse.draw2d.Graphics; +import org.eclipse.gmf.runtime.diagram.ui.editparts.AbstractBorderedShapeEditPart; import org.eclipse.gmf.runtime.notation.View; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IRoundedRectangleFigure; import org.eclipse.papyrus.infra.gmfdiag.common.helper.PapyrusRoundedEditPartHelper; @@ -157,12 +158,12 @@ public abstract class RoundedBorderNamedElementEditPart extends BorderNamedEleme } /** - * Refresh the port position + * Refresh the port position */ private void refreshPortPosition() { if (getPrimaryShape() instanceof IRoundedRectangleFigure) { if (getModel() instanceof View) { - Object constraint = ((RoundedCompartmentEditPart) getParent()).getBorderedFigure().getBorderItemContainer().getLayoutManager().getConstraint(getFigure()); + Object constraint = ((AbstractBorderedShapeEditPart) getParent()).getBorderedFigure().getBorderItemContainer().getLayoutManager().getConstraint(getFigure()); if (constraint instanceof PortPositionLocator) { PortPositionLocator portLocator = (PortPositionLocator) constraint; String position = NotationUtils.getStringValue((View) getModel(), PORT_POSITION, "onLine"); diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java index 19f293587dd..0a18f5b1487 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common/src/org/eclipse/papyrus/uml/diagram/common/locator/PortPositionLocator.java @@ -20,8 +20,10 @@ import org.eclipse.draw2d.geometry.Dimension; import org.eclipse.draw2d.geometry.Point; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.RoundedRectangleNodePlateFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SVGNodePlateFigure; import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SlidableRoundedRectangleAnchor; +import org.eclipse.papyrus.infra.gmfdiag.common.utils.FigureUtils; /** * @@ -120,27 +122,25 @@ public class PortPositionLocator implements IBorderItemLocator { // Initialize port location with proposed location // and resolve the bounds of it graphical parent + Rectangle realLocation = new Rectangle(proposedLocation); Rectangle parentRec = getParentFigure().getBounds().getCopy(); // If it's a SVGNodePlate get the anchor to get the position - if (parentFigure instanceof SVGNodePlateFigure) { + if (parentFigure instanceof SVGNodePlateFigure && ((SVGNodePlateFigure) parentFigure).getConnectionAnchor("") instanceof SlidableRoundedRectangleAnchor) { // Translate location to absolute before calculate location Point parentFigure.translateToAbsolute(proposedLocation); parentFigure.translateToAbsolute(parentRec); ConnectionAnchor connectionAnchor = ((SVGNodePlateFigure) parentFigure).getConnectionAnchor(""); - - if (connectionAnchor instanceof SlidableRoundedRectangleAnchor) { - // Get the location point, with anchor. - ((SlidableRoundedRectangleAnchor) connectionAnchor).setOffset(getPortOffset()); - Point locationForPort = ((SlidableRoundedRectangleAnchor) connectionAnchor).getLocation(parentRec.getCenter(), proposedLocation.getLocation()); - ((SlidableRoundedRectangleAnchor) connectionAnchor).setOffset(new Dimension()); - if (locationForPort != null) { - proposedLocation.setLocation(locationForPort); - } + // Get the location point, with anchor. + ((SlidableRoundedRectangleAnchor) connectionAnchor).setOffset(getPortOffset()); + Point locationForPort = ((SlidableRoundedRectangleAnchor) connectionAnchor).getLocation(parentRec.getCenter(), proposedLocation.getLocation()); + ((SlidableRoundedRectangleAnchor) connectionAnchor).setOffset(new Dimension()); + if (locationForPort != null) { + proposedLocation.setLocation(locationForPort); } // Translate to relative the location @@ -316,14 +316,19 @@ public class PortPositionLocator implements IBorderItemLocator { if (figure == null) { figure = target; } + Rectangle proposedLocation = constraint.getCopy(); proposedLocation.setLocation(constraint.getLocation().translate(parentFigure.getBounds().getTopLeft())); Point validLocation = getValidLocation(proposedLocation, target).getLocation(); + if (FigureUtils.findChildFigureInstance(figure, RoundedRectangleNodePlateFigure.class) != null) { - Dimension preferredSize = target.getPreferredSize(); - Rectangle rect = new Rectangle(validLocation, preferredSize); - rect.translate(-preferredSize.width / 2, -preferredSize.height / 2); - target.setBounds(rect); + Dimension preferredSize = target.getPreferredSize(); + Rectangle rect = new Rectangle(validLocation, preferredSize); + rect.translate(-preferredSize.width / 2, -preferredSize.height / 2); + target.setBounds(rect); + } else { + target.setBounds(new Rectangle(validLocation, target.getPreferredSize())); + } } } |