public void Init() { message=new Message(dummyPoint,"",null); sourceMessageEnd=new MessageEnd(dummyPoint,"",null); destinationMessageEnd=new MessageEnd(dummyPoint,"",null); message.SourceMessageEnd=sourceMessageEnd; message.DestinationMessageEnd=destinationMessageEnd; sourceMessageEnd.CorrespondingMessage=message; destinationMessageEnd.CorrespondingMessage=message; }
public void Init() { lifeline=new Lifeline(dummyPosition,"",null); coveredMessageEnd=new MessageEnd(coveredMessageEndPosition,"1",null); uncoveredMessageEnd=new MessageEnd(unCoveredMessageEndPosition,"2",null); coveringExecutionSpecification=new ExecutionSpecification(coveringExecutionSpecificationPosition,"",null); coveringExecutionSpecification.Dimension=coveringExecutionSpecificationSize; coveringExecutionSpecification.MessageSourceEnds.Add(coveredMessageEnd); notCoveringExecutionSpecification=new ExecutionSpecification(coveringExecutionSpecificationPosition,"",null); notCoveringExecutionSpecification.Dimension=notCoveringExecutionSpecificationSize; lifeline.MessageEnds.Add(coveredMessageEnd); lifeline.MessageEnds.Add(uncoveredMessageEnd); lifeline.ExecutionSpecifications.Add(coveringExecutionSpecification); lifeline.ExecutionSpecifications.Add(notCoveringExecutionSpecification); coveredMessageEnd.CoveredLifeline=lifeline; uncoveredMessageEnd.CoveredLifeline=lifeline; }
public bool IsLastCoveringMessageEnd(MessageEnd relevantMessageEnd) { bool isLastCoveringMessageEnd=false; MessageEnd actualLastMessageEnd; int messageSourceEndsCount=messageSourceEnds.Count; messageSourceEnds= sorter.SortListForVerticalPosition(messageSourceEnds); if(messageSourceEndsCount>0) { actualLastMessageEnd=(MessageEnd)messageSourceEnds[messageSourceEndsCount-1]; if(actualLastMessageEnd == relevantMessageEnd) { isLastCoveringMessageEnd=true; } } return isLastCoveringMessageEnd; }
public MessageEnd GetOppositeMessageEnd(MessageEnd relevantMessageEnd) { MessageEnd oppositeMessageEnd=null; MessageEnd currentMessageEnd=this.DestinationMessageEnd; if(currentMessageEnd!=relevantMessageEnd) { oppositeMessageEnd=currentMessageEnd; } else { oppositeMessageEnd=this.SourceMessageEnd; } return oppositeMessageEnd; }
public bool IsMessageEndCovered(MessageEnd relevantMessageEnd) { bool executionCoversMessageEnd=false; int executionX=this.Position.X; int executionY=this.Position.Y; int executionW=this.Dimension.Width; int executionH=this.Dimension.Height; int relevantMessageEndX=relevantMessageEnd.Position.X; int relevantMessageEndY=relevantMessageEnd.Position.Y; int relevantMessageEndW=relevantMessageEnd.Dimension.Width; int relevantMessageEndH=relevantMessageEnd.Dimension.Height; //The position of a MessageEnd is given in the context to the bounds of the //corresponding Lifeline, hence the Lifeline-position was added to the MessageEnd-position. //Although there fails the value of 5, to appoint that a MessageEnd is covered by an corresponding //Execution. So there is the Value 6 subducted by the x.coordinate of the Execution //The with of an Execution is only 1, so there is a need to the Value 6 to the width of the Execution-Dimension. Rectangle relevantExecutionBounds=new Rectangle(this.Position.X-6, this.Position.Y, this.Dimension.Width+12, this.Dimension.Height+1); executionCoversMessageEnd=relevantExecutionBounds.Contains(relevantMessageEnd.Position); return executionCoversMessageEnd; }
protected internal void InterpretMessageOccurrenceSpec(MessageEnd sourceMessageOccurrenceSpec) { Message connectedMessage; MessageEnd destinationMessageOccurrenceSpec; ExecutionSpecification coveredExecutionSpec; Lifeline sourceLifeline; string sourceProcessId; Lifeline destinationLifeline; string destinationProcessId; bool isLastMessageEndOfLifeline=false; connectedMessage=sourceMessageOccurrenceSpec.CorrespondingMessage; destinationMessageOccurrenceSpec=connectedMessage.DestinationMessageEnd; sourceLifeline=sourceMessageOccurrenceSpec.CoveredLifeline; sourceProcessId=this.GetProcessEntryIdForLifelineId(sourceLifeline.XmiId); destinationLifeline=destinationMessageOccurrenceSpec.CoveredLifeline; destinationProcessId=this.GetProcessEntryIdForLifelineId(destinationLifeline.XmiId); string messageName=connectedMessage.Name; coveredExecutionSpec=sourceMessageOccurrenceSpec.CoveredExecutionSpecification; if(coveredExecutionSpec!=null) { isLastMessageEndOfLifeline=coveredExecutionSpec.IsLastCoveringMessageEnd(sourceMessageOccurrenceSpec); } if((isLastMessageEndOfLifeline==true)&&(connectedMessage.MessageSort== MessageSort.reply)) { this.CreateMessageEditorEntry(connectedMessage,sourceProcessId,destinationProcessId,false); } else { this.CreateMessageEditorEntry(connectedMessage,sourceProcessId,destinationProcessId,true); } }
public void Init() { elementListSorter=new SequenceChartElementListSorter(); relevantLifeline=new Lifeline(dummyPosition,"",null); firstExecutionSpecification= new ExecutionSpecification(firstExecutionSpecificationPosition,"",null); firstExecutionSpecification.Dimension=firstExecutionSpecificationDimension; secondExecutionSpecification= new ExecutionSpecification(secondExecutionSpecificationPosition,"",null); secondExecutionSpecification.Dimension=secondExecutionSpecificationDimension; firstSourceEnd=new MessageEnd(firstSourceEndPosition,"",null); firstSourceEnd.MessageEndKind=MessageEndKind.sourceEnd; secondSourceEnd=new MessageEnd(secondSourceEndPosition,"",null); secondSourceEnd.MessageEndKind=MessageEndKind.sourceEnd; thirdSourceEnd=new MessageEnd(thirdSourceEndPosition,"",null); thirdSourceEnd.MessageEndKind=MessageEndKind.sourceEnd; fourthSourceEnd=new MessageEnd(fourthSourceEndPosition,"",null); fourthSourceEnd.MessageEndKind=MessageEndKind.sourceEnd; firstDestinationEnd=new MessageEnd(firstDestinationEndPosition,"",null); firstDestinationEnd.MessageEndKind=MessageEndKind.destinationEnd; secondDestinationEnd=new MessageEnd(secondDestinationEndPosition,"",null); secondDestinationEnd.MessageEndKind=MessageEndKind.destinationEnd; }
/* protected internal void CreateFormalGates(Interaction relevantInteraction,XmlElement diagramElement) { XmlElement currentFormalGateElement; XmlElement currentConnectedMessageElement; string currentConnectedMessageElementId; Point currentFormalGatePosition; MessageEndKind messageEndKind; string strMessageEndKind; string currentFormalGateId; FormalGate currentFormalGate; XmlElement interactionElement=relevantInteraction.XmlRepresentation; XmlNodeList formalGateElements=modelDocumentInterpreter.GetFormalGateElements(interactionElement); IEnumerator itrFormalGateElements=formalGateElements.GetEnumerator(); while(itrFormalGateElements.MoveNext()) { currentFormalGateElement=(XmlElement)itrFormalGateElements.Current; currentFormalGateId=currentFormalGateElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME); currentConnectedMessageElementId=currentFormalGateElement.GetAttribute(UmlModel.MESSAGE_ATTR_NAME); currentConnectedMessageElement=modelDocumentInterpreter.GetMessageElementForId(diagramElement,currentConnectedMessageElementId); strMessageEndKind =modelDocumentInterpreter.GetEventKindForFormalGateXmlElement(currentFormalGateElement,currentConnectedMessageElement); if (strMessageEndKind.Equals(MessageEndKind.destinationEnd)) { messageEndKind= MessageEndKind.destinationEnd; currentFormalGatePosition=diDocumentInterpreter.GetFormalGateGraphNodePosition(diagramElement,currentFormalGateElement,messageEndKind); } else if(strMessageEndKind.Equals(MessageEndKind.sourceEnd)) { messageEndKind= MessageEndKind.sourceEnd; currentFormalGatePosition=diDocumentInterpreter.GetFormalGateGraphNodePosition(diagramElement,currentFormalGateElement,messageEndKind); } currentFormalGate= new FormalGate(currentFormalGatePosition,currentFormalGateId ,currentFormalGateElement); currentFormalGate.MessageEndKind=messageEndKind; } }*/ protected internal void CreateMessageEndsForLifeline(Lifeline lifeline,XmlElement diagramElement,Interaction interaction) { ArrayList relevantMessageEnds; XmlElement currentMessageEndElement; MessageEnd currentMessageEnd; ExecutionSpecification currentBehaviorExecutionSpec; string currentMessageEndId; Point currentMessageEndPosition; relevantMessageEnds=new ArrayList(); XmlElement lifelineElement=lifeline.XmlRepresentation; XmlElement interactionElement=(XmlElement)lifelineElement.ParentNode; XmlNodeList messageOccurrenceSpecElements= modelDocumentInterpreter.GetMessageOccurrenceSpecElementsForLifeline(lifelineElement); IEnumerator itrMessageOccurrenceSpecElements=messageOccurrenceSpecElements.GetEnumerator(); while(itrMessageOccurrenceSpecElements.MoveNext()) { currentMessageEndElement=(XmlElement)itrMessageOccurrenceSpecElements.Current; currentMessageEndId=currentMessageEndElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME); currentMessageEndPosition= diDocumentInterpreter.GetMessageOccurrenceSpecGraphNodePosition(diagramElement,currentMessageEndElement); currentMessageEnd=new MessageEnd(currentMessageEndPosition,currentMessageEndId,currentMessageEndElement); currentMessageEnd.CoveredLifeline=lifeline; currentBehaviorExecutionSpec=currentMessageEnd.GetExecutionForMessageEnd(); if(currentBehaviorExecutionSpec!=null) { currentBehaviorExecutionSpec.MessageSourceEnds.Add(currentMessageEnd); } relevantMessageEnds.Add(currentMessageEnd); } relevantMessageEnds=SortListForVerticalPosition(relevantMessageEnds); lifeline.MessageEnds=relevantMessageEnds; if(relevantMessageEnds.Count >0) { interaction.MessageOccurrenceSpecs.AddRange(relevantMessageEnds); } }
protected internal void ConnectMessageEndToMessage(MessageEnd messageEnd,Message message) { XmlElement messageElement=message.XmlRepresentation; XmlElement messageEndElement=messageEnd.XmlRepresentation; string messageReceiveEventId=messageElement.GetAttribute(UmlModel.RECEIVE_EVENT_ATTR_NAME); string messageSendEventId=messageElement.GetAttribute(UmlModel.SEND_EVENT_ATTR_NAME); string messageEndElementId=messageEndElement.GetAttribute(UmlModel.XMI_ID_ATTR_COMPLETE_NAME); messageEnd.CorrespondingMessage=message; if(messageEndElementId.Equals(messageReceiveEventId)) { message.DestinationMessageEnd=messageEnd; messageEnd.MessageEndKind= MessageEndKind.destinationEnd; } else if(messageEndElementId.Equals(messageSendEventId)) { message.SourceMessageEnd=messageEnd; messageEnd.MessageEndKind= MessageEndKind.sourceEnd; } }
public void ConnectMessageEndToMessageTest() { XmlElement messageElement =MessageElementStub.CreateMessageElementStub(xmiDocument,FIRST_MESSAGE_ELEMENT_ID); messageElement.SetAttribute(UmlModelElements.SEND_EVENT_ATTR_NAME,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); messageElement.SetAttribute(UmlModelElements.RECEIVE_EVENT_ATTR_NAME,FOURTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); Message message =new Message(ZERO_POSITION,FIRST_MESSAGE_ELEMENT_ID,messageElement); XmlElement sourceMessageEndElement= MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); sourceMessageEndElement.SetAttribute(UmlModelElements.MESSAGE,FIRST_MESSAGE_ELEMENT_ID); MessageEnd sourceMessageEnd=new MessageEnd(ZERO_POSITION,FIRST_MESSAGE_ELEMENT_ID,sourceMessageEndElement); XmlElement destinationMessageEndElement= MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,FOURTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); destinationMessageEndElement.SetAttribute(UmlModelElements.MESSAGE,FIRST_MESSAGE_ELEMENT_ID); MessageEnd destinationMessageEnd=new MessageEnd(ZERO_POSITION,FOURTH_MESSAGE_ELEMENT_ID,destinationMessageEndElement); sequenceChartModelCreator.ConnectMessageEndToMessage(sourceMessageEnd,message); MessageEnd actualSoureMessageEnd=message.SourceMessageEnd; Assert.IsNotNull(actualSoureMessageEnd); Assert.AreEqual(sourceMessageEnd,actualSoureMessageEnd); MessageEnd actualDestinationMessageEnd=message.DestinationMessageEnd; Assert.IsNull(actualDestinationMessageEnd); message.SourceMessageEnd=null; sequenceChartModelCreator.ConnectMessageEndToMessage(destinationMessageEnd,message); actualDestinationMessageEnd=message.DestinationMessageEnd; Assert.IsNotNull(actualDestinationMessageEnd); Assert.AreEqual(destinationMessageEnd,actualDestinationMessageEnd); MessageEnd actualSourceElement=message.SourceMessageEnd; Assert.IsNull(actualSourceElement); }
public void ConnectMessageEndToMessagesTest() { XmlElement firstMessageElement =MessageElementStub.CreateMessageElementStub(xmiDocument,FIRST_MESSAGE_ELEMENT_ID); firstMessageElement.SetAttribute(UmlModelElements.SEND_EVENT_ATTR_NAME,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); firstMessageElement.SetAttribute(UmlModelElements.RECEIVE_EVENT_ATTR_NAME,FOURTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); Message firstMessage =new Message(ZERO_POSITION,FIRST_MESSAGE_ELEMENT_ID,firstMessageElement); XmlElement firstSourceMessageEndElement= MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,FIRST_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); firstSourceMessageEndElement.SetAttribute(UmlModelElements.MESSAGE_ATTR_NAME,FIRST_MESSAGE_ELEMENT_ID); MessageEnd firstSourceMessageEnd=new MessageEnd(ZERO_POSITION,FIRST_MESSAGE_ELEMENT_ID,firstSourceMessageEndElement); XmlElement firstDestinationMessageEndElement= MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,FOURTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); firstDestinationMessageEndElement.SetAttribute(UmlModelElements.MESSAGE_ATTR_NAME,FIRST_MESSAGE_ELEMENT_ID); MessageEnd firstDestinationMessageEnd=new MessageEnd(ZERO_POSITION,FOURTH_MESSAGE_ELEMENT_ID,firstDestinationMessageEndElement); XmlElement secondMessageElement =MessageElementStub.CreateMessageElementStub(xmiDocument,SECOND_MESSAGE_ELEMENT_ID); secondMessageElement.SetAttribute(UmlModelElements.SEND_EVENT_ATTR_NAME,SECOND_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); secondMessageElement.SetAttribute(UmlModelElements.RECEIVE_EVENT_ATTR_NAME,FIFTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); Message secondMessage =new Message(ZERO_POSITION,SECOND_MESSAGE_ELEMENT_ID,secondMessageElement); XmlElement secondSourceMessageEndElement= MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,SECOND_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); secondSourceMessageEndElement.SetAttribute(UmlModelElements.MESSAGE_ATTR_NAME,SECOND_MESSAGE_ELEMENT_ID); MessageEnd secondSourceMessageEnd=new MessageEnd(ZERO_POSITION,SECOND_MESSAGE_ELEMENT_ID,secondSourceMessageEndElement); XmlElement secondDestinationMessageEndElement= MessageOccurrenceSpecElementStub.CreateMessageOccurrenceSpecElementStub(xmiDocument,FIFTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID); secondDestinationMessageEndElement.SetAttribute(UmlModelElements.MESSAGE_ATTR_NAME,SECOND_MESSAGE_ELEMENT_ID); MessageEnd secondDestinationMessageEnd=new MessageEnd(ZERO_POSITION,FIFTH_MESSAGE_OCCURRENCE_SPEC_ELEMENT_ID,secondDestinationMessageEndElement); Lifeline firstLifeline=new Lifeline(ZERO_POSITION,"",null); firstLifeline.MessageEnds.Add(firstSourceMessageEnd); firstLifeline.MessageEnds.Add(secondSourceMessageEnd); Lifeline secondLifeline=new Lifeline(ZERO_POSITION,"",null); secondLifeline.MessageEnds.Add(firstDestinationMessageEnd); secondLifeline.MessageEnds.Add(secondDestinationMessageEnd); interactionElement.AppendChild(firstMessageElement); interactionElement.AppendChild(secondMessageElement); interactionElement.AppendChild(firstSourceMessageEndElement); interactionElement.AppendChild(firstDestinationMessageEndElement); interactionElement.AppendChild(secondSourceMessageEndElement); interactionElement.AppendChild(secondDestinationMessageEndElement); Interaction interaction=new Interaction(ZERO_POSITION,"",null); interaction.Messages.Add(firstMessage); interaction.Messages.Add(secondMessage); ArrayList relevantMessageEnds=new ArrayList(); relevantMessageEnds.Add(firstSourceMessageEnd); relevantMessageEnds.Add(firstDestinationMessageEnd); relevantMessageEnds.Add(secondSourceMessageEnd); relevantMessageEnds.Add(secondDestinationMessageEnd); ArrayList relevantLifelines=new ArrayList(); relevantLifelines.Add(firstLifeline); relevantLifelines.Add(secondLifeline); sequenceChartModelCreator.ConnectMessageEndsToMessage(relevantLifelines,interaction); MessageEnd firstActualSoureMessageEnd=firstMessage.SourceMessageEnd; Assert.IsNotNull(firstActualSoureMessageEnd); Assert.AreEqual(firstSourceMessageEnd,firstActualSoureMessageEnd); MessageEnd firstActualDestinationMessageEnd=firstMessage.DestinationMessageEnd; Assert.IsNotNull(firstActualDestinationMessageEnd); Assert.AreEqual(firstActualDestinationMessageEnd,firstActualDestinationMessageEnd); MessageEnd secondActualSoureMessageEnd=secondMessage.SourceMessageEnd; Assert.IsNotNull(secondActualSoureMessageEnd); Assert.AreEqual(secondSourceMessageEnd,secondActualSoureMessageEnd); MessageEnd secondActualDestinationMessageEnd=secondMessage.DestinationMessageEnd; Assert.IsNotNull(secondActualDestinationMessageEnd); Assert.AreEqual(secondActualDestinationMessageEnd,secondActualDestinationMessageEnd); }
public void Init() { firstCoveredMessageEndSource=new MessageEnd(firstCoveredMessageEndSourcePosition,"",null); firstCoveredMessageEndSource.MessageEndKind=MessageEndKind.sourceEnd; secondCoveredMessageEndSource=new MessageEnd(secondCoveredMessageEndSourcePosition,"",null); secondCoveredMessageEndSource.MessageEndKind=MessageEndKind.sourceEnd; thirdCoveredMessageEndSource=new MessageEnd(thirdCoveredMessageEndSourcePosition,"",null); thirdCoveredMessageEndSource.MessageEndKind=MessageEndKind.sourceEnd; fourthCoveredMessageEndSource=new MessageEnd(fourthCoveredMessageEndSourcePosition,"",null); fourthCoveredMessageEndSource.MessageEndKind=MessageEndKind.sourceEnd; fifthCoveredMessageEndDestination=new MessageEnd(fifthCoveredMessageEndDestinationPosition,"",null); fifthCoveredMessageEndDestination.MessageEndKind=MessageEndKind.destinationEnd; uncoveredMessageEndDestination=new MessageEnd(uncoveredMessageEndDestinationPosition,"",null); uncoveredMessageEndDestination.MessageEndKind=MessageEndKind.destinationEnd; executionSpecificationCoveringOneEnd=new ExecutionSpecification (executionSpecificationCoveringOneEndPosition,"",null); executionSpecificationCoveringOneEnd.Dimension=executionSpecificationCoveringOneEndSize; executionSpecificationCoveringOneEnd.MessageSourceEnds.Add(firstCoveredMessageEndSource); executionSpecificationCoveringFourEnds=new ExecutionSpecification (executionSpecificationCoveringFourEndsPosition,"",null); executionSpecificationCoveringFourEnds.Dimension=executionSpecificationCoveringFourEndsSize; executionSpecificationCoveringFourEnds.MessageSourceEnds.Add(secondCoveredMessageEndSource); executionSpecificationCoveringFourEnds.MessageSourceEnds.Add(thirdCoveredMessageEndSource); executionSpecificationCoveringFourEnds.MessageSourceEnds.Add(fourthCoveredMessageEndSource); executionSpecificationCoveringFourEnds.MessageSourceEnds.Add(fifthCoveredMessageEndDestination); executionSpecificationCoveringNoEnd=new ExecutionSpecification (executionSpecificationCoveringNoEndPosition,"",null); executionSpecificationCoveringNoEnd.Dimension=executionSpecificationCoveringNoEndSize; oppositeExecutionSpecificationReply=new ExecutionSpecification(dummyPosition,"",null); replyMessage=new Message(dummyPosition,"",null); replyMessageSourceEnd=new MessageEnd(dummyPosition,"",null); replyMessageSourceEnd.CorrespondingMessage=replyMessage; replyMessageDestinationEnd=new MessageEnd(replyMessageDestinationEndPosition,"",null); replyMessageDestinationEnd.CorrespondingMessage=replyMessage; replyMessage.SourceMessageEnd=replyMessageSourceEnd; replyMessage.DestinationMessageEnd=replyMessageDestinationEnd; }