Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 377501 | Differences between
and this patch

Collapse All | Expand All

(-)custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/HighlightConnectionPartEditPolicy.java (-11 / +20 lines)
Lines 3-37 Link Here
3
import org.eclipse.gef.Request;
3
import org.eclipse.gef.Request;
4
import org.eclipse.gef.editpolicies.AbstractEditPolicy;
4
import org.eclipse.gef.editpolicies.AbstractEditPolicy;
5
import org.eclipse.gef.requests.CreateConnectionRequest;
5
import org.eclipse.gef.requests.CreateConnectionRequest;
6
import org.eclipse.gef.requests.ReconnectRequest;
6
import org.eclipse.papyrus.uml.diagram.sequence.util.HighlightUtil;
7
import org.eclipse.papyrus.uml.diagram.sequence.util.HighlightUtil;
7
8
8
public class HighlightConnectionPartEditPolicy extends AbstractEditPolicy {
9
public class HighlightConnectionPartEditPolicy extends AbstractEditPolicy {
9
10
11
	private HighlightUtil sourceHighlighter = new HighlightUtil();
12
13
	private HighlightUtil targetHighlighter = new HighlightUtil();
14
10
	@Override
15
	@Override
11
	public void showSourceFeedback(Request request) {
16
	public void showSourceFeedback(Request request) {
12
		if(request instanceof CreateConnectionRequest){
17
		if(request instanceof CreateConnectionRequest) {
13
			HighlightUtil.showConnectionFeedback(getHost(), HighlightUtil.SOURCE_COLOR);
18
			sourceHighlighter.highlight(getHost());
14
		}
19
		}
15
	}
20
	}
16
	
21
17
	@Override
22
	@Override
18
	public void showTargetFeedback(Request request) {
23
	public void showTargetFeedback(Request request) {
19
		if(request instanceof CreateConnectionRequest && ((CreateConnectionRequest)request).getSourceEditPart() != null){
24
		if(request instanceof CreateConnectionRequest && ((CreateConnectionRequest)request).getSourceEditPart() != null) {
20
			HighlightUtil.showConnectionFeedback(getHost(), HighlightUtil.TARGET_COLOR);
25
			targetHighlighter.highlight(getHost());
26
		} else if(request instanceof ReconnectRequest && ((ReconnectRequest)request).getTarget() != null) {
27
			targetHighlighter.highlight(((ReconnectRequest)request).getTarget());
21
		}
28
		}
22
	}
29
	}
23
	
30
24
	@Override
31
	@Override
25
	public void eraseSourceFeedback(Request request) {
32
	public void eraseSourceFeedback(Request request) {
26
		if(request instanceof CreateConnectionRequest){
33
		if(request instanceof CreateConnectionRequest) {
27
			HighlightUtil.eraseConnectionFeedback(getHost());
34
			sourceHighlighter.unhighlight(getHost());
28
		}
35
		}
29
	}
36
	}
30
	
37
31
	@Override
38
	@Override
32
	public void eraseTargetFeedback(Request request) {
39
	public void eraseTargetFeedback(Request request) {
33
		if(request instanceof CreateConnectionRequest && ((CreateConnectionRequest)request).getSourceEditPart() != null){
40
		if(request instanceof CreateConnectionRequest && ((CreateConnectionRequest)request).getSourceEditPart() != null) {
34
			HighlightUtil.eraseConnectionFeedback(getHost());
41
			targetHighlighter.unhighlight(getHost());
42
		} else if(request instanceof ReconnectRequest && ((ReconnectRequest)request).getTarget() != null) {
43
			targetHighlighter.unhighlight(((ReconnectRequest)request).getTarget());
35
		}
44
		}
36
	}
45
	}
37
}
46
}
(-)custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/policies/LifelineXYLayoutEditPolicy.java (-31 / +88 lines)
Lines 39-44 Link Here
39
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
39
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
40
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
40
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.XYLayoutEditPolicy;
41
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
41
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
42
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
42
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
43
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewAndElementRequest;
43
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
44
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
44
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
45
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest.ViewDescriptor;
Lines 59-64 Link Here
59
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart;
60
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.TimeObservationEditPart;
60
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
61
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLVisualIDRegistry;
61
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
62
import org.eclipse.papyrus.uml.diagram.sequence.providers.UMLElementTypes;
63
import org.eclipse.papyrus.uml.diagram.sequence.util.HighlightUtil;
62
import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationMoveHelper;
64
import org.eclipse.papyrus.uml.diagram.sequence.util.OccurrenceSpecificationMoveHelper;
63
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
65
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceRequestConstant;
64
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
66
import org.eclipse.papyrus.uml.diagram.sequence.util.SequenceUtil;
Lines 83-88 Link Here
83
	/** The default spacing used between Execution Specification */
85
	/** The default spacing used between Execution Specification */
84
	private final static int SPACING_HEIGHT = 5;
86
	private final static int SPACING_HEIGHT = 5;
85
87
88
	// force location of time/duration elements and ES
89
	private static final String TIME_CONSTRAINT_HINT = ((IHintedType)UMLElementTypes.TimeConstraint_3019).getSemanticHint();
90
91
	private static final String TIME_OBSERVATION_HINT = ((IHintedType)UMLElementTypes.TimeObservation_3020).getSemanticHint();
92
93
	private static final String DURATION_CONSTRAINT_ON_LIFELINE_HINT = ((IHintedType)UMLElementTypes.DurationConstraint_3021).getSemanticHint();
94
95
	private static final String ACTION_EXECUTION_SPECIFICATION_HINT = ((IHintedType)UMLElementTypes.ActionExecutionSpecification_3006).getSemanticHint();
96
97
	private static final String BEHAVIOR_EXECUTION_SPECIFICATION_HINT = ((IHintedType)UMLElementTypes.BehaviorExecutionSpecification_3003).getSemanticHint();
98
99
	private static final String CO_REGION_HINT = ((IHintedType)UMLElementTypes.CombinedFragment_3018).getSemanticHint();
100
101
	private HighlightUtil highlightUtil = new HighlightUtil();
102
103
86
	/**
104
	/**
87
	 * {@inheritDoc}
105
	 * {@inheritDoc}
88
	 */
106
	 */
Lines 94-126 Link Here
94
				ViewDescriptor viewDescriptor = cvr.getViewDescriptors().iterator().next();
112
				ViewDescriptor viewDescriptor = cvr.getViewDescriptors().iterator().next();
95
				String semanticHint = viewDescriptor.getSemanticHint();
113
				String semanticHint = viewDescriptor.getSemanticHint();
96
114
97
				// force location of time/duration elements and ES
115
				if(TIME_CONSTRAINT_HINT.equals(semanticHint) || TIME_OBSERVATION_HINT.equals(semanticHint)) {
98
				String timeConstraintHint = ((IHintedType)UMLElementTypes.TimeConstraint_3019).getSemanticHint();
99
				String timeObservationHint = ((IHintedType)UMLElementTypes.TimeObservation_3020).getSemanticHint();
100
				String durationConstraintOnLifelineHint = ((IHintedType)UMLElementTypes.DurationConstraint_3021).getSemanticHint();
101
				String actionExecutionSpecificationHint = ((IHintedType)UMLElementTypes.ActionExecutionSpecification_3006).getSemanticHint();
102
				String behaviorExecutionSpecificationHint = ((IHintedType)UMLElementTypes.BehaviorExecutionSpecification_3003).getSemanticHint();
103
				String coRegionHint = ((IHintedType)UMLElementTypes.CombinedFragment_3018).getSemanticHint();
104
105
				if(timeConstraintHint.equals(semanticHint) || timeObservationHint.equals(semanticHint)) {
106
					Command cmd = getCommandForTimeObservationOrConstraint(cvr, viewDescriptor);
116
					Command cmd = getCommandForTimeObservationOrConstraint(cvr, viewDescriptor);
107
					if(cmd != null) {
117
					if(cmd != null) {
108
						return cmd;
118
						return cmd;
109
					}
119
					}
110
				}
120
				}
