Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridBasedXYLayoutEditPolicy.java75
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java19
2 files changed, 89 insertions, 5 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridBasedXYLayoutEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridBasedXYLayoutEditPolicy.java
index 0e1e7f99644..981f9f2c555 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridBasedXYLayoutEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridBasedXYLayoutEditPolicy.java
@@ -13,13 +13,25 @@
package org.eclipse.papyrus.uml.diagram.sequence.referencialgrilling;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
import org.eclipse.gef.commands.Command;
import org.eclipse.gef.commands.CompoundCommand;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.requests.CreateRequest;
import org.eclipse.gmf.runtime.diagram.ui.commands.ICommandProxy;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
+import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.DecorationNode;
+import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.XYLayoutWithConstrainedResizedEditPolicy;
+import org.eclipse.papyrus.infra.gmfdiag.common.service.palette.AspectUnspecifiedTypeCreationTool.CreateAspectUnspecifiedTypeRequest;
import org.eclipse.papyrus.uml.diagram.sequence.command.SetMoveAllLineAtSamePositionCommand;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.service.types.element.UMLDIElementTypes;
/**
* This class is over load the creation of element and to avoid to move element directly at creation
@@ -38,6 +50,13 @@ public class GridBasedXYLayoutEditPolicy extends XYLayoutWithConstrainedResizedE
DiagramEditPart diagramEditPart=getDiagramEditPart(getHost());
GridManagementEditPolicy grid=(GridManagementEditPolicy)diagramEditPart.getEditPolicy(GridManagementEditPolicy.GRID_MANAGEMENT);
if (grid!=null){
+ if( request instanceof CreateViewAndElementRequest){
+ String semanticHint=((CreateViewAndElementRequest)request).getViewAndElementDescriptor().getSemanticHint();
+ // do let the user place where he want the life line at the creation
+ if(semanticHint.equals(LifelineEditPart.VISUAL_ID)){
+ request.setLocation(new Point(request.getLocation().x,40));
+ }
+ }
CompoundCommand cmd= new CompoundCommand();
SetMoveAllLineAtSamePositionCommand setMoveAllLineAtSamePositionCommand= new SetMoveAllLineAtSamePositionCommand(grid, false);
cmd.add(setMoveAllLineAtSamePositionCommand);
@@ -49,7 +68,63 @@ public class GridBasedXYLayoutEditPolicy extends XYLayoutWithConstrainedResizedE
return super.getCreateCommand(request);
}
+ /* Override to use to deal with causes where the point is UNDERFINED
+ * we will ask the layout helper to find a location for us
+ * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getConstraintFor(org.eclipse.gef.requests.CreateRequest)
+ */
+ /* Override to use to deal with causes where the point is UNDERFINED
+ * we will ask the layout helper to find a location for us
+ * @see org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy#getConstraintFor(org.eclipse.gef.requests.CreateRequest)
+ */
+ protected Object getConstraintFor(CreateRequest request) {
+ // Used during the creation from the palette
+ Object constraint = super.getConstraintFor(request);
+ if( constraint instanceof Rectangle){
+ if( request instanceof CreateViewAndElementRequest){
+ String semanticHint=((CreateViewAndElementRequest)request).getViewAndElementDescriptor().getSemanticHint();
+ // do let the user place where he want the life line at the creation
+ if(semanticHint.equals(LifelineEditPart.VISUAL_ID)){
+ request.setLocation(new Point(request.getLocation().x,10));
+ }
+ }
+ }
+ return constraint;
+ }
+ /**
+ * @see org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.XYLayoutWithConstrainedResizedEditPolicy#createChangeConstraintCommand(org.eclipse.gef.requests.ChangeBoundsRequest, org.eclipse.gef.EditPart, java.lang.Object)
+ *
+ * @param request
+ * @param child
+ * @param constraint
+ * @return
+ */
+ @Override
+ protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child, Object constraint) {
+ if( child instanceof LifelineEditPart && constraint instanceof Rectangle) {
+ Rectangle rect= (Rectangle)constraint;
+ rect.y=((Bounds)((Node)((LifelineEditPart)child).getNotationView()).getLayoutConstraint()).getY();
+ return super.createChangeConstraintCommand(request, child, rect);
+ }
+ return super.createChangeConstraintCommand(request, child, constraint);
+ }
+
+ /**
+ * @see org.eclipse.gef.editpolicies.LayoutEditPolicy#showLayoutTargetFeedback(org.eclipse.gef.Request)
+ *
+ * @param request
+ */
+ @Override
+ protected void showLayoutTargetFeedback(Request request) {
+ if(request instanceof ChangeBoundsRequest){
+ ChangeBoundsRequest changeBoundsRequest= (ChangeBoundsRequest)request;
+ if( changeBoundsRequest.getEditParts().get(0) instanceof LifelineEditPart) {
+ changeBoundsRequest.setMoveDelta(new Point(changeBoundsRequest.getMoveDelta().x,0));
+ }
+ }
+ super.showLayoutTargetFeedback(request);
+ }
}
+
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java
index 9bc33704497..9cdb96e6b67 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/referencialgrilling/GridManagementEditPolicy.java
@@ -372,6 +372,7 @@ public class GridManagementEditPolicy extends GraphicalEditPolicyEx implements A
updateRowsAndColumns();
if ((((EObject) notification.getNotifier()).eContainer()) instanceof DecorationNode && rows.contains((((EObject) notification.getNotifier()).eContainer()))) {
if (notification.getFeature().equals(NotationPackage.eINSTANCE.getLocation_Y())) {
+ DecorationNode movedRow=(DecorationNode)(((EObject) notification.getNotifier()).eContainer());
// when we move line we disconnect listeners to avoid problems of infinite loop
if (moveAllLinesAtSamePosition) {
ArrayList<DecorationNode> rowlist = getRowAtPosition(notification.getOldIntValue());
@@ -379,18 +380,26 @@ public class GridManagementEditPolicy extends GraphicalEditPolicyEx implements A
// maybe we must move other lines
// it exist other lines
- if (rows.size() > rowlist.size()) {
- updateYpositionForRow((DecorationNode) (((EObject) notification.getNotifier()).eContainer()), notification.getOldIntValue());
+ if(!(movedRow.getElement() instanceof Lifeline)) {
+ if (rows.size() > rowlist.size()) {
+ updateYpositionForRow((DecorationNode) (((EObject) notification.getNotifier()).eContainer()), notification.getOldIntValue());
+ }
}
for (Iterator<DecorationNode> iterator = rowlist.iterator(); iterator.hasNext();) {
DecorationNode axis = (DecorationNode) iterator.next();
- execute(new SetBoundsCommand(getDiagramEditPart(getHost()).getEditingDomain(), "update Line", new EObjectAdapter(axis), new Point(0, notification.getNewIntValue()))); //$NON-NLS-1$
+ if((movedRow.getElement() instanceof Lifeline)&& (axis.getElement() instanceof Lifeline)) {
+
+ execute(new SetBoundsCommand(getDiagramEditPart(getHost()).getEditingDomain(), "update Line", new EObjectAdapter(axis), new Point(0, notification.getNewIntValue())));
+ }
+ else if(!(movedRow.getElement() instanceof Lifeline)) {
+ execute(new SetBoundsCommand(getDiagramEditPart(getHost()).getEditingDomain(), "update Line", new EObjectAdapter(axis), new Point(0, notification.getNewIntValue())));
+ }
}
- ((EObject) getHost().getModel()).eResource().eAdapters().add(contentDiagramListener);
}
-
+ ((EObject) getHost().getModel()).eResource().eAdapters().add(contentDiagramListener);
}
+
}
}
}

Back to the top