예제 #1
0
        /// <summary>
        ///     Searches the dictionary for an update to this.
        /// </summary>
        /// <param name="dictionary"></param>
        /// <returns></returns>
        public Specification FindOrCreateSpecificationUpdate(Dictionary dictionary)
        {
            Specification retVal = null;

            foreach (ModelElement update in UpdatedBy)
            {
                if (update.Dictionary == dictionary)
                {
                    Specification specUpdate = update as Specification;
                    if (specUpdate != null)
                    {
                        retVal = specUpdate;
                    }
                    break;
                }
            }

            if (retVal == null)
            {
                retVal = CreateSpecificationUpdate(dictionary);
                UpdatedBy.Add(retVal);
            }

            return(retVal);
        }
예제 #2
0
        /// <summary>
        ///     Creates an update of this chapter in the provided specification
        /// </summary>
        /// <param name="specification">The specification update</param>
        /// <returns></returns>
        public Chapter CreateChapterUpdate(Specification specification)
        {
            Chapter retVal = new Chapter();

            retVal.Id = Id;
            retVal.setUpdates(Guid);

            specification.appendChapters(retVal);
            ArrayList tmp = new ArrayList();

            foreach (Chapter chapter in EnclosingSpecification.Chapters)
            {
                if (chapter.UpdatedBy != null)
                {
                    tmp.Add(chapter.UpdatedBy);
                }
                if (chapter == this)
                {
                    tmp.Add(retVal);
                }
            }

            UpdatedBy.Add(retVal);

            return(retVal);
        }
예제 #3
0
        /// <summary>
        ///     Creates an update for this paragraph in the provided dictionary.
        /// </summary>
        /// <param name="dictionary">The dictionary to put the updated paragraph in</param>
        /// <returns>The updated paragraph</returns>
        public Paragraph CreateParagraphUpdate(Dictionary dictionary)
        {
            Paragraph retVal = (Paragraph)acceptor.getFactory().createParagraph();

            retVal.FullId = FullId;
            retVal.Text   = Text;
            retVal.setUpdates(Guid);

            Specification specUpdate = FindEnclosingSpecification().FindOrCreateSpecificationUpdate(dictionary);

            // If the enclosing is a paragraph, find or create the enclosing paragraph update
            // If it is a chapter, find or create the chapter update
            if (EnclosingParagraph != null)
            {
                string    parentId = FullId.Substring(0, FullId.LastIndexOf('.'));
                Paragraph parent   = specUpdate.FindParagraphByNumber(parentId);
                if (parent == null)
                {
                    parent = EnclosingParagraph.CreateParagraphUpdate(dictionary);
                }
                parent.appendParagraphs(retVal);
                parent.SubParagraphs.Sort();
            }
            else if (EnclosingChapter != null)
            {
                Chapter parent = EnclosingChapter.FindChapterUpdate(dictionary);
                if (parent == null)
                {
                    parent = EnclosingChapter.CreateChapterUpdate(specUpdate);
                }
                parent.appendParagraphs(retVal);
                parent.Paragraphs.Sort();
            }

            UpdatedBy.Add(retVal);

            return(retVal);
        }