/** * Overridden to tells if the specified {@link ISequenceEvent} is owned by the current {@link * Lifeline}. * * <p>{@inheritDoc} */ public boolean apply(ISequenceEvent input) { boolean result = false; Option<Lifeline> inputLifeline = input.getLifeline(); if (inputLifeline.some()) { result = inputLifeline.get().equals(owner); } else if (input instanceof Message) { Message message = (Message) input; ISequenceNode sourceElt = message.getSourceElement(); ISequenceNode targetElt = message.getSourceElement(); Option<Lifeline> sourceLifeline = sourceElt.getLifeline(); Option<Lifeline> targetLifeline = targetElt.getLifeline(); result = sourceLifeline.some() && sourceLifeline.get().equals(owner) || targetLifeline.some() && targetLifeline.get().equals(owner); } else if (input instanceof Operand) { result = true; } else if (input instanceof AbstractFrame) { AbstractFrame frame = (AbstractFrame) input; Collection<Lifeline> coverage = frame.computeCoveredLifelines(); result = coverage.contains(owner); } return result; }
/** Test that create message move down shift correctly all sub event ends. */ public void testCreateMessageMoveDownToShiftAllSubEventEnds() { validateOrdering(20); Point startOfCreateMessage = new Point(instanceRoleEditPartDBounds.getCenter().x, firstInteractionUseBounds.y - 10); Point finishOfCreateMessage = instanceRoleEditPartEBounds.getCenter(); createMessage( InteractionsConstants.CREATE_TOOL_ID, startOfCreateMessage.x, startOfCreateMessage.y, finishOfCreateMessage.x, finishOfCreateMessage.y); validateOrdering(22); SWTBotGefConnectionEditPart createMessageBot = instanceRoleEditPartEBot.parent().targetConnections().get(0); Rectangle createMessageBounds = editor.getBounds(createMessageBot); int dy = 8; int NB_MOVE_DOWN = 5; createMessageBot.select(); // Avoid to drag from the label. editor.clickContextMenu("Hide label"); SequenceDiagram sequenceDiagram = getSequenceDiagram(); SequenceDDiagram sequenceDDiagram = sequenceDiagram.getSequenceDDiagram(); List<EventEnd> initalSemanticOrdering = Lists.newArrayList(sequenceDDiagram.getSemanticOrdering().getEventEnds()); Map<ISequenceEvent, Range> initalState = Maps.newHashMap(); Set<ISequenceEvent> initalEvents = sequenceDiagram.getAllOrderedDelimitedSequenceEvents(); for (ISequenceEvent ise : initalEvents) { initalState.put(ise, ise.getVerticalRange()); } for (int i = 1; i <= NB_MOVE_DOWN; i++) { createMessageBounds = editor.getBounds(createMessageBot); CheckSequenceMessageEditPartMoved checkSequenceMessageEditPartMoved = new CheckSequenceMessageEditPartMoved(createMessageBot); editor.drag( createMessageBounds.getCenter(), createMessageBounds.getCenter().translate(0, dy)); bot.waitUntil(checkSequenceMessageEditPartMoved); assertEquals( "The expected drag n�" + (i) + " did not occurs", createMessageBounds.getCenter().getTranslated(0, dy).y, editor.getBounds(createMessageBot).getCenter().y, 2); // Check graphical and semantic ordering are sync. validateOrdering(22); // Check no reorder occurs / initial ordering assertTrue( "No reorder should occur in this test.", Iterables.elementsEqual( initalSemanticOrdering, sequenceDDiagram.getGraphicalOrdering().getEventEnds())); Set<ISequenceEvent> events = sequenceDiagram.getAllOrderedDelimitedSequenceEvents(); assertEquals("We should have the same number of events.", initalEvents.size(), events.size()); for (ISequenceEvent ise : events) { assertEquals( "We should have the same number of events.", initalState.get(ise).shifted(i * dy), ise.getVerticalRange()); } } }