Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-02-21 11:20:14 -0500
committercletavernie2012-02-21 11:20:14 -0500
commit001e1ec878eaa6d9225c5831936b133cec0c38d3 (patch)
tree37ea546180eceea4ed6867878b88b0c9e9116f7f /plugins
parentbe75f4d80f97e7971fdbd09d4c5a81b84056f0e7 (diff)
downloadorg.eclipse.papyrus-001e1ec878eaa6d9225c5831936b133cec0c38d3.tar.gz
org.eclipse.papyrus-001e1ec878eaa6d9225c5831936b133cec0c38d3.tar.xz
org.eclipse.papyrus-001e1ec878eaa6d9225c5831936b133cec0c38d3.zip
364608: [Sequence Diagram] - Lifeline selection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=364608
Diffstat (limited to 'plugins')
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java28
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java70
2 files changed, 98 insertions, 0 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java
index 26aa9066890..089eae4430d 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java
@@ -84,6 +84,7 @@ import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.ElementCreationWit
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineAppliedStereotypeNodeLabelDisplayEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineCreationEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineItemSemanticEditPolicy;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineSelectionEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineXYLayoutEditPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.RemoveOrphanViewPolicy;
import org.eclipse.papyrus.uml.diagram.sequence.figures.LifelineDotLineCustomFigure;
@@ -183,6 +184,9 @@ public class LifelineEditPart extends NamedElementEditPart {
installEditPolicy(AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY, new LifelineAppliedStereotypeNodeLabelDisplayEditPolicy());
// XXX need an SCR to runtime to have another abstract superclass that would let children add reasonable editpolicies
// removeEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.CONNECTION_HANDLES_ROLE);
+
+ //Fixed bug: https://bugs.eclipse.org/bugs/show_bug.cgi?id=364608
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new LifelineSelectionEditPolicy());
}
/**
@@ -371,6 +375,13 @@ public class LifelineEditPart extends NamedElementEditPart {
protected boolean isDefaultAnchorArea(PrecisionPoint p) {
return false;
}
+
+ public boolean containsPoint(int x, int y) {
+ if (primaryShape != null) {
+ return primaryShape.containsPoint(x, y);
+ }
+ return super.containsPoint(x, y);
+ }
};
return result;
}
@@ -1421,6 +1432,23 @@ public class LifelineEditPart extends NamedElementEditPart {
public LifelineDotLineCustomFigure getFigureLifelineDotLineFigure() {
return fFigureLifelineDotLineFigure;
}
+
+ public boolean containsPoint(int x, int y) {
+ boolean contains = super.containsPoint(x, y);
+ if (!contains) {
+ return false;
+ }
+ if (fFigureLifelineNameContainerFigure != null
+ && fFigureLifelineNameContainerFigure.containsPoint(x, y)) {
+ return true;
+ } else if (fFigureLifelineDotLineFigure != null) {
+ Rectangle bounds = fFigureLifelineDotLineFigure
+ .getDashLineRectangle().getBounds().getCopy();
+ bounds.expand(4, 0);
+ return bounds.contains(x, y);
+ }
+ return false;
+ }
}
/**
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java
new file mode 100644
index 00000000000..8358f4333f3
--- /dev/null
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineSelectionEditPolicy.java
@@ -0,0 +1,70 @@
+package org.eclipse.papyrus.uml.diagram.sequence.edit.policies;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.Cursors;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.Locator;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.draw2d.RectangleFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Handle;
+import org.eclipse.gef.handles.MoveHandle;
+import org.eclipse.gef.handles.MoveHandleLocator;
+import org.eclipse.gef.handles.RelativeHandleLocator;
+import org.eclipse.gef.handles.ResizeHandle;
+import org.eclipse.gef.tools.ResizeTracker;
+import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableEditPolicyEx;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
+import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart.LifelineFigure;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Cursor;
+
+public class LifelineSelectionEditPolicy extends ResizableEditPolicyEx {
+
+ public LifelineSelectionEditPolicy() {
+ setResizeDirections(PositionConstants.NORTH | PositionConstants.SOUTH | PositionConstants.WEST | PositionConstants.EAST);
+ }
+
+ protected List<?> createSelectionHandles() {
+ final LifelineEditPart host = (LifelineEditPart) getHost();
+ final LifelineFigure primaryShape = host.getPrimaryShape();
+ // resizable in at least one direction
+ List<Handle> list = new ArrayList<Handle>();
+ // createMoveHandle(list);
+ Locator locator = new MoveHandleLocator(
+ primaryShape.getFigureLifelineNameContainerFigure());
+ MoveHandle moveHandle = new MoveHandle((GraphicalEditPart) getHost(),
+ locator);
+ moveHandle.setCursor(Cursors.SIZEALL);
+ list.add(moveHandle);
+
+ createResizeHandle(list, PositionConstants.NORTH);
+ final RectangleFigure fig = primaryShape
+ .getFigureLifelineNameContainerFigure();
+
+ createResizeHandle(host, list, fig,PositionConstants.WEST);
+ createResizeHandle(host, list, fig,PositionConstants.EAST);
+
+ createResizeHandle(list, PositionConstants.SOUTH);
+ return list;
+ }
+
+ private void createResizeHandle(LifelineEditPart host, List<Handle> list,
+ RectangleFigure fig, int location) {
+ Locator locator = new RelativeHandleLocator(fig, location);
+ Cursor cursor = Cursors
+ .getDirectionalCursor(location, fig.isMirrored());
+ ResizeHandle westResizer = new ResizeHandle((GraphicalEditPart) host,
+ locator, cursor);
+ ResizeTracker resizeTracker = new ResizeTracker(host, location);
+ westResizer.setDragTracker(resizeTracker);
+ list.add(westResizer);
+ }
+
+}

Back to the top