111
				if(durationConstraintOnLifelineHint.equals(semanticHint)) {
121
				if(DURATION_CONSTRAINT_ON_LIFELINE_HINT.equals(semanticHint)) {
112
					Command cmd = getCommandForDurationConstraint(cvr, viewDescriptor);
122
					Command cmd = getCommandForDurationConstraint(cvr, viewDescriptor);
113
					if(cmd != null) {
123
					if(cmd != null) {
114
						return cmd;
124
						return cmd;
115
					}
125
					}
116
				}
126
				}
117
				if(actionExecutionSpecificationHint.equals(semanticHint) || behaviorExecutionSpecificationHint.equals(semanticHint)) {
127
				if(ACTION_EXECUTION_SPECIFICATION_HINT.equals(semanticHint) || BEHAVIOR_EXECUTION_SPECIFICATION_HINT.equals(semanticHint)) {
118
					Command cmd = getCommandForExecutionSpecificationCreation(cvr, viewDescriptor);
128
						Command cmd = getCommandForExecutionSpecificationCreation(cvr, viewDescriptor);
119
					if(cmd != null) {
129
					if(cmd != null) {
120
						return cmd;
130
						return cmd;
121
					}
131
					}
122
				}
132
				}
123
				if(coRegionHint.equals(semanticHint)) {
133
				if(CO_REGION_HINT.equals(semanticHint)) {
124
					Command cmd = getCommandForCoRegionCreation(cvr, viewDescriptor);
134
					Command cmd = getCommandForCoRegionCreation(cvr, viewDescriptor);
125
					if(cmd != null) {
135
					if(cmd != null) {
126
						return cmd;
136
						return cmd;
Lines 133-138 Link Here
133
	}
143
	}
134
	
144
	
135
	@Override
145
	@Override
146
	protected void showLayoutTargetFeedback(Request request) {
147
		if(request instanceof CreateUnspecifiedTypeRequest) {
148
			CreateUnspecifiedTypeRequest cvr = (CreateUnspecifiedTypeRequest)request;
149
			if(!cvr.getElementTypes().isEmpty()) {
150
				IHintedType elementType = (IHintedType)cvr.getElementTypes().iterator().next();
151
				String semanticHint = elementType.getSemanticHint();
152
				EditPart editPartForHighlight = getHost();
153
				if(ACTION_EXECUTION_SPECIFICATION_HINT.equals(semanticHint) || BEHAVIOR_EXECUTION_SPECIFICATION_HINT.equals(semanticHint)) {
154
					ShapeNodeEditPart parentExecuteSpecification = getParentWhenCreationExecuteSpecification(cvr.getLocation(), cvr.getSize(), semanticHint);
155
					if(parentExecuteSpecification != null) {
156
						editPartForHighlight = parentExecuteSpecification;
157
					}
158
				}
159
				if(editPartForHighlight != null) {
160
					highlightUtil.unhighlight();
161
					highlightUtil.highlight(editPartForHighlight);
162
				}
163
			}
164
		}
165
		super.showLayoutTargetFeedback(request);
166
	}
167
168
	@Override
169
	protected void eraseLayoutTargetFeedback(Request request) {
170
		super.eraseLayoutTargetFeedback(request);
171
		highlightUtil.unhighlight();
172
	}
173
174
	@Override
136
	protected EditPolicy createChildEditPolicy(EditPart child) {
175
	protected EditPolicy createChildEditPolicy(EditPart child) {
137
		View childView = (View)child.getModel();
176
		View childView = (View)child.getModel();
138
		switch(UMLVisualIDRegistry.getVisualID(childView)) {
177
		switch(UMLVisualIDRegistry.getVisualID(childView)) {
Lines 161-168 Link Here
161
			}
200
			}
162
			
201
			
163
			String destructionHint = ((IHintedType)UMLElementTypes.DestructionOccurrenceSpecification_3022).getSemanticHint();
202
			String destructionHint = ((IHintedType)UMLElementTypes.DestructionOccurrenceSpecification_3022).getSemanticHint();
164
			if (destructionHint.equals(req.getViewAndElementDescriptor().getSemanticHint()) && constraint.width < 0 && constraint.height < 0) {
203
			if(destructionHint.equals(req.getViewAndElementDescriptor().getSemanticHint()) && constraint.width < 0 && constraint.height < 0) {
165
				constraint.width = constraint.height = 20 ;// set initial size, same as DestructionOccurrenceSpecificationPreferencePage
204
				constraint.width = constraint.height = 20;// set initial size, same as DestructionOccurrenceSpecificationPreferencePage
166
			}
205
			}
167
		}
206
		}
168
		return constraint;
207
		return constraint;
Lines 208-215 Link Here
208
		return new ICommandProxy(new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, viewDescriptor, newBounds));
247
		return new ICommandProxy(new SetBoundsCommand(editingDomain, DiagramUIMessages.SetLocationCommand_Label_Resize, viewDescriptor, newBounds));
209
	}
248
	}
