예제 #1
0
		public bool StepHasAlternatives(Step step)
		{
			Int32 index;
			Step tmpStep;

			if(step.Type == Step.StepType.AlternativeChild)
			{
				return true;
			}

			for(index = this.Steps.Count - 1; index >= 0; index--)
			{
				tmpStep = (Step)this.Steps[index];
				if(tmpStep.UniqueID == step.UniqueID)
				{
					break;
				}
			}
			// Step is not found or it is the last step in collection
			if(index >= this.Steps.Count - 1)
			{
				return false;
			}
			tmpStep = (Step)this.Steps[index + 1];
			if(step.Type == Step.StepType.Default && tmpStep.Type == Step.StepType.Alternative)
			{
				return true;
			}
			if(step.Type == Step.StepType.Alternative && tmpStep.Type == Step.StepType.AlternativeChild)
			{
				return true;
			}
			return false;
		}
예제 #2
0
		public void RemoveStep(Step step)
		{
			for(int i = this.steps.Count - 1; i >= 0; i--)
			{
				Step tmpStep = (Step)this.steps[i];
				switch(step.Type)
				{
					case Step.StepType.Default:
						if(tmpStep.ID == step.ID)
						{
							this.steps.Remove(tmpStep);
						}
						if(tmpStep.ID > step.ID)
						{
							tmpStep.ID -= 1;
						}
						break;
					case Step.StepType.Alternative:
						if(tmpStep.ID == step.ID)
						{
							if(tmpStep.Prefix == step.Prefix)
							{
								this.steps.Remove(tmpStep);
							}
							if(tmpStep.Prefix != String.Empty && tmpStep.Prefix.CompareTo(step.Prefix) > 0)
							{
								Char nextChar = tmpStep.Prefix[0];
								nextChar--;
								tmpStep.Prefix = new String(nextChar,1);
							}
						}
						break;
					case Step.StepType.AlternativeChild:
						if(tmpStep.ID == step.ID && tmpStep.Prefix == step.Prefix)
						{
							if(tmpStep.ChildID == step.ChildID)
							{
								this.steps.Remove(step);
							}
							if(tmpStep.ChildID > step.ChildID)
							{
								tmpStep.ChildID -= 1;
							}
						}
						break;
				}
			}
		}
예제 #3
0
		public Int32 AddStep(
			Step previousStep,
			Step.StepType type,
			String stereotype,
			UseCase referencedUseCase,
			DependencyItem.ReferenceType referenceType)
		{
			Step step = new Step();
			Int32 index;
			Int32 ret;

			if(referenceType != DependencyItem.ReferenceType.None)
			{
				step.Dependency.Stereotype = stereotype;
				step.Dependency.PartnerUniqueID = referencedUseCase.UniqueID;
				step.Dependency.Type = referenceType;
				step.Description = (step.Dependency.Stereotype != "") ? "<<" + step.Dependency.Stereotype + ">>" : "";
				step.Description += " \"";
				step.Description += referencedUseCase.Name;
				step.Description += "\"";
			}

			if(previousStep == null)
			{
				step.ID = 1;
				ret = this.steps.Add(step);
				return ret;
			}
			else
			{
				switch(type)
				{
					case Step.StepType.Default:
						if(previousStep.Type == Step.StepType.Default)
						{
							step.ID = previousStep.ID;
							index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
							while(true)
							{
								if(index == this.steps.Count)
								{
									previousStep = (Step)this.steps[index - 1];
									break;
								}
								Step tmpStep = (Step)this.steps[index];
								if(tmpStep.ID != step.ID)
								{
									previousStep = (Step)this.steps[index - 1];
									break;
								}
								index += 1;
							}
							step.ID = previousStep.ID + 1;
							foreach(Step tmpStep in this.steps)
							{
								if(tmpStep.ID >= step.ID)
								{
									tmpStep.ID += 1;
								}
							}
						}
						else if(previousStep.Type == Step.StepType.Alternative)
						{
							step.ID = previousStep.ID;
							step.Type = Step.StepType.Alternative;

							index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
							while(true)
							{
								if(index == this.steps.Count)
								{
									previousStep = (Step)this.steps[index - 1];
									break;
								}
								Step tmpStep = (Step)this.steps[index];
								if(tmpStep.ID != step.ID || tmpStep.Prefix == String.Empty)
								{
									previousStep = (Step)this.steps[index - 1];
									break;
								}
								index += 1;
							}
							step.Prefix = previousStep.Prefix;
							if(step.Prefix != String.Empty)
							{
								Char nextChar = step.Prefix[0];
								nextChar++;
								step.Prefix = new String(nextChar,1);
							}
							else
							{
								step.Prefix = "A";
							}
						
							foreach(Step tmpStep in this.steps)
							{
								if(tmpStep.ID == step.ID)
								{
									if(tmpStep.Prefix != String.Empty && tmpStep.Prefix.CompareTo(step.Prefix) >= 0)
									{
										Char nextChar = tmpStep.Prefix[0];
										nextChar++;
										tmpStep.Prefix = new String(nextChar,1);
									}
								}
							}
						}
						else if(previousStep.Type == Step.StepType.AlternativeChild)
						{
							step.Type = Step.StepType.AlternativeChild;
							step.ID = previousStep.ID;
							step.Prefix = previousStep.Prefix;

							index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
							while(true)
							{
								if(index == this.steps.Count)
								{
									previousStep = (Step)this.steps[index - 1];
									break;
								}
								Step tmpStep = (Step)this.steps[index];
								if(tmpStep.ID != step.ID || tmpStep.Prefix != step.Prefix)
								{
									previousStep = (Step)this.steps[index - 1];
									break;
								}
								index += 1;
							}

							step.Prefix = previousStep.Prefix;
							step.ChildID = previousStep.ChildID + 1;
						}
						break;
					case Step.StepType.Alternative:
						if(previousStep.Type == Step.StepType.Default)
						{
							step.ID = previousStep.ID;
							step.Type = Step.StepType.Alternative;

							index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
							while(true)
							{
								if(index == this.steps.Count)
								{
									previousStep = (Step)this.steps[index - 1];
									break;
								}
								Step tmpStep = (Step)this.steps[index];
								if(tmpStep.ID != step.ID || tmpStep.Prefix == String.Empty)
								{
									previousStep = (Step)this.steps[index - 1];
									break;
								}
								index += 1;
							}
							step.Prefix = previousStep.Prefix;
							if(step.Prefix != String.Empty)
							{
								Char nextChar = step.Prefix[0];
								nextChar++;
								step.Prefix = new String(nextChar,1);
							}
							else
							{
								step.Prefix = "A";
							}
						
							foreach(Step tmpStep in this.steps)
							{
								if(tmpStep.ID == step.ID)
								{
									if(tmpStep.Prefix != String.Empty && tmpStep.Prefix.CompareTo(step.Prefix) >= 0)
									{
										Char nextChar = tmpStep.Prefix[0];
										nextChar++;
										tmpStep.Prefix = new String(nextChar,1);
									}
								}
							}
						}
						else if(previousStep.Type == Step.StepType.Alternative)
						{
							step.Type = Step.StepType.AlternativeChild;
							step.ID = previousStep.ID;
							step.Prefix = previousStep.Prefix;
							step.ChildID = 1;
						}
						break;
				}
			}

			index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
			if(index == this.steps.Count)
			{
				ret = this.steps.Add(step);
			}
			else
			{
				this.steps.Insert(index, step);
				ret = index;
			}

			return ret;
		}
