Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatilov2015-11-26 13:34:51 +0000
committerashatilov2015-11-26 13:34:51 +0000
commit97bb1e857fda0e58849bc9cddf66724ba054a16b (patch)
tree9c059262b212b3b9122791aae2ac0ea55d8eb7d4 /plugins/uml/diagram
parentea49a638875848683c765a1b74a90a490a7fd84e (diff)
downloadorg.eclipse.papyrus-97bb1e857fda0e58849bc9cddf66724ba054a16b.tar.gz
org.eclipse.papyrus-97bb1e857fda0e58849bc9cddf66724ba054a16b.tar.xz
org.eclipse.papyrus-97bb1e857fda0e58849bc9cddf66724ba054a16b.zip
Bug 462987 - [Composite Structure Diagram] Ports that are added
graphically to composites are placed in the upper left hand corner - remove diagram specific port locators (common port locator should be used) Change-Id: I2baf6eb590cf49ecbb5e32171a713c34f4379aee Signed-off-by: ashatilov <shatilov@montages.com>
Diffstat (limited to 'plugins/uml/diagram')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/locators/PortPositionLocator.java270
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/StructuredClassifierLayoutEditPolicy.java2
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/PortPositionLocator.java116
3 files changed, 1 insertions, 387 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/locators/PortPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/locators/PortPositionLocator.java
deleted file mode 100644
index 7b62513dafb..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.component/custom-src/org/eclipse/papyrus/uml/diagram/component/custom/locators/PortPositionLocator.java
+++ /dev/null
@@ -1,270 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009-2010 CEA LIST.
- *
- *
- * 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:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- * Vincent Lorenzo(CEA-List) vincent.lorenzo@cea.fr - getCurrentSideOfParent()
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.component.custom.locators;
-
-import org.eclipse.draw2d.ConnectionAnchor;
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.PositionConstants;
-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.SVGNodePlateFigure;
-import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.SlidableRoundedRectangleAnchor;
-
-// TODO: Auto-generated Javadoc
-/**
- * This class is used to constrain the position of Port when they are added on a Property or a
- * StructuredClassifier
- *
- * <pre>
- * +-------------------+
- * | [Class] |
- * +-------------------+
- * | |
- * | |
- * | +-+ - Expected position of Port
- * | +-+
- * | |
- * +-------------------+
- *
- * </pre>
- *
- * <pre>
- * TODO : The port is not re-sizable
- * </pre>
- *
- * .
- */
-@Deprecated
-// use org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator instead
-public class PortPositionLocator implements IBorderItemLocator {
-
- /** the figure around which this border item appears. */
- protected IFigure parentFigure = null;
-
- /** the width of the area surrounding the parent figure where border item can be put. */
- protected int borderItemOffset = 10;
-
- /**
- * get the parent figure.
- *
- * @return the parent figure
- */
- public IFigure getParentFigure() {
- return parentFigure;
- }
-
- /** the position constraint. */
- protected Rectangle constraint = new Rectangle(0, 0, 0, 0);
-
- /**
- * Constructor *.
- *
- * @param parentFigure
- * the parent figure
- * @param preferredSide
- * the preferred side
- */
- public PortPositionLocator(IFigure parentFigure, int preferredSide) {
- // The preferredSide parameter is not used, just kept here to ensure compatibility
- // with GMF generated code.
- this.parentFigure = parentFigure;
- }
-
- /**
- * Gets the valid location.
- *
- * @param proposedLocation
- * the proposed location
- * @param borderItem
- * the border item
- * @return a valid location
- * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getValidLocation(org.eclipse.draw2d.geometry.Rectangle, org.eclipse.draw2d.IFigure)
- */
- @Override
- public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) {
- return getPreferredLocation(proposedLocation);
- }
-
- /**
- * Gets the preferred location.
- *
- * @param proposedLocation
- * the proposed location
- * @return a possible location on parent figure border
- */
- public Rectangle getPreferredLocation(Rectangle proposedLocation) {
-
- // Initialize port location with proposed location
- // and resolve the bounds of it graphical parent
- Rectangle realLocation = new Rectangle(proposedLocation);
-
-
- Rectangle parentRec = getParentFigure().getBounds().getCopy();
-
- // Calculate Max position around the graphical parent (1/2 size or the port around
- // the graphical parent bounds.
- int xMin = parentRec.x - borderItemOffset;
- int xMax = parentRec.x - borderItemOffset + parentRec.width;
- int yMin = parentRec.y - borderItemOffset;
- int yMax = parentRec.y - borderItemOffset + parentRec.height;
-
- // Modify Port location if MAX X or Y are exceeded
- if (realLocation.x < xMin) {
- realLocation.x = xMin;
- }
-
- if (realLocation.x > xMax) {
- realLocation.x = xMax;
- }
-
- if (realLocation.y < yMin) {
- realLocation.y = yMin;
- }
-
- if (realLocation.y > yMax) {
- realLocation.y = yMax;
- }
-
- // Ensure the port is positioned on its parent borders and not in the middle.
- // Modify position if needed.
- if ((realLocation.y != yMin) && (realLocation.y != yMax)) {
- if ((realLocation.x != xMin) && (realLocation.x != xMax)) {
-
- if (realLocation.x <= (xMin + (parentRec.width / 2))) {
- realLocation.x = xMin;
- } else {
- realLocation.x = xMax;
- }
- }
- }
- // If it's a SVGNodePlate get the anchor to get the position
- if (parentFigure instanceof SVGNodePlateFigure) {
-
- // Translate location to absolute before calculate location Point
- parentFigure.translateToAbsolute(proposedLocation);
- parentFigure.translateToAbsolute(parentRec);
-
- // Get the anchor
- ConnectionAnchor connectionAnchor = ((SVGNodePlateFigure) parentFigure).getConnectionAnchor("");
-
- // Get the location point, with anchor.
- Point locationForPort = ((SlidableRoundedRectangleAnchor) connectionAnchor).getLocation(parentRec.getCenter(), proposedLocation.getLocation());
- if (locationForPort != null) {
- proposedLocation.setLocation(locationForPort);
- }
- // Translate to relative the location
- parentFigure.translateToRelative(proposedLocation);
-
- // Set the location
- realLocation.setLocation(proposedLocation.getLocation());
- }
-
- // Return constrained location
- return realLocation;
- }
-
- /**
- * Gets the current side of parent.
- *
- * @return the current side of parent
- * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getCurrentSideOfParent()
- * the position of the port around its parent. This position can be
- * <ul>
- * <li>{@linkplain PositionConstants#NORTH}</li>
- * <li> {@linkplain PositionConstants#SOUTH}</li>
- * <li> {@linkplain PositionConstants#EAST}</li>
- * <li> {@linkplain PositionConstants#WEST}</li>
- * <li> {@linkplain PositionConstants#NORTH_EAST}</li>
- * <li> {@linkplain PositionConstants#NORTH_WEST}</li>
- * <li> {@linkplain PositionConstants#SOUTH_EAST}</li>
- * <li> {@linkplain PositionConstants#SOUTH_WEST}</li>
- * </ul>
- */
- @Override
- public int getCurrentSideOfParent() {
- int position = PositionConstants.NONE;
-
- // we are not on EAST, not on WEST, but we are on the NORTH
- if ((constraint.x != parentFigure.getBounds().width - borderItemOffset) && (constraint.x != -this.borderItemOffset) && (constraint.y == -this.borderItemOffset)) {
- position = PositionConstants.NORTH;
-
- // we are not on the EAST and not on the WEST, but we are on the SOUTH
- } else if ((constraint.x != parentFigure.getBounds().width - borderItemOffset) && (constraint.x != -this.borderItemOffset) && (constraint.y == parentFigure.getBounds().height - borderItemOffset)) {
- position = PositionConstants.SOUTH;
-
- // we are on the EAST, but we are not on the NORTH and not on the SOUTH
- } else if ((constraint.x == parentFigure.getBounds().width - borderItemOffset) && (constraint.y != -this.borderItemOffset) && (constraint.y != parentFigure.getBounds().height - borderItemOffset)) {
- position = PositionConstants.EAST;
-
- // we are on the WEST, but we are not on the on the NORTH and not on the SOUTH
- } else if ((constraint.x == -this.borderItemOffset) && (constraint.y != -this.borderItemOffset) && (constraint.y != parentFigure.getBounds().height - borderItemOffset)) {
- position = PositionConstants.WEST;
-
- // we are on the NORTH and on the EAST
- } else if ((constraint.x == parentFigure.getBounds().width - borderItemOffset) && (constraint.y == -this.borderItemOffset)) {
- position = PositionConstants.NORTH_EAST;
-
- // we are on the NORTH and on the WEST
- } else if ((constraint.x == -this.borderItemOffset) && (constraint.y == -this.borderItemOffset)) {
- position = PositionConstants.NORTH_WEST;
-
- // we are on the EAST and on the SOUTH
- } else if ((constraint.x == parentFigure.getBounds().width - borderItemOffset) && (constraint.y == parentFigure.getBounds().height - borderItemOffset)) {
- position = PositionConstants.SOUTH_EAST;
-
- // we are on the WEST and on the SOUTH
- } else if ((constraint.x == -this.borderItemOffset) && (constraint.y == parentFigure.getBounds().height - borderItemOffset)) {
- position = PositionConstants.SOUTH_WEST;
- }
-
- return position;
- }
-
- /**
- * Sets the constraint.
- *
- * @param constraint
- * the new constraint
- * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#setConstraint(org.eclipse.draw2d.geometry.Rectangle)
- */
- @Override
- public void setConstraint(Rectangle constraint) {
- this.constraint = constraint;
-
- }
-
- /**
- * Relocate.
- *
- * @param target
- * the target
- * @see org.eclipse.draw2d.Locator#relocate(org.eclipse.draw2d.IFigure)
- */
- @Override
- public void relocate(IFigure target) {
-
- Rectangle proposedLocation = constraint.getCopy();
- proposedLocation.setLocation(constraint.getLocation().translate(parentFigure.getBounds().getTopLeft()));
-
- Point validLocation = getValidLocation(proposedLocation, target).getLocation();
-
- Dimension preferredSize = target.getPreferredSize();
- Rectangle rect = new Rectangle(validLocation, preferredSize);
- rect.translate(-preferredSize.width / 2, -preferredSize.height / 2);
-
- target.setBounds(rect);
- }
-}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/StructuredClassifierLayoutEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/StructuredClassifierLayoutEditPolicy.java
index 125a27ca166..9ddd4ee5c1a 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/StructuredClassifierLayoutEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/edit/policies/StructuredClassifierLayoutEditPolicy.java
@@ -36,7 +36,7 @@ import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
import org.eclipse.gmf.runtime.emf.commands.core.command.CompositeTransactionalCommand;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy;
-import org.eclipse.papyrus.uml.diagram.composite.custom.locators.PortPositionLocator;
+import org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.ClassCompositeEditPart;
import org.eclipse.papyrus.uml.diagram.composite.edit.parts.PortEditPart;
import org.eclipse.papyrus.uml.diagram.composite.part.UMLVisualIDRegistry;
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/PortPositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/PortPositionLocator.java
deleted file mode 100644
index 3e60359cb0e..00000000000
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.composite/custom-src/org/eclipse/papyrus/uml/diagram/composite/custom/locators/PortPositionLocator.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2009-2011 CEA LIST.
- *
- *
- * 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:
- * Yann Tanguy (CEA LIST) yann.tanguy@cea.fr - Initial API and implementation
- *
- *****************************************************************************/
-package org.eclipse.papyrus.uml.diagram.composite.custom.locators;
-
-import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
-import org.eclipse.papyrus.uml.diagram.composite.custom.preferences.CustomDiagramPreferencePage;
-import org.eclipse.papyrus.uml.diagram.composite.part.UMLDiagramEditorPlugin;
-
-/**
- * This class is used to constrain the position of Port when they are added on a Property or a
- * StructuredClassifier
- *
- * <pre>
- * +-------------------+
- * | [Class] |
- * +-------------------+
- * | |
- * | |
- * | +-+ - Expected position of Port
- * | +-+
- * | |
- * +-------------------+
- *
- * </pre>
- *
- * <pre>
- * TODO : The port is not re-sizable
- *
- */
-public class PortPositionLocator implements IBorderItemLocator {
-
- protected org.eclipse.papyrus.uml.diagram.common.locator.PortPositionLocator currentLocator = null;
- protected IFigure parentFigure;
- protected int preferredSide;
-
- /** Constructor **/
- public PortPositionLocator(IFigure parentFigure, int preferredSide) {
- currentLocator = new ExternalPortPositionLocator(parentFigure, preferredSide);
- this.parentFigure = parentFigure;
- this.preferredSide = preferredSide;
- }
-
- /**
- *
- * @see org.eclipse.gmf.runtime.draw2d.ui.figures.IBorderItemLocator#getValidLocation(org.eclipse.draw2d.geometry.Rectangle, org.eclipse.draw2d.IFigure)
- *
- * @param proposedLocation
- * @param borderItem
- * @return a valid location
- */
- @Override
- public Rectangle getValidLocation(Rectangle proposedLocation, IFigure borderItem) {
- updateLocator();
- return currentLocator.getValidLocation(proposedLocation, borderItem);
- }
-
- @Override
- public void setConstraint(Rectangle constraint) {
- updateLocator();
- currentLocator.setConstraint(constraint);
-
- }
-
- @Override
- public int getCurrentSideOfParent() {
- updateLocator();
- return currentLocator.getCurrentSideOfParent();
- }
-
- @Override
- public void relocate(IFigure target) {
- updateLocator();
- currentLocator.relocate(target);
-
- }
-
- public Rectangle getPreferredLocation(Rectangle proposedLocation) {
- return currentLocator.getPreferredLocation(proposedLocation);
- }
-
- public void setInternal() {
- if (currentLocator instanceof ExternalPortPositionLocator) {
- currentLocator = new InternalPortPositionLocator(parentFigure, preferredSide);
- }
- }
-
- public void setExternal() {
- if (currentLocator instanceof InternalPortPositionLocator) {
- currentLocator = new ExternalPortPositionLocator(parentFigure, preferredSide);
- }
- }
-
- protected void updateLocator() {
- boolean isInside = UMLDiagramEditorPlugin.getInstance().getPreferenceStore().getBoolean(CustomDiagramPreferencePage.IS_INSIDE_COMPOSITE_COMPOSITE_DIAGRAM);
- if (isInside) {
- setInternal();
- }
- else {
- setExternal();
- }
-
- }
-} \ No newline at end of file

Back to the top