210
249
211
	private Command getCommandForExecutionSpecificationCreation(CreateViewRequest cvr, ViewDescriptor viewDescriptor) {
250
	private Rectangle getCreateExecuteSpecificationBounds(Point location, Dimension size, String semanticHint) {
212
		Point newLocation = cvr.getLocation().getCopy();
251
		Point newLocation = location == null ? new Point() : location.getCopy();
213
252
214
		if(newLocation.x < 0 || newLocation.y < 0) {
253
		if(newLocation.x < 0 || newLocation.y < 0) {
215
			newLocation.x = newLocation.y = 0;
254
			newLocation.x = newLocation.y = 0;
Lines 242-252 Link Here
242
		}
281
		}
243
282
244
		// Get the height of the Execution specification
283
		// Get the height of the Execution specification
245
		int newHeight = getFigureHeight(cvr);
284
		int newHeight = getFigureHeight(semanticHint, size);
285
286
		// Define the bounds of the new Execution specification
287
		return new Rectangle(newLocation.x, newLocation.y, -1, newHeight);
288
	}
289
290
	private ShapeNodeEditPart getParentWhenCreationExecuteSpecification(Point location, Dimension size, String semanticHint) {
291
292
		// Define the bounds of the new Execution specification
293
		Rectangle newBounds = getCreateExecuteSpecificationBounds(location, size, semanticHint);
294
		// Get the dotline figure
295
		List<ShapeNodeEditPart> executionSpecificationList = ((LifelineEditPart)getHost()).getChildShapeNodeEditPart();
246
296
297
		return getParent((LifelineEditPart)getHost(), newBounds, executionSpecificationList);
298
	}
299
		 
300
	private Command getCommandForExecutionSpecificationCreation(CreateViewRequest cvr, ViewDescriptor viewDescriptor) {
301
302
		LifelineEditPart editPart = (LifelineEditPart)getHost();
303
304
		List<ShapeNodeEditPart> executionSpecificationList = editPart.getChildShapeNodeEditPart();
305
306
		Point location = cvr.getLocation();
307
		Dimension size = cvr.getSize();
308
		String semanticHint = viewDescriptor.getSemanticHint();
309
		
247
		// Define the bounds of the new Execution specification
310
		// Define the bounds of the new Execution specification
248
		Rectangle newBounds = new Rectangle(newLocation.x, newLocation.y, -1, newHeight);
311
		Rectangle newBounds = getCreateExecuteSpecificationBounds(location, size, semanticHint);
249
		ShapeNodeEditPart parent = getParent((LifelineEditPart)getHost(), newBounds, executionSpecificationList);
312
		ShapeNodeEditPart parent = getParentWhenCreationExecuteSpecification(location, size, semanticHint);
250
		newBounds = getExecutionSpecificationNewBounds(true, editPart, new Rectangle(), newBounds, new ArrayList<ShapeNodeEditPart>(0), false);
313
		newBounds = getExecutionSpecificationNewBounds(true, editPart, new Rectangle(), newBounds, new ArrayList<ShapeNodeEditPart>(0), false);
251
		if(newBounds == null) {
314
		if(newBounds == null) {
252
			return UnexecutableCommand.INSTANCE;
315
			return UnexecutableCommand.INSTANCE;
Lines 293-299 Link Here
293
			parentFigure.translateToRelative(referencePoint);
356
			parentFigure.translateToRelative(referencePoint);
294
			referencePoint.translate(parentFigure.getBounds().getLocation().getCopy().negate());
357
			referencePoint.translate(parentFigure.getBounds().getLocation().getCopy().negate());
295
			// Get the height of the element
358
			// Get the height of the element
296
			int newHeight = getFigureHeight(cvr);
359
			int newHeight = getFigureHeight(viewDescriptor.getSemanticHint(), cvr.getSize());
297
			// Define the bounds of the new time element
360
			// Define the bounds of the new time element
298
			Rectangle newBounds = new Rectangle(referencePoint.x, referencePoint.y - newHeight / 2, -1, newHeight);
361
			Rectangle newBounds = new Rectangle(referencePoint.x, referencePoint.y - newHeight / 2, -1, newHeight);
299
			TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
362
			TransactionalEditingDomain editingDomain = ((IGraphicalEditPart)getHost()).getEditingDomain();
Lines 346-365 Link Here
346
	 *        the create request
409
	 *        the create request
347
	 * @return the height defined in the create request or a default value depending on the created figure
410
	 * @return the height defined in the create request or a default value depending on the created figure
348
	 */
411
	 */
349
	private int getFigureHeight(CreateRequest cr) {
412
	private int getFigureHeight(String semanticHint, Dimension size) {
350
		final String timeObsHint = ((IHintedType)UMLElementTypes.TimeObservation_3020).getSemanticHint();
351
		final String timeCstHint = ((IHintedType)UMLElementTypes.TimeConstraint_3019).getSemanticHint();
352
		String semHint = null;
353
		if(cr instanceof CreateViewAndElementRequest) {
354
			semHint = ((CreateViewAndElementRequest)cr).getViewAndElementDescriptor().getSemanticHint();
355
		}
356
		int newHeight;
413
		int newHeight;
357
		if(timeObsHint.equals(semHint) || timeCstHint.equals(semHint)) {
414
		if(TIME_OBSERVATION_HINT.equals(semanticHint) || TIME_CONSTRAINT_HINT.equals(semanticHint)) {
358
			// height for a time bar (takes precedence on request's size)
415
			// height for a time bar (takes precedence on request's size)
359
			newHeight = TIME_BAR_HEIGHT;
416
			newHeight = TIME_BAR_HEIGHT;
360
		} else if(cr.getSize() != null) {
417
		} else if(size != null) {
361
			// heigh from request
418
			// heigh from request
362
			newHeight = cr.getSize().height;
419
			newHeight = size.height;
363
		} else {
420
		} else {
364
			newHeight = EXECUTION_INIT_HEIGHT;
421
			newHeight = EXECUTION_INIT_HEIGHT;
365
		}
422
		}
(-)custom-src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/AbstractExecutionSpecificationEditPart.java (+78 lines)
Lines 16-25 Link Here
16
import org.eclipse.draw2d.geometry.Rectangle;
16
import org.eclipse.draw2d.geometry.Rectangle;
17
import org.eclipse.emf.common.notify.Notification;
17
import org.eclipse.emf.common.notify.Notification;
18
import org.eclipse.emf.ecore.EObject;
18
import org.eclipse.emf.ecore.EObject;
19
import org.eclipse.gef.EditPart;
19
import org.eclipse.gef.EditPolicy;
20
import org.eclipse.gef.EditPolicy;
21
import org.eclipse.gef.Request;
22
import org.eclipse.gef.commands.Command;
23
import org.eclipse.gef.commands.UnexecutableCommand;
24
import org.eclipse.gef.handles.HandleBounds;
20
import org.eclipse.gef.requests.ChangeBoundsRequest;
25
import org.eclipse.gef.requests.ChangeBoundsRequest;
21
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
26
import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeNodeEditPart;
22
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy;
27
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.ResizableShapeEditPolicy;
28
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
23
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
29
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.IMapMode;
24
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
30
import org.eclipse.gmf.runtime.draw2d.ui.mapmode.MapModeUtil;
25
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
31
import org.eclipse.gmf.runtime.gef.ui.figures.DefaultSizeNodeFigure;
Lines 108-113 Link Here
108
		super.createDefaultEditPolicies();
114
		super.createDefaultEditPolicies();
109
		installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableShapeEditPolicy(){
115
		installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE, new ResizableShapeEditPolicy(){
110
			@Override
116
			@Override
117
			protected Command getResizeCommand(ChangeBoundsRequest request) {
118
				// Bugfix: Avoid resize ES with the child size is little than parent one. 
119
				EditPart host = getHost();
120
				List<ShapeNodeEditPart> movedChildrenParts = LifelineXYLayoutEditPolicy.getAffixedExecutionSpecificationEditParts((ShapeNodeEditPart)host);
121
				Rectangle r = getInitialFeedbackBounds().getCopy();
122
				getHostFigure().translateToAbsolute(r);
123
				r.translate(0, request.getMoveDelta().y);
124
				r.resize(0, request.getSizeDelta().height);
125
				for(ShapeNodeEditPart child : movedChildrenParts) {
126
					IFigure figure = child.getFigure();
127
					Rectangle rect = figure.getBounds().getCopy();
128
					if (figure instanceof HandleBounds) {
129
						rect = ((HandleBounds)figure).getBounds().getCopy();
130
					}
131
					figure.translateToAbsolute(rect);
132
					if(rect.y < r.y || rect.bottom() > r.bottom()) {
133
						return UnexecutableCommand.INSTANCE;
134
					}
135
				}
136
				return super.getResizeCommand(request);
137
			}
138
	
139
			@Override
111
			protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
140
			protected void showChangeBoundsFeedback(ChangeBoundsRequest request) {
112
				request.getMoveDelta().x = 0; // reset offset
141
				request.getMoveDelta().x = 0; // reset offset
113
				
142
				
Lines 297-300 Link Here
297
			}
326
			}
298
		}
327
		}
299
	}
328
	}
329
	
330
	/**
331
	 * Override for add elements on ExecutionSpecification
332
	 */
333
	@Override
334
	public Command getCommand(Request request) {
335
		if(request instanceof CreateUnspecifiedTypeRequest) {
336
			return getParent().getCommand(request);
337
		}
338
		return super.getCommand(request);
339
	}
340
341
	/**
342
	 * @generated NOT Override for redirecting creation request to the lifeline
343
	 */
344
	@Override
345
	public void showSourceFeedback(Request request) {
346
		if(request instanceof CreateUnspecifiedTypeRequest) {
347
			getParent().showSourceFeedback(request);
348
		}
349
		super.showSourceFeedback(request);
350
	}
351
352
	/**
353
	 * @generated NOT Override for redirecting creation request to the lifeline
354
	 */
355
	@Override
356
	public void eraseSourceFeedback(Request request) {
357
		if(request instanceof CreateUnspecifiedTypeRequest) {
358
			getParent().eraseSourceFeedback(request);
359
		}
360
		super.eraseSourceFeedback(request);
361
	}
362
363
	@Override
364
	public void showTargetFeedback(Request request) {
365
		if(request instanceof CreateUnspecifiedTypeRequest) {
366
			getParent().showTargetFeedback(request);
367
		}
368
		super.showTargetFeedback(request);
369
	}
370
371
	@Override
372
	public void eraseTargetFeedback(Request request) {
373
		if(request instanceof CreateUnspecifiedTypeRequest) {
374
			getParent().eraseSourceFeedback(request);
375
		}
376
		super.eraseTargetFeedback(request);
377
	}
300
}
378
}
(-)custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/SequenceDeleteHelper.java (-1 / +2 lines)
Lines 305-311 Link Here
305
	public static void addDeleteMessageRelatedTimeObservationLinkCommand(
305
	public static void addDeleteMessageRelatedTimeObservationLinkCommand(
306
			TransactionalEditingDomain editingDomain, EditPart editPart,
306
			TransactionalEditingDomain editingDomain, EditPart editPart,
307
			CompositeCommand command, MessageEnd messageEnd,boolean deleteRelatedEvent) {
307
			CompositeCommand command, MessageEnd messageEnd,boolean deleteRelatedEvent) {
308
		if(messageEnd != null){
308
		//Bug fix: messageEnd maybe a Gate instance.
309
		if(messageEnd != null && messageEnd instanceof OccurrenceSpecification){
309
			OccurrenceSpecification occurrenceSpecification = (OccurrenceSpecification) messageEnd;
310
			OccurrenceSpecification occurrenceSpecification = (OccurrenceSpecification) messageEnd;
310
			EList<Lifeline> receiveCovereds = occurrenceSpecification.getCovereds();
311
			EList<Lifeline> receiveCovereds = occurrenceSpecification.getCovereds();
311
			CompoundCommand CompoundCommand = new CompoundCommand();
312
			CompoundCommand CompoundCommand = new CompoundCommand();
(-)custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/ReconnectMessageHelper.java (+29 lines)
Lines 24-29 Link Here
24
import org.eclipse.uml2.uml.Message;
24
import org.eclipse.uml2.uml.Message;
25
import org.eclipse.uml2.uml.MessageEnd;
25
import org.eclipse.uml2.uml.MessageEnd;
26
import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
26
import org.eclipse.uml2.uml.MessageOccurrenceSpecification;
27
import org.eclipse.uml2.uml.MessageSort;
27
import org.eclipse.uml2.uml.OccurrenceSpecification;
28
import org.eclipse.uml2.uml.OccurrenceSpecification;
28
29
29
/**
30
/**
Lines 150-153 Link Here
150
			}
151
			}
151
		}
152
		}
152
	}
153
	}
154
155
	/**
156
	 * It seems that OCL constraints can not hold everything about reconnecting messages.
157
	 * 
158
	 * @param message
159
	 * @param newTarget
160
	 */
161
	public static boolean canReorientTarget(Message message, Element newTarget) {
162
		if(message == null || newTarget == null) {
163
			return false;
164
		}
165
		MessageSort messageSort = message.getMessageSort();
166
		if(MessageSort.SYNCH_CALL_LITERAL == messageSort) {
167
			return newTarget instanceof ExecutionSpecification;
168
		}
169
		return true;
170
	}
171
172
	public static boolean canReorientSource(Message message, Element newSource) {
173
		if(message == null || newSource == null) {
174
			return false;
175
		}
176
		MessageSort messageSort = message.getMessageSort();
177
		if(MessageSort.SYNCH_CALL_LITERAL == messageSort) {
178
			return newSource instanceof ExecutionSpecification;
179
		}
180
		return true;
181
	}
153
}
182
}
(-)custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/HighlightUtil.java (-111 / +187 lines)
Lines 8-196 Link Here
8
import java.util.Map.Entry;
8
import java.util.Map.Entry;
9
import java.util.Set;
9
import java.util.Set;
10
10
11
import org.eclipse.draw2d.Border;
11
import org.eclipse.draw2d.ColorConstants;
12
import org.eclipse.draw2d.ColorConstants;
12
import org.eclipse.draw2d.IFigure;
13
import org.eclipse.draw2d.IFigure;
14
import org.eclipse.draw2d.LineBorder;
15
import org.eclipse.draw2d.Polyline;
13
import org.eclipse.draw2d.RectangleFigure;
16
import org.eclipse.draw2d.RectangleFigure;
17
import org.eclipse.draw2d.Shape;
14
import org.eclipse.draw2d.geometry.Rectangle;
18
import org.eclipse.draw2d.geometry.Rectangle;
15
import org.eclipse.gef.EditPart;
19
import org.eclipse.gef.EditPart;
16
import org.eclipse.gef.Request;
20
import org.eclipse.gef.Request;
17
import org.eclipse.gef.requests.CreateRequest;
21
import org.eclipse.gef.requests.CreateRequest;
18
import org.eclipse.papyrus.uml.diagram.common.figure.node.ConstraintFigure;
22
import org.eclipse.papyrus.infra.gmfdiag.common.editpart.IPapyrusEditPart;
19
import org.eclipse.papyrus.uml.diagram.common.figure.node.HTMLCornerBentFigure;
20
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
23
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart;
21
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.AbstractExecutionSpecificationEditPart.ExecutionSpecificationRectangleFigure;
22
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
24
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CombinedFragmentEditPart;
23
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentEditPart;
25
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.CommentEditPart;
24
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart;
26
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.ConstraintEditPart;
25
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
27
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.InteractionOperandEditPart;
26
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
28
import org.eclipse.papyrus.uml.diagram.sequence.edit.parts.LifelineEditPart;
27
import org.eclipse.papyrus.uml.diagram.sequence.figures.CombinedFragmentFigure;
28
import org.eclipse.swt.graphics.Color;
29
import org.eclipse.swt.graphics.Color;
29
30
30
31
31
public class HighlightUtil {
32
public class HighlightUtil {
33
34
	private static class FigureState {
35
36
		private Color bgColor;
37
38
		private Color fgColor;
39
40
		private int lineWidth;
41
42
		public FigureState(Color bgColor, Color fgColor, int lineWidth) {
43
			this.bgColor = bgColor;
44
			this.fgColor = fgColor;
45
			this.lineWidth = lineWidth;
46
		}
47
	}
48
32
	public static final Color COVER_COLOR = ColorConstants.cyan;
49
	public static final Color COVER_COLOR = ColorConstants.cyan;
50
33
	public static final Color TARGET_COLOR = ColorConstants.cyan;
51
	public static final Color TARGET_COLOR = ColorConstants.cyan;
52
34
	public static final Color SOURCE_COLOR = ColorConstants.cyan;
53
	public static final Color SOURCE_COLOR = ColorConstants.cyan;
35
	
54
36
	static Map<LifelineEditPart, Rectangle> lifelines ;
55
	static Map<LifelineEditPart, Rectangle> lifelines;
56
37
	static List<LifelineEditPart> highlightLifelines = new ArrayList<LifelineEditPart>();
57
	static List<LifelineEditPart> highlightLifelines = new ArrayList<LifelineEditPart>();
38
	static Map<EditPart,FigureState> figureState = new HashMap<EditPart,FigureState>();
39
	
58
	
59
	static Map<EditPart, FigureState> feedbackStates = new HashMap<EditPart, HighlightUtil.FigureState>();
60
40
	public static Map<LifelineEditPart, Rectangle> collectAllLifelines(EditPart part) {
61
	public static Map<LifelineEditPart, Rectangle> collectAllLifelines(EditPart part) {
41
		Map<LifelineEditPart,Rectangle> lifelines = new HashMap<LifelineEditPart,Rectangle>();
62
		Map<LifelineEditPart, Rectangle> lifelines = new HashMap<LifelineEditPart, Rectangle>();
42
		Set<Entry<Object, EditPart>> allEditPartEntries = part.getViewer().getEditPartRegistry().entrySet();
63
		Set<Entry<Object, EditPart>> allEditPartEntries = part.getViewer().getEditPartRegistry().entrySet();
43
		for(Entry<Object, EditPart> epEntry : allEditPartEntries) {
64
		for(Entry<Object, EditPart> epEntry : allEditPartEntries) {
44
			EditPart ep = epEntry.getValue();
65
			EditPart ep = epEntry.getValue();
45
			if(!(ep instanceof LifelineEditPart))
66
			if(!(ep instanceof LifelineEditPart))
46
				continue;
67
				continue;
47
				
68
48
			LifelineEditPart lp = (LifelineEditPart)ep;
69
			LifelineEditPart lp = (LifelineEditPart)ep;
49
			IFigure figure = lp.getFigure();
70
			IFigure figure = lp.getFigure();
50
			Rectangle childBounds = figure.getBounds().getCopy();
71
			Rectangle childBounds = figure.getBounds().getCopy();
51
			figure.translateToAbsolute(childBounds);
72
			figure.translateToAbsolute(childBounds);
52
			Rectangle centralLineBounds = new Rectangle(
73
			Rectangle centralLineBounds = new Rectangle(childBounds.x() + childBounds.width() / 2, childBounds.y(), 1, childBounds.height());
53
					childBounds.x() +  childBounds.width() / 2,
74
54
					childBounds.y(), 1,  childBounds.height());
75
			lifelines.put(lp, centralLineBounds);
55
			
56
			lifelines.put(lp, centralLineBounds);					
57
		}
76
		}
58
		return lifelines;
77
		return lifelines;
59
	}
78
	}
60
	
79
61
	public static void showSizeOnDropFeedback(CreateRequest request,EditPart host, IFigure feedback, Rectangle bounds){
80
	public static void eraseSizeOnDropFeedback(Request request, EditPart host) {
62
		if(lifelines == null){
81
		for(LifelineEditPart lp : highlightLifelines) {
82
			FigureState s = feedbackStates.get(lp);
83
			if(s == null)
84
				continue;
85
86
			RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();
87
			rect.setBackgroundColor(s.bgColor);
88
			rect.setFill(true);
89
		}
90
91
		lifelines = null;
92
		highlightLifelines = new ArrayList<LifelineEditPart>();
93
	}
94
95
	public static void showSizeOnDropFeedback(CreateRequest request, EditPart host, IFigure feedback, Rectangle bounds) {
96
		if(lifelines == null) {
63
			lifelines = collectAllLifelines(host);
97
			lifelines = collectAllLifelines(host);
64
			highlightLifelines = new ArrayList<LifelineEditPart>();
98
			highlightLifelines = new ArrayList<LifelineEditPart>();
65
		}
99
		}
66
		
100
67
		List<LifelineEditPart> addLifelines = new ArrayList<LifelineEditPart>();
101
		List<LifelineEditPart> addLifelines = new ArrayList<LifelineEditPart>();
68
		List<LifelineEditPart> removeLifelines = new ArrayList<LifelineEditPart>();
102
		List<LifelineEditPart> removeLifelines = new ArrayList<LifelineEditPart>();
69
		
103
70
		Iterator<Entry<LifelineEditPart, Rectangle>> it = lifelines.entrySet().iterator();
104
		Iterator<Entry<LifelineEditPart, Rectangle>> it = lifelines.entrySet().iterator();
71
		while(it.hasNext()){
105
		while(it.hasNext()) {
72
			Entry<LifelineEditPart, Rectangle> en = it.next();
106
			Entry<LifelineEditPart, Rectangle> en = it.next();
73
			
107
74
			if(bounds.intersects(en.getValue())){
108
			if(bounds.intersects(en.getValue())) {
75
				if(!highlightLifelines.contains(en.getKey()))
109
				if(!highlightLifelines.contains(en.getKey()))
76
					addLifelines.add(en.getKey());
110
					addLifelines.add(en.getKey());
77
			}else{
111
			} else {
78
				if(highlightLifelines.contains(en.getKey()))
112
				if(highlightLifelines.contains(en.getKey()))
79
					removeLifelines.add(en.getKey());
113
					removeLifelines.add(en.getKey());
80
			}
114
			}
81
		}
115
		}
82
		
116
83
		highlightLifelines.removeAll(removeLifelines);
117
		highlightLifelines.removeAll(removeLifelines);
84
		highlightLifelines.addAll(addLifelines);
118
		highlightLifelines.addAll(addLifelines);
85
		
119
86
		// highlight lifeline inside
120
		// highlight lifeline inside
87
		for(LifelineEditPart lp : addLifelines){
121
		for(LifelineEditPart lp : addLifelines) {
88
			RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();
122
			RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();
89
			figureState.put(lp, new FigureState(rect.getBackgroundColor()));
123
			feedbackStates.put(lp, new FigureState(rect.getBackgroundColor(), rect.getForegroundColor(), rect.getLineWidth()));
90
			rect.setBackgroundColor(COVER_COLOR);
124
			rect.setBackgroundColor(COVER_COLOR);
91
			rect.setFill(true);
125
			rect.setFill(true);
92
		}
126
		}
93
		
127
94
		// restore lifeline outside
128
		// restore lifeline outside
95
		for(LifelineEditPart lp : removeLifelines){
129
		for(LifelineEditPart lp : removeLifelines) {
96
			FigureState s = figureState.get(lp);
130
			FigureState s = feedbackStates.get(lp);
97
			if(s == null)
131
			if(s == null)
98
				continue;
132
				continue;
99
			
100
			RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();			
101
			rect.setBackgroundColor(s.bgColor);
102
			rect.setFill(true);
103
		}
104
	}
105
133
106
	public static void eraseSizeOnDropFeedback(Request request, EditPart host) {
107
		for(LifelineEditPart lp : highlightLifelines){
108
			FigureState s = figureState.get(lp);
109
			if(s == null)
110
				continue;
111
			
112
			RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();
134
			RectangleFigure rect = lp.getPrimaryShape().getFigureLifelineNameContainerFigure();
113
			rect.setBackgroundColor(s.bgColor);
135
			rect.setBackgroundColor(s.bgColor);
114
			rect.setFill(true);
136
			rect.setFill(true);
115
		}
137
		}
116
		
117
		lifelines = null;
118
		highlightLifelines = new ArrayList<LifelineEditPart>();		
119
	}
138
	}
120
	
139
121
	public static void showConnectionFeedback(EditPart host, Color color) {
140
	private Map<Object, FigureState> figureState = new HashMap<Object, FigureState>();
122
		if(host instanceof LifelineEditPart){
141
142
	/**
143
	 * Maybe this value can be managed by preferences.
144
	 */
145
	private Color getHighlightBackground() {
146
		return null;
147
	}
148
149
	/**
150
	 * Maybe this value can be managed by preferences.
151
	 */
152
	private int getHighlightBorderWidth() {
153
		return 2;
154
	}
155
156
	private List<IFigure> getHighlightFigures(EditPart host) {
157
		List<IFigure> figures = new ArrayList<IFigure>();
158
		if(host instanceof LifelineEditPart) {
123
			LifelineEditPart part = (LifelineEditPart)host;
159
			LifelineEditPart part = (LifelineEditPart)host;
124
			RectangleFigure fig = part.getPrimaryShape().getFigureLifelineNameContainerFigure();
160
			figures.add(part.getPrimaryShape().getFigureLifelineNameContainerFigure());
125
			saveIfNotExist(host, fig);
161
			figures.add(part.getPrimaryShape().getFigureLifelineDotLineFigure());
126
			fig.setBackgroundColor(color);
162
		} else if(host instanceof AbstractExecutionSpecificationEditPart) {
127
			fig.setFill(true);
163
			figures.add(((AbstractExecutionSpecificationEditPart)host).getPrimaryShape());
128
		}else if(host instanceof AbstractExecutionSpecificationEditPart){
164
		} else if(host instanceof CombinedFragmentEditPart) {
129
			ExecutionSpecificationRectangleFigure fig = ((AbstractExecutionSpecificationEditPart)host).getPrimaryShape();
165
			figures.add(((CombinedFragmentEditPart)host).getPrimaryShape());
130
			saveIfNotExist(host, fig);
166
		} else if(host instanceof InteractionOperandEditPart) {
131
			fig.setBackgroundColor(color);
167
			InteractionOperandEditPart op = (InteractionOperandEditPart)host;
132
		}else if(host instanceof CombinedFragmentEditPart){
168
			CombinedFragmentEditPart cep = (CombinedFragmentEditPart)op.getParent().getParent();
133
			CombinedFragmentFigure fig = ((CombinedFragmentEditPart)host).getPrimaryShape();
169
			figures.add(cep.getPrimaryShape());
134
			saveIfNotExist(host, fig);
170
		} else if(host instanceof CommentEditPart) {
135
			fig.setBackgroundColor(color);
171
			figures.add(((CommentEditPart)host).getPrimaryShape());
136
		}else if(host instanceof InteractionOperandEditPart){
172
		} else if(host instanceof ConstraintEditPart) {
137
			InteractionOperandEditPart op = (InteractionOperandEditPart) host;
173
			figures.add(((ConstraintEditPart)host).getPrimaryShape());
138
			CombinedFragmentEditPart cep = (CombinedFragmentEditPart) op.getParent().getParent();
174
		} else if(host instanceof IPapyrusEditPart) {
139
			CombinedFragmentFigure fig = cep.getPrimaryShape();
175
			figures.add(((IPapyrusEditPart)host).getPrimaryShape());
140
			saveIfNotExist(host, fig);
141
			fig.setBackgroundColor(color);
142
		}else if(host instanceof CommentEditPart){
143
			HTMLCornerBentFigure fig = ((CommentEditPart)host).getPrimaryShape();
144
			saveIfNotExist(host, fig);
145
			fig.setBackgroundColor(color);
146
		}else if(host instanceof ConstraintEditPart){
147
			ConstraintFigure fig = ( (ConstraintEditPart) host).getPrimaryShape();
148
			saveIfNotExist(host, fig);
149
			fig.setBackgroundColor(color);
150
		}
176
		}
177
		return figures;
151
	}
178
	}
152
179
153
	protected static void saveIfNotExist(EditPart host, IFigure fig) {
180
	/**
154
		if(!figureState.containsKey(host))
181
	 * Maybe this value can be managed by preferences.
155
			figureState.put(host, new FigureState(fig.getBackgroundColor()));
182
	 */
183
	private Color getHighlightForeground() {
184
		return null;
156
	}
185
	}
157
	
186
158
	public static void eraseConnectionFeedback(EditPart host) {
187
	public void highlight(EditPart host) {
159
		FigureState s = figureState.get(host);
188
		List<IFigure> highlightFigures = getHighlightFigures(host);
160
		if(s == null)
189
		if(highlightFigures.isEmpty()) {
161
			return;
190
			return;
162
		
191
		}
163
		if(host instanceof LifelineEditPart){
192
164
			LifelineEditPart part = (LifelineEditPart)host;
193
		Color background = getHighlightBackground();
165
			RectangleFigure fig = part.getPrimaryShape().getFigureLifelineNameContainerFigure();
194
		Color foreground = getHighlightForeground();
166
			fig.setBackgroundColor(s.bgColor);
195
		int lineWidth = getHighlightBorderWidth();
167
			fig.setFill(true);
196
		for(IFigure figure : highlightFigures) {
168
		}else if(host instanceof AbstractExecutionSpecificationEditPart){
197
			saveIfNotExist(figure, figure);
169
			ExecutionSpecificationRectangleFigure fig = ((AbstractExecutionSpecificationEditPart)host).getPrimaryShape();
198
			updateFigure(figure, background, foreground, lineWidth);
170
			fig.setBackgroundColor(s.bgColor);
171
		}else if(host instanceof CombinedFragmentEditPart){
172
			CombinedFragmentEditPart cep = (CombinedFragmentEditPart)host;
173
			cep.getPrimaryShape().setBackgroundColor(s.bgColor);
174
		}else if(host instanceof InteractionOperandEditPart){
175
			InteractionOperandEditPart op = (InteractionOperandEditPart) host;
176
			CombinedFragmentEditPart cep = (CombinedFragmentEditPart) op.getParent().getParent();
177
			cep.getPrimaryShape().setBackgroundColor(s.bgColor);
178
		}else if(host instanceof CommentEditPart){
179
			HTMLCornerBentFigure fig = ((CommentEditPart)host).getPrimaryShape();
180
			fig.setBackgroundColor(s.bgColor);
181
		}else if(host instanceof ConstraintEditPart){
182
			ConstraintFigure fig = ( (ConstraintEditPart) host).getPrimaryShape();
183
			fig.setBackgroundColor(s.bgColor);
184
		}
199
		}
185
		
186
		figureState.remove(host);
187
	}
200
	}
188
	
201
189
	static class FigureState{		
202
	protected void saveIfNotExist(Object host, IFigure fig) {
190
		Color bgColor;
203
		if(!figureState.containsKey(host)) {
191
		
204
			int lineWidth = 1;
192
		public FigureState(Color bgColor) {
205
			Border border = fig.getBorder();
193
			this.bgColor = bgColor;
206
			if(border instanceof LineBorder) {
207
				lineWidth = ((LineBorder)border).getWidth();
208
			} else if(fig instanceof Shape) {
209
				lineWidth = ((Shape)fig).getLineWidth();
210
			}
211
			figureState.put(host, new FigureState(fig.getBackgroundColor(), fig.getForegroundColor(), lineWidth));
194
		}
212
		}
195
	}
213
	}
214
215
	public void unhighlight() {
216
		if(figureState == null || figureState.isEmpty()) {
217
			return;
218
		}
219
		Set<Entry<Object, FigureState>> entrySet = figureState.entrySet();
220
		for(Entry<Object, FigureState> entry : entrySet) {
221
			Object key = entry.getKey();
222
			FigureState value = entry.getValue();
223
			if(key instanceof IFigure) {
224
				IFigure fig = (IFigure)key;
225
				updateFigure(fig, value.bgColor, value.fgColor, value.lineWidth);
226
			} else if(key instanceof EditPart) {
227
				List<IFigure> figures = getHighlightFigures((EditPart)key);
228
				for(IFigure fig : figures) {
229
					updateFigure(fig, value.bgColor, value.fgColor, value.lineWidth);
230
				}
231
			}
232
		}
233
		figureState.clear();
234
	}
235
236
	public void unhighlight(EditPart host) {
237
		List<IFigure> highlightFigures = getHighlightFigures(host);
238
		if(highlightFigures.isEmpty()) {
239
			return;
240
		}
241
		for(IFigure figure : highlightFigures) {
242
			FigureState s = figureState.remove(figure);
243
			if(s == null) {
244
				continue;
245
			}
246
			updateFigure(figure, s.bgColor, s.fgColor, s.lineWidth);
247
		}
248
	}
249
250
	private void updateFigure(IFigure fig, Color bgColor, Color fgColor, int lineWidth) {
251
		if(fig == null) {
252
			return;
253
		}
254
		if(lineWidth > 0) {
255
			Border border = fig.getBorder();
256
			if(border != null && border instanceof LineBorder) {
257
				((LineBorder)border).setWidth(lineWidth);
258
			} else if(fig instanceof Shape) {
259
				((Shape)fig).setLineWidth(lineWidth);
260
			} else if(fig instanceof Polyline) {
261
				((Polyline)fig).setLineWidth(lineWidth);
262
			}
263
		}
264
		if(bgColor != null) {
265
			fig.setBackgroundColor(bgColor);
266
		}
267
		if(fgColor != null) {
268
			fig.setForegroundColor(fgColor);
269
		}
270
		fig.repaint();
271
	}
196
}
272
}
(-)custom-src/org/eclipse/papyrus/uml/diagram/sequence/util/LifelineModelChildrenHelper.java (+90 lines)
Line 0 Link Here
1
package org.eclipse.papyrus.uml.diagram.sequence.util;
2
3
import java.util.ArrayList;
4
import java.util.Collections;
5
import java.util.Comparator;
6
import java.util.List;
7
8
import org.eclipse.draw2d.geometry.Rectangle;
9
import org.eclipse.emf.ecore.EObject;
10
import org.eclipse.emf.ecore.EStructuralFeature;
11
import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
12
import org.eclipse.gmf.runtime.notation.NotationPackage;
13
import org.eclipse.gmf.runtime.notation.View;
14
import org.eclipse.uml2.uml.ExecutionSpecification;
15
16
17
public class LifelineModelChildrenHelper {
18
19
	/**
20
	 * Try to fixed the bug about display ExecutionSpecifications(ES).
21
	 * 
22
	 * At some times, the child ES would be displayed under the parent ES.
23
	 * 
24
	 * Fixed to sort them with bounds in model before creating.
25
	 */
26
	public static List<View> getModelChildren(View lifeline) {
27
		if(lifeline == null) {
28
			return Collections.emptyList();
29
		}
30
		@SuppressWarnings("unchecked")
31
		List<View> children = new ArrayList<View>(lifeline.getVisibleChildren());
32
		sortChildren(children);
33
		return children;
34
	}
35
36
	private static void sortChildren(List<View> children) {
37
		Collections.sort(children, new Comparator<Object>() {
38
39
			public int compare(Object o1, Object o2) {
40
				if(!(o1 instanceof View && o2 instanceof View)) {
41
					return 0;
42
				}
43
				View v1 = (View)o1;
44
				View v2 = (View)o2;
45
				EObject e1 = ViewUtil.resolveSemanticElement(v1);
46
				EObject e2 = ViewUtil.resolveSemanticElement(v2);
47
				if(!(e1 instanceof ExecutionSpecification && e2 instanceof ExecutionSpecification)) {
48
					return 0;
49
				}
50
				Rectangle r1 = getViewBounds(v1);
51
				Rectangle r2 = getViewBounds(v2);
52
				if(r1 == null || r2 == null) {
53
					return 0;
54
				}
55
				if(r1.width <= 0) {
56
					r1.width = 16;
57
				}
58
				if(r2.width <= 0) {
59
					r2.width = 16;
60
				}
61
62
				if((r1.x < r2.x) || r1.right() < r2.right()) {
63
					return -1;
64
				}
65
				return 1;
66
			}
67
		});
68
	}
69
70
	private static Rectangle getViewBounds(View view) {
71
		if(view == null) {
72
			return null;
73
		}
74
		Integer x = getFeatureValue(view, NotationPackage.eINSTANCE.getLocation_X());
75
		Integer y = getFeatureValue(view, NotationPackage.eINSTANCE.getLocation_Y());
76
		Integer width = getFeatureValue(view, NotationPackage.eINSTANCE.getSize_Width());
77
		Integer height = getFeatureValue(view, NotationPackage.eINSTANCE.getSize_Height());
78
		if(x == null && y == null && width == null && height == null) {
79
			return null;
80
		}
81
		return new Rectangle(x == null ? 0 : x.intValue(), y == null ? 0 : y.intValue(), width == null ? -1 : width.intValue(), height == null ? -1 : height.intValue());
82
	}
83
84
	private static Integer getFeatureValue(View view, EStructuralFeature feature) {
85
		if(view == null || feature == null) {
86
			return null;
87
		}
88
		return (Integer)ViewUtil.getPropertyValue(view, feature, feature.getEContainingClass());
89
	}
90
}
(-)src/org/eclipse/papyrus/uml/diagram/sequence/edit/commands/MessageReorientCommand.java (-3 / +11 lines)
Lines 83-93 Link Here
83
			return false;
83
			return false;
84
		}
84
		}
85
		Interaction container = (Interaction)getLink().eContainer();
85
		Interaction container = (Interaction)getLink().eContainer();
86
		return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistMessage_4003(container, getLink(), getNewSource(), getOldTarget());
86
		boolean canExistMessage = UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistMessage_4003(container, getLink(), getNewSource(), getOldTarget());
87
		if(!canExistMessage) {
88
			return false;
89
		}
90
		//Fixed bug about reconnect messages.
91
		return ReconnectMessageHelper.canReorientSource(getLink(), getNewSource());
87
	}