예제 #4
0
		public Int32 InsertStep(
			Step previousStep,
			String stereotype,
			UseCase referencedUseCase,
			DependencyItem.ReferenceType referenceType)
		{
			Step step = new Step();
			Int32 ret;

			if(referenceType != DependencyItem.ReferenceType.None)
			{
				step.Dependency.Stereotype = stereotype;
				step.Dependency.PartnerUniqueID = referencedUseCase.UniqueID;
				step.Dependency.Type = referenceType;
				step.Description = (step.Dependency.Stereotype != "") ? "<<" + step.Dependency.Stereotype + ">>" : "";
				step.Description += " \"";
				step.Description += referencedUseCase.Name;
				step.Description += "\"";
			}

			if(previousStep.Type == Step.StepType.Default)
			{
				step.ID = previousStep.ID;
				foreach(Step tmpStep in this.steps)
				{
					if(tmpStep.ID >= step.ID)
					{
						tmpStep.ID += 1;
					}
				}
			}
			else if(previousStep.Type == Step.StepType.Alternative)
			{
				step.Prefix = previousStep.Prefix;
				if(step.Prefix == String.Empty)
				{
					step.Prefix = "A";
				}
				step.ID = previousStep.ID;
				step.Type = Step.StepType.Alternative;

				foreach(Step tmpStep in this.steps)
				{
					if(tmpStep.ID == step.ID)
					{
						if(tmpStep.Prefix != String.Empty && tmpStep.Prefix.CompareTo(step.Prefix) >= 0)
						{
							Char nextChar = tmpStep.Prefix[0];
							nextChar++;
							tmpStep.Prefix = new String(nextChar,1);
						}
					}
				}
			}
			else if(previousStep.Type == Step.StepType.AlternativeChild)
			{
				step.Type = Step.StepType.AlternativeChild;
				step.ID = previousStep.ID;
				step.Prefix = previousStep.Prefix;
				step.ChildID = previousStep.ChildID;
				foreach(Step tmpStep in this.steps)
				{
					if(tmpStep.ID == step.ID && tmpStep.Prefix == step.Prefix)
					{
						if(tmpStep.ChildID >= step.ChildID)
						{
							tmpStep.ChildID += 1;
						}
					}
				}
			}

			int index = this.FindStepIndexByUniqueID(previousStep.UniqueID);
			this.steps.Insert(index,step);
			ret = index;

			return ret;
		}
예제 #5
0
        public bool StepHasAlternatives(Step step)
        {
            Int32 index;
            Step tmpStep;
            Boolean retVal = true;

            if(step.Type != Step.StepType.Default)
            {
                return false;
            }

            for(index = this.Steps.Count - 1; index >= 0; index--)
            {
                tmpStep = (Step)this.Steps[index];
                if(tmpStep.UniqueID == step.UniqueID)
                {
                    break;
                }
            }

            while(true)
            {
                // Step is not found or it is the last step in collection
                if(index >= this.Steps.Count - 1)
                {
                    retVal = false;
                    break;
                }
                tmpStep = (Step)this.Steps[index + 1];
                if(step.ID == tmpStep.ID && tmpStep.Type == Step.StepType.Alternative)
                {
                    retVal = true;
                    break;
                }
                index += 1;
            }

            return retVal;
        }