diff options
Diffstat (limited to 'plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit')
2 files changed, 142 insertions, 123 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java index 80dc7d02202..8050f616685 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java @@ -28,15 +28,15 @@ import org.eclipse.gmf.runtime.notation.FillStyle; import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
-import org.eclipse.papyrus.infra.emf.appearance.helper.ShadowFigureHelper;
+import org.eclipse.papyrus.infra.emf.appearance.helper.AppearanceHelper;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.node.IPapyrusNodeFigure;
import org.eclipse.papyrus.uml.diagram.common.figure.node.PapyrusNodeFigure;
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.LifelineXYLayoutEditPolicy;
import org.eclipse.swt.graphics.Color;
import org.eclipse.uml2.uml.ExecutionSpecification;
-public abstract class AbstractExecutionSpecificationEditPart extends
- ShapeNodeEditPart {
+public abstract class AbstractExecutionSpecificationEditPart extends ShapeNodeEditPart {
+
private List executionSpecificationEndParts;
public AbstractExecutionSpecificationEditPart(View view) {
@@ -45,7 +45,7 @@ public abstract class AbstractExecutionSpecificationEditPart extends @Override
public List getChildren() {
- if (executionSpecificationEndParts == null) {
+ if(executionSpecificationEndParts == null) {
initExecutionSpecificationEndEditPart();
}
return super.getChildren();
@@ -55,33 +55,31 @@ public abstract class AbstractExecutionSpecificationEditPart extends executionSpecificationEndParts = new ArrayList();
EObject element = this.resolveSemanticElement();
- if (!(element instanceof ExecutionSpecification))
+ if(!(element instanceof ExecutionSpecification)) {
return;
- ExecutionSpecification execution = (ExecutionSpecification) element;
- final ExecutionSpecificationEndEditPart startPart = new ExecutionSpecificationEndEditPart(
- execution.getStart(), this, new RelativeLocator(getFigure(),
- PositionConstants.NORTH));
+ }
+ ExecutionSpecification execution = (ExecutionSpecification)element;
+ final ExecutionSpecificationEndEditPart startPart = new ExecutionSpecificationEndEditPart(execution.getStart(), this, new RelativeLocator(getFigure(), PositionConstants.NORTH));
executionSpecificationEndParts.add(startPart);
- final ExecutionSpecificationEndEditPart finishPart = new ExecutionSpecificationEndEditPart(
- execution.getFinish(), this, new RelativeLocator(getFigure(),
- PositionConstants.SOUTH));
+ final ExecutionSpecificationEndEditPart finishPart = new ExecutionSpecificationEndEditPart(execution.getFinish(), this, new RelativeLocator(getFigure(), PositionConstants.SOUTH));
executionSpecificationEndParts.add(finishPart);
- Diagram diagram = ((View) this.getModel()).getDiagram();
+ Diagram diagram = ((View)this.getModel()).getDiagram();
startPart.rebuildLinks(diagram);
finishPart.rebuildLinks(diagram);
-
+
addChild(startPart, -1);
addChild(finishPart, -1);
}
static class FillParentLocator implements Locator {
+
public void relocate(IFigure target) {
target.setBounds(target.getParent().getBounds());
}
}
-
+
/**
* Overrides to disable the defaultAnchorArea. The edge is now more stuck with the middle of the
* figure.
@@ -90,6 +88,7 @@ public abstract class AbstractExecutionSpecificationEditPart extends */
protected NodeFigure createNodePlate() {
DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(16, 60) {
+
/**
* @see org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure#isDefaultAnchorArea(org.eclipse.draw2d.geometry.PrecisionPoint)
*/
@@ -101,71 +100,74 @@ public abstract class AbstractExecutionSpecificationEditPart extends result.setMinimumSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(20))); // min height 20
return result;
}
-
+
@Override
protected void createDefaultEditPolicies() {
super.createDefaultEditPolicies();
- installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableShapeEditPolicy(){
+ installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableShapeEditPolicy() {
+
@Override
protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
request.getMoveDelta().x = 0; // reset offset
-
+
IFigure feedback = getDragSourceFeedbackFigure();
-
- PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
- getHostFigure().translateToAbsolute(rect);
-
- IFigure f = getHostFigure();
- Dimension min = f.getMinimumSize().getCopy();
- Dimension max = f.getMaximumSize().getCopy();
- IMapMode mmode = MapModeUtil.getMapMode(f);
- min.height = mmode.LPtoDP(min.height);
- min.width = mmode.LPtoDP(min.width);
- max.height = mmode.LPtoDP(max.height);
- max.width = mmode.LPtoDP(max.width);
-
- Rectangle originalBounds = rect.getCopy();
- rect.translate(request.getMoveDelta());
- rect.resize(request.getSizeDelta());
-
- if (min.width>rect.width)
- rect.width = min.width;
- else if (max.width < rect.width)
- rect.width = max.width;
- if (min.height>rect.height)
- rect.height = min.height;
- else if (max.height < rect.height)
- rect.height = max.height;
-
- if(rect.height == min.height && request.getSizeDelta().height < 0 && request.getMoveDelta().y > 0 ){ //shrink at north
- Point loc = rect.getLocation();
- loc.y = originalBounds.getBottom().y - min.height;
- rect.setLocation(loc);
-
- request.getSizeDelta().height = min.height - originalBounds.height;
- request.getMoveDelta().y = loc.y - originalBounds.y;
- }
-
- if(request.getSizeDelta().height == 0){ // moving
- moveExecutionSpecificationFeedback(request, AbstractExecutionSpecificationEditPart.this, rect);
- }
- feedback.translateToRelative(rect);
- feedback.setBounds(rect);
+
+ PrecisionRectangle rect = new PrecisionRectangle(getInitialFeedbackBounds().getCopy());
+ getHostFigure().translateToAbsolute(rect);
+
+ IFigure f = getHostFigure();
+ Dimension min = f.getMinimumSize().getCopy();
+ Dimension max = f.getMaximumSize().getCopy();
+ IMapMode mmode = MapModeUtil.getMapMode(f);
+ min.height = mmode.LPtoDP(min.height);
+ min.width = mmode.LPtoDP(min.width);
+ max.height = mmode.LPtoDP(max.height);
+ max.width = mmode.LPtoDP(max.width);
+
+ Rectangle originalBounds = rect.getCopy();
+ rect.translate(request.getMoveDelta());
+ rect.resize(request.getSizeDelta());
+
+ if(min.width > rect.width) {
+ rect.width = min.width;
+ } else if(max.width < rect.width) {
+ rect.width = max.width;
+ }
+ if(min.height > rect.height) {
+ rect.height = min.height;
+ } else if(max.height < rect.height) {
+ rect.height = max.height;
+ }
+
+ if(rect.height == min.height && request.getSizeDelta().height < 0 && request.getMoveDelta().y > 0) { //shrink at north
+ Point loc = rect.getLocation();
+ loc.y = originalBounds.getBottom().y - min.height;
+ rect.setLocation(loc);
+
+ request.getSizeDelta().height = min.height - originalBounds.height;
+ request.getMoveDelta().y = loc.y - originalBounds.y;
+ }
+
+ if(request.getSizeDelta().height == 0) { // moving
+ moveExecutionSpecificationFeedback(request, AbstractExecutionSpecificationEditPart.this, rect);
+ }
+ feedback.translateToRelative(rect);
+ feedback.setBounds(rect);
}
});
- }
-
+ }
+
@Override
protected void setLineWidth(int width) {
- if(getPrimaryShape() instanceof NodeFigure){
+ if(getPrimaryShape() instanceof NodeFigure) {
((NodeFigure)getPrimaryShape()).setLineWidth(width);
}
}
-
+
protected final void refreshShadow() {
- getPrimaryShape().setShadow(ShadowFigureHelper.getShadowFigureValue((View)getModel()));
+ getPrimaryShape().setShadow(AppearanceHelper.showShadow((View)getModel()));
}
-
+
/**
* Override to set the transparency to the correct figure
*/
@@ -173,7 +175,7 @@ public abstract class AbstractExecutionSpecificationEditPart extends protected void setTransparency(int transp) {
getPrimaryShape().setTransparency(transp);
}
-
+
/**
* sets the back ground color of this edit part
*
@@ -201,15 +203,16 @@ public abstract class AbstractExecutionSpecificationEditPart extends fig.setIsUsingGradient(false);
}
}
-
+
+ @Override
public boolean supportsGradient() {
return true;
}
-
+
@Override
protected void handleNotificationEvent(Notification event) {
super.handleNotificationEvent(event);
-
+
Object feature = event.getFeature();
if((getModel() != null) && (getModel() == event.getNotifier())) {
if(NotationPackage.eINSTANCE.getLineStyle_LineWidth().equals(feature)) {
@@ -221,78 +224,88 @@ public abstract class AbstractExecutionSpecificationEditPart extends refreshShadow();
}
-
- public class ExecutionSpecificationRectangleFigure extends PapyrusNodeFigure{ //RectangleFigure {
+
+ public class ExecutionSpecificationRectangleFigure extends PapyrusNodeFigure { //RectangleFigure {
public ExecutionSpecificationRectangleFigure() {
this.setPreferredSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(60)));
this.setMinimumSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(20)));
}
- public IFigure findMouseEventTargetAt(int x, int y) {
+ @Override
+ public IFigure findMouseEventTargetAt(int x, int y) {
// check children first instead of self
IFigure f = findMouseEventTargetInDescendantsAt(x, y);
- if (f != null)
+ if(f != null) {
return f;
- if (!containsPoint(x, y))
+ }
+ if(!containsPoint(x, y)) {
return null;
- if (isMouseEventTarget())
+ }
+ if(isMouseEventTarget()) {
return this;
+ }
return null;
}
+ @Override
public IFigure findFigureAt(int x, int y, TreeSearch search) {
- if (search.prune(this))
+ if(search.prune(this)) {
return null;
+ }
IFigure child = findDescendantAtExcluding(x, y, search);
- if (child != null)
+ if(child != null) {
return child;
- if (!containsPoint(x, y))
+ }
+ if(!containsPoint(x, y)) {
return null;
- if (search.accept(this))
+ }
+ if(search.accept(this)) {
return this;
+ }
return null;
}
}
-
- public abstract ExecutionSpecificationRectangleFigure getPrimaryShape() ;
+
+ public abstract ExecutionSpecificationRectangleFigure getPrimaryShape();
//see bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=385604
protected void moveExecutionSpecificationFeedback(ChangeBoundsRequest request, AbstractExecutionSpecificationEditPart movedPart, PrecisionRectangle rect) {
LifelineEditPart lifelineEP = (LifelineEditPart)movedPart.getParent();
Rectangle copy = rect.getCopy();
lifelineEP.getPrimaryShape().translateToRelative(copy);
-
+
List<ShapeNodeEditPart> executionSpecificationList = lifelineEP.getChildShapeNodeEditPart();
- List<ShapeNodeEditPart> movedChildrenParts = LifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts(AbstractExecutionSpecificationEditPart.this );
+ List<ShapeNodeEditPart> movedChildrenParts = LifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts(AbstractExecutionSpecificationEditPart.this);
executionSpecificationList.remove(movedPart); // ignore current action and its children
- executionSpecificationList.removeAll(movedChildrenParts);
+ executionSpecificationList.removeAll(movedChildrenParts);
ShapeNodeEditPart parentBar = LifelineXYLayoutEditPolicy.getParent(lifelineEP, copy, executionSpecificationList);
-
+
Rectangle dotLineBounds = lifelineEP.getPrimaryShape().getFigureLifelineDotLineFigure().getBounds();
int dotLineBarLocationX = dotLineBounds.x + dotLineBounds.width / 2 - LifelineXYLayoutEditPolicy.EXECUTION_INIT_WIDTH / 2;
- if(parentBar == null){
- if(dotLineBarLocationX < copy.x){ // there is no parent bar, move to the center dotline position
+ if(parentBar == null) {
+ if(dotLineBarLocationX < copy.x) { // there is no parent bar, move to the center dotline position
int dx = dotLineBarLocationX - copy.x;
request.getMoveDelta().x += dx;
rect.x += dx;
}
- }else{
- while(!executionSpecificationList.isEmpty()){
- Rectangle parentBounds = parentBar.getFigure().getBounds();
+ } else {
+ while(!executionSpecificationList.isEmpty()) {
+ Rectangle parentBounds = parentBar.getFigure().getBounds();
int width = parentBounds.width > 0 ? parentBounds.width : LifelineXYLayoutEditPolicy.EXECUTION_INIT_WIDTH;
- int x = parentBounds.x + width / 2 + 1; // affixed to the parent bar
+ int x = parentBounds.x + width / 2 + 1; // affixed to the parent bar
int dx = x - copy.x;
rect.x += dx;
request.getMoveDelta().x += dx;
copy.x = x;
-
+
// check again to see if the new bar location overlaps with existing bars
ShapeNodeEditPart part = LifelineXYLayoutEditPolicy.getParent(lifelineEP, copy, executionSpecificationList);
- if(part == parentBar) // if parent bar is the same, there will be no overlapping
+ if(part == parentBar) {
break;
- else // if overlaps, go on moving the bar to next x position
+ } else {
parentBar = part;
+ }
}
}
}
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java index 8d29f58a595..4c5f3a89ab2 100644 --- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java +++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.sequence/custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java @@ -126,33 +126,35 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { return super.getCreateCommand(request); } - + @Override protected EditPolicy createChildEditPolicy(EditPart child) { View childView = (View)child.getModel(); switch(UMLVisualIDRegistry.getVisualID(childView)) { - case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: - return new BorderItemResizableEditPolicy(); - } + case DestructionOccurrenceSpecificationEditPart.VISUAL_ID: + return new BorderItemResizableEditPolicy(); + } return super.createChildEditPolicy(child); } - + + @Override protected Rectangle getCurrentConstraintFor(GraphicalEditPart child) { IFigure fig = child.getFigure(); - Object con = fig.getParent().getLayoutManager() - .getConstraint(fig); - if(con instanceof Rectangle) - return (Rectangle) con; + Object con = fig.getParent().getLayoutManager().getConstraint(fig); + if(con instanceof Rectangle) { + return (Rectangle)con; + } return fig.getBounds(); } + @Override protected Object getConstraintFor(CreateRequest request) { Rectangle constraint = (Rectangle)super.getConstraintFor(request); - if (request instanceof CreateViewAndElementRequest) { + if(request instanceof CreateViewAndElementRequest) { CreateViewAndElementRequest req = (CreateViewAndElementRequest)request; - IHintedType type = (IHintedType) UMLElementTypes.Lifeline_3001; - if (type.getSemanticHint().equals(req.getViewAndElementDescriptor().getSemanticHint())) { - constraint.y = 0 ; // fix layout offset + IHintedType type = (IHintedType)UMLElementTypes.Lifeline_3001; + if(type.getSemanticHint().equals(req.getViewAndElementDescriptor().getSemanticHint())) { + constraint.y = 0; // fix layout offset } } return constraint; @@ -241,30 +243,32 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { if(newBounds == null) { return UnexecutableCommand.INSTANCE; } - Command p = new ICommandProxy(new SetBoundsCommand(editPart.getEditingDomain(), "Creation of an ExecutionSpecification", viewDescriptor, newBounds)); + Command p = new ICommandProxy(new SetBoundsCommand(editPart.getEditingDomain(), "Creation of an ExecutionSpecification", viewDescriptor, newBounds)); // resize parent bar - if(parent != null){ + if(parent != null) { p = p.chain(resizeParentExecutionSpecification((LifelineEditPart)getHost(), parent, newBounds.getCopy(), executionSpecificationList)); - } + } return p; } private static Command resizeParentExecutionSpecification(LifelineEditPart lifelinePart, ShapeNodeEditPart part, Rectangle childBounds, List<ShapeNodeEditPart> list) { Rectangle bounds = getRelativeBounds(part.getFigure()); - + childBounds.x = bounds.x; childBounds.width = bounds.width; - if(bounds.contains(childBounds)) - return null; + if(bounds.contains(childBounds)) { + return null; + } bounds.union(childBounds); Command c = new ICommandProxy(new SetBoundsCommand(part.getEditingDomain(), "Resize of Parent Bar", part, bounds.getCopy())); - + list.remove(part); ShapeNodeEditPart parent = getParent(lifelinePart, part.getFigure().getBounds(), list); - if(parent == null) + if(parent == null) { return c; - + } + return c.chain(resizeParentExecutionSpecification(lifelinePart, parent, bounds.getCopy(), list)); } @@ -438,6 +442,7 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { /** * {@inheritDoc} */ + @Override protected Command getMoveChildrenCommand(Request request) { // This policy is hosted in a LifelineEditPart LifelineEditPart lifelineEP = (LifelineEditPart)getHost(); @@ -489,17 +494,17 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { List<ShapeNodeEditPart> executionSpecificationList = lifelineEP.getChildShapeNodeEditPart(); executionSpecificationList.remove(executionSpecificationEP); ShapeNodeEditPart parentBar = getParent(lifelineEP, newBounds, executionSpecificationList); - + // change bounds to relative newBounds = getExecutionSpecificationNewBounds(isMove, lifelineEP, oldBounds, newBounds, notToCheckExecutionSpecificationList, useFixedXPos); if(newBounds == null) { return UnexecutableCommand.INSTANCE; } - if(parentBar != null){ + if(parentBar != null) { compoundCmd.add(resizeParentExecutionSpecification(lifelineEP, parentBar, newBounds.getCopy(), executionSpecificationList)); } - + // Create and add the command to the compound command SetBoundsCommand setBoundsCmd = new SetBoundsCommand(executionSpecificationEP.getEditingDomain(), "Resize of a ExecutionSpecification", executionSpecificationEP, newBounds); compoundCmd.add(new ICommandProxy(setBoundsCmd)); @@ -636,7 +641,8 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { /** * Get the (futur) parent of a ExecutionSpecification - * @param lifelinePart + * + * @param lifelinePart * * @param childBounds * the child bounds @@ -673,7 +679,7 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { * * @return a corrected sizeDelta */ - protected final static Dimension adaptSizeDeltaToMaxHeight(IFigure figure, Dimension sizeDelta) { + public final static Dimension adaptSizeDeltaToMaxHeight(IFigure figure, Dimension sizeDelta) { Dimension newSizeDelta = new Dimension(sizeDelta); int figureHeight = figure.getBounds().height; @@ -762,7 +768,7 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { * @return true if the rectangles of both figures touch and the right figure is really on the * right. False otherwise */ - protected final static boolean isAffixedToRight(Rectangle leftFigure, Rectangle rightFigure) { + public final static boolean isAffixedToRight(Rectangle leftFigure, Rectangle rightFigure) { return leftFigure.touches(rightFigure) && leftFigure.x < rightFigure.x; } @@ -828,7 +834,7 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { * * @return The real MoveDelta applied */ - protected final static Rectangle getRealMoveDelta(Rectangle oldRelativeBounds, Rectangle newRelativeBounds) { + public final static Rectangle getRealMoveDelta(Rectangle oldRelativeBounds, Rectangle newRelativeBounds) { Rectangle realMoveDelta = new Rectangle(); realMoveDelta.x = newRelativeBounds.x - oldRelativeBounds.x; realMoveDelta.y = newRelativeBounds.y - oldRelativeBounds.y; @@ -845,7 +851,7 @@ public class LifelineXYLayoutEditPolicy extends XYLayoutEditPolicy { * * @return The relative bounds regarding it's parent figure */ - protected final static Rectangle getRelativeBounds(IFigure figure) { + public final static Rectangle getRelativeBounds(IFigure figure) { Rectangle relBounds = figure.getBounds().getCopy(); Rectangle parentRectangle = figure.getParent().getBounds(); relBounds.x -= parentRectangle.x; |