92
	}
88
93
89
	/**
94
	/**
90
	 * @generated
95
	 * @generated NOT
91
	 */
96
	 */
92
	protected boolean canReorientTarget() {
97
	protected boolean canReorientTarget() {
93
		if(!(oldEnd instanceof Element && newEnd instanceof Element)) {
98
		if(!(oldEnd instanceof Element && newEnd instanceof Element)) {
Lines 98-104 Link Here
98
			return false;
103
			return false;
99
		}
104
		}
100
		Interaction container = (Interaction)getLink().eContainer();
105
		Interaction container = (Interaction)getLink().eContainer();
101
		return UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistMessage_4003(container, getLink(), source, getNewTarget());
106
		if(!UMLBaseItemSemanticEditPolicy.getLinkConstraints().canExistMessage_4003(container, getLink(), source, getNewTarget())) {
107
			return false;
108
		}
109
		return ReconnectMessageHelper.canReorientTarget(getLink(), getNewTarget());
102
	}
110
	}
103
111
104
	/**
112
	/**
(-)src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/BehaviorExecutionSpecificationEditPart.java (-34 lines)
Lines 36-42 Link Here
36
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
36
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
37
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
37
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
38
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
38
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
39
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
40
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
39
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
41
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
40
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
42
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
41
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
Lines 1115-1151 Link Here
1115
		return super.getSourceConnectionAnchor(connEditPart);
1114
		return super.getSourceConnectionAnchor(connEditPart);
1116
	}
1115
	}
1117
1116
1118
	/**
1119
	 * Override for add elements on ExecutionSpecification
1120
	 */
