Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauline DEVILLE2017-08-09 12:37:45 +0000
committerJeremie Tatibouet2017-09-01 12:38:40 +0000
commit4f99ac85cda6a1e00d50bfdd22af6de1919f32d4 (patch)
tree20b4a9033acbeb1a79915c73621c72a42776b071 /plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus
parent911d78adea35b8833b036b495b7bfb00a5a8439a (diff)
downloadorg.eclipse.papyrus-4f99ac85cda6a1e00d50bfdd22af6de1919f32d4.tar.gz
org.eclipse.papyrus-4f99ac85cda6a1e00d50bfdd22af6de1919f32d4.tar.xz
org.eclipse.papyrus-4f99ac85cda6a1e00d50bfdd22af6de1919f32d4.zip
Bug 520325 - [ActivityDiagram] Bad initial position for an activity
parameter node created from the palette -Add CREATION_ROLE editPolicy on ActivityEditPart -Change ActivityParameterNodePositionLocation behavior (to be on the correct side when don't click on the side of the activity) Change-Id: I7b2bf658c8f96fa49f5cad66d604ee5a183e63c4 Signed-off-by: Pauline DEVILLE <pauline.deville@cea.fr>
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivitySideAffixedNodesCreationEditPolicy.java37
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/locator/ActivityParameterNodePositionLocator.java38
2 files changed, 57 insertions, 18 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivitySideAffixedNodesCreationEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivitySideAffixedNodesCreationEditPolicy.java
new file mode 100644
index 00000000000..1c7a82d11a1
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/edit/policies/ActivitySideAffixedNodesCreationEditPolicy.java
@@ -0,0 +1,37 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST 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:
+ * Pauline DEVILLE (CEA LIST) - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.uml.diagram.activity.edit.policies;
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.papyrus.uml.diagram.activity.locator.ActivityParameterNodePositionLocator;
+import org.eclipse.papyrus.uml.diagram.common.editpolicies.SideAffixedNodesCreationEditPolicy;
+import org.eclipse.papyrus.uml.diagram.common.locator.ISideAffixedNodeBorderItemLocator;
+
+/**
+ * This class extends {@link SideAffixedNodesCreationEditPolicy} to redefine the PositionLocator
+ * and use the {@link ActivityParameterNodePositionLocator}
+ */
+public class ActivitySideAffixedNodesCreationEditPolicy extends SideAffixedNodesCreationEditPolicy {
+
+ /**
+ * @see org.eclipse.papyrus.uml.diagram.common.editpolicies.SideAffixedNodesCreationEditPolicy#getPositionLocator()
+ *
+ * @return
+ */
+ @Override
+ protected ISideAffixedNodeBorderItemLocator getPositionLocator() {
+ return new ActivityParameterNodePositionLocator(getHostFigure(), PositionConstants.NONE);
+ }
+
+}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/locator/ActivityParameterNodePositionLocator.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/locator/ActivityParameterNodePositionLocator.java
index d7799b2725c..6b060b57f71 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/locator/ActivityParameterNodePositionLocator.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.activity/custom-src/org/eclipse/papyrus/uml/diagram/activity/locator/ActivityParameterNodePositionLocator.java
@@ -19,10 +19,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.BorderItemLocator;
-import org.eclipse.gmf.runtime.diagram.ui.figures.IBorderItemLocator;
import org.eclipse.papyrus.uml.diagram.common.locator.AdvancedBorderItemLocator;
+import org.eclipse.papyrus.uml.diagram.common.locator.ISideAffixedNodeBorderItemLocator;
-public class ActivityParameterNodePositionLocator extends AdvancedBorderItemLocator implements IBorderItemLocator {
+public class ActivityParameterNodePositionLocator extends AdvancedBorderItemLocator implements ISideAffixedNodeBorderItemLocator {
/**
* The offset to add to default position. (to avoid corner of rounded
@@ -55,10 +55,10 @@ public class ActivityParameterNodePositionLocator extends AdvancedBorderItemLoca
Rectangle realLocation = new Rectangle(proposedLocation);
- if(realLocation.width < DEFAULT_PIN_SIZE) {
+ if (realLocation.width < DEFAULT_PIN_SIZE) {
realLocation.setWidth(DEFAULT_PIN_SIZE);
}
- else if(realLocation.height < DEFAULT_PIN_SIZE){
+ if (realLocation.height < DEFAULT_PIN_SIZE) {
realLocation.setHeight(DEFAULT_PIN_SIZE);
}
@@ -113,7 +113,7 @@ public class ActivityParameterNodePositionLocator extends AdvancedBorderItemLoca
switch (suggestedSide) {
case PositionConstants.NORTH:
- int northY = parent.y() - borderItemSize.height/2;
+ int northY = parent.y() - borderItemSize.height / 2;
if (suggestedLocation.y != northY) {
newY = northY;
}
@@ -132,7 +132,7 @@ public class ActivityParameterNodePositionLocator extends AdvancedBorderItemLoca
break;
case PositionConstants.WEST:
default:
- int westX = parent.x() - borderItemSize.width / 2;
+ int westX = parent.x() - borderItemSize.width / 2;
if (suggestedLocation.x != westX) {
newX = westX;
}
@@ -184,22 +184,13 @@ public class ActivityParameterNodePositionLocator extends AdvancedBorderItemLoca
setCurrentSideOfParent(findClosestSideOfParent(borderItem.getBounds(), getParentBorder()));
}
- @Override
- protected Point getPreferredLocation(int side, IFigure borderItem) {
- return super.getPreferredLocation(side, borderItem);
- }
-
-
- @Override protected Point locateOnBorder(Point suggestedLocation, int suggestedSide, int circuitCount, IFigure borderItem) {
- return super.locateOnBorder(suggestedLocation, suggestedSide, circuitCount, borderItem);
- }
-
/**
*
* @param proposedLocation
* the proposed location
* @return a possible location on parent figure border
*/
+ @Override
public Rectangle getPreferredLocation(Rectangle proposedLocation) {
// Initialize port location with proposed location
// and resolve the bounds of it graphical parent
@@ -230,10 +221,21 @@ public class ActivityParameterNodePositionLocator extends AdvancedBorderItemLoca
// 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))) {
+ int preferedSide = findClosestSideOfParent(realLocation, parentRec);
+ switch (preferedSide) {
+ case PositionConstants.NORTH:
+ realLocation.y = yMin;
+ break;
+ case PositionConstants.SOUTH:
+ realLocation.y = yMax;
+ break;
+ case PositionConstants.WEST:
realLocation.x = xMin;
- } else {
+ break;
+ case PositionConstants.EAST:
+ default:
realLocation.x = xMax;
+ break;
}
}
}

Back to the top