1121
	@Override
1122
	public Command getCommand(Request request) {
1123
		if(request instanceof CreateUnspecifiedTypeRequest) {
1124
			return getParent().getCommand(request);
1125
		}
1126
		return super.getCommand(request);
1127
	}
1128
1129
	/**
1130
	 * @generated NOT Override for redirecting creation request to the lifeline
1131
	 */
1132
	@Override
1133
	public void showSourceFeedback(Request request) {
1134
		if(request instanceof CreateUnspecifiedTypeRequest) {
1135
			getParent().showSourceFeedback(request);
1136
		}
1137
		super.showSourceFeedback(request);
1138
	}
1139
1140
	/**
1141
	 * @generated NOT Override for redirecting creation request to the lifeline
1142
	 */
1143
	@Override
1144
	public void eraseSourceFeedback(Request request) {
1145
		if(request instanceof CreateUnspecifiedTypeRequest) {
1146
			getParent().eraseSourceFeedback(request);
1147
		}
1148
		super.eraseSourceFeedback(request);
1149
	}
1150
1151
}
1117
}
(-)src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/LifelineEditPart.java (+11 lines)
Lines 116-121 Link Here
116
import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
116
import org.eclipse.papyrus.uml.diagram.sequence.util.CommandHelper;
117
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineCoveredByUpdater;
117
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineCoveredByUpdater;
118
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageCreateHelper;
118
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineMessageCreateHelper;
119
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineModelChildrenHelper;
119
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineResizeHelper;
120
import org.eclipse.papyrus.uml.diagram.sequence.util.LifelineResizeHelper;
120
import org.eclipse.papyrus.uml.diagram.sequence.util.NotificationHelper;
121
import org.eclipse.papyrus.uml.diagram.sequence.util.NotificationHelper;
121
import org.eclipse.swt.graphics.Color;
122
import org.eclipse.swt.graphics.Color;
Lines 1150-1155 Link Here
1150
		}
1151
		}
1151
		return types;
1152
		return types;
1152
	}
1153
	}
1154
	
1155
	@Override
1156
	protected List getModelChildren() {
1157
		Object model = getModel();
1158
		//Fixed bug about inverse order for ExecutionSpecifications.
1159
		if (model instanceof View){
1160
			return LifelineModelChildrenHelper.getModelChildren((View)model);
1161
		}
1162
		return super.getModelChildren();
1163
	}
1153
1164
1154
	/**
1165
	/**
1155
	 * @generated
1166
	 * @generated
(-)src/org/eclipse/papyrus/uml/diagram/sequence/edit/parts/ActionExecutionSpecificationEditPart.java (-58 / +25 lines)
Lines 36-42 Link Here
36
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
36
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
37
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
37
import org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles;
38
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
38
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeConnectionRequest;
39
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest;
40
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
39
import org.eclipse.gmf.runtime.draw2d.ui.figures.FigureUtilities;
41
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
40
import org.eclipse.gmf.runtime.emf.type.core.IElementType;
42
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
41
import org.eclipse.gmf.runtime.gef.ui.figures.NodeFigure;
Lines 172-178 Link Here
172
		final NodeFigure figure = createNodePlate();
171
		final NodeFigure figure = createNodePlate();
173
		figure.setLayoutManager(new DelegatingLayout());
172
		figure.setLayoutManager(new DelegatingLayout());
174
		//figure.setLayoutManager(new StackLayout());
173
		//figure.setLayoutManager(new StackLayout());
175
	 
174
176
		IFigure shape = createNodeShape();
175
		IFigure shape = createNodeShape();
177
		figure.add(shape, new FillParentLocator());
176
		figure.add(shape, new FillParentLocator());
178
		contentPane = setupContentPane(shape);
177
		contentPane = setupContentPane(shape);
Lines 212-226 Link Here
212
		}
211
		}
213
	}
212
	}
214
213
215
//	/**
214
	//	/**
216
//	 * @generated
215
	//	 * @generated
217
//	 */
216
	//	 */
218
//	@Override
217
	//	@Override
219
//	protected void setLineWidth(int width) {
218
	//	protected void setLineWidth(int width) {
220
//		if(primaryShape instanceof Shape) {
219
	//		if(primaryShape instanceof Shape) {
221
//			((Shape)primaryShape).setLineWidth(width);
220
	//			((Shape)primaryShape).setLineWidth(width);
222
//		}
221
	//		}
223
//	}
222
	//	}
224
223
225
	/**
224
	/**
226
	 * @generated
225
	 * @generated
Lines 976-995 Link Here
976
		return types;
975
		return types;
977
	}
976
	}
978
977
979
//	/**
978
	//	/**
980
//	 * @generated
979
	//	 * @generated
981
//	 */
980
	//	 */
982
//	public class ExecutionSpecificationRectangleFigure extends RectangleFigure {
981
	//	public class ExecutionSpecificationRectangleFigure extends RectangleFigure {
983
//
982
	//
984
//		/**
983
	//		/**
985
//		 * @generated
984
	//		 * @generated
986
//		 */
985
	//		 */
987
//		public ExecutionSpecificationRectangleFigure() {
986
	//		public ExecutionSpecificationRectangleFigure() {
988
//			this.setPreferredSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(60)));
987
	//			this.setPreferredSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(60)));
989
//			this.setMinimumSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(20)));
988
	//			this.setMinimumSize(new Dimension(getMapMode().DPtoLP(16), getMapMode().DPtoLP(20)));
990
//		}
989
	//		}
991
//
990
	//
992
//	}
991
	//	}
993
992
994
	/**
993
	/**
995
	 * @generated
994
	 * @generated
Lines 1028-1034 Link Here
1028
	/**
1027
	/**
1029
	 * Add connection on top off the figure during the feedback.
1028
	 * Add connection on top off the figure during the feedback.
1030
	 */
1029
	 */
1031
 
1030
1032
	public ConnectionAnchor getTargetConnectionAnchor(Request request) {
1031
	public ConnectionAnchor getTargetConnectionAnchor(Request request) {
1033
		if(request instanceof CreateUnspecifiedTypeConnectionRequest) {
1032
		if(request instanceof CreateUnspecifiedTypeConnectionRequest) {
1034
			CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest)request;
1033
			CreateUnspecifiedTypeConnectionRequest createRequest = (CreateUnspecifiedTypeConnectionRequest)request;
Lines 1118-1153 Link Here
1118
		return super.getSourceConnectionAnchor(connEditPart);
1117
		return super.getSourceConnectionAnchor(connEditPart);
1119
	}
1118
	}
1120
1119
1121
	/**
1122
	 * Override for adding elements on ExecutionSpecification
1123
	 */
1124
	@Override
1125
	public Command getCommand(Request request) {
1126
		if(request instanceof CreateUnspecifiedTypeRequest) {
1127
			return getParent().getCommand(request);
1128
		}
1129
		return super.getCommand(request);
1130
	}
1131
1132
	/**
1133
	 * @generated NOT Override for redirecting creation request to the lifeline
1134
	 */
1135
	@Override
1136
	public void showSourceFeedback(Request request) {
1137
		if(request instanceof CreateUnspecifiedTypeRequest) {
1138
			getParent().showSourceFeedback(request);
1139
		}
1140
		super.showSourceFeedback(request);
1141
	}
1142
1143
	/**
1144
	 * @generated NOT Override for redirecting creation request to the lifeline
1145
	 */
1146
	@Override
1147
	public void eraseSourceFeedback(Request request) {
1148
		if(request instanceof CreateUnspecifiedTypeRequest) {
1149
			getParent().eraseSourceFeedback(request);
1150
		}
1151
		super.eraseSourceFeedback(request);
1152
	}
1153
}
1120
}

Return to bug 377501