コード例 #1
0
        /// <summary>
        /// Finalize. This method is called on each copied element once all the elements and links are processed.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        public virtual void ModelFinalize(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;
                Guid elementID             = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelFinalize(elementP, groupMerger);
                }

                NodeShape shape = this.Store.ElementDirectory.FindElement(
                    groupMerger.GetIdMapping(protoElement.ElementId)) as NodeShape;

                // restore layout
                Store store = new Microsoft.VisualStudio.Modeling.Store(typeof(DiagramsDSLDomainModel));

                LayoutInfo info;
                using (Transaction t = store.TransactionManager.BeginTransaction())
                {
                    info = options.GetLayoutInfo(store);
                    t.Commit();
                }
                LayoutHelper.ApplyLayout(this, this.Diagram, info);
                store.Dispose();

                if (!shape.IsRelativeChildShape)
                {
                    shape.SetLocation(new PointD(RelativePastePoint.X + options.RelativeLocation.X,
                                                 RelativePastePoint.Y + options.RelativeLocation.Y));
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Adds a proto element to the current element.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        /// <param name="isRoot">Root element?</param>
        public virtual void ModelMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger, bool isRoot)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;

                Guid elementID             = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelMerge(elementP, groupMerger, isRoot);
                }

                ModelElement copiedElement = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(options.ElementId));

                // create shape for that element
                this.FixUpMissingShapes();

                NodeShape shape = DiagramHelper.FindShape(this.Store, options.ShapeDomainClassId, copiedElement.Id) as NodeShape;
                if (shape != null)
                {
                    groupMerger.SetIdMapping(protoElement.ElementId, shape.Id);
                }
            }
        }
コード例 #3
0
        private void FinalizeEmbeddingRelationshipsMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger, bool bCreateSInfo)
        {
            EmbeddingRelationship embRel = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as EmbeddingRelationship;

            if (bCreateSInfo)
            {
                SerializationDomainRelationshipAddRule.OnEmbeddingRelationshipAdded(embRel);
            }
            if (embRel == null)
            {
                return;
            }

            ModelTreeHelper.AddNewEmbeddingRS(embRel, embRel.Source.RolePlayer as DomainClass, embRel.Target.RolePlayer, false);
        }
コード例 #4
0
        private void FinalizeReferenceRelationshipMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger, bool bCreateSInfo)
        {
            ReferenceRelationship refRel = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as ReferenceRelationship;

            if (bCreateSInfo)
            {
                SerializationDomainRelationshipAddRule.OnReferenceRelationshipAdded(refRel);
            }
            if (refRel == null)
            {
                return;
            }

            ModelTreeHelper.AddNewReferenceRelationship(refRel, refRel.Source.RolePlayer as DomainClass, refRel.Target.RolePlayer);
        }
コード例 #5
0
        /// <summary>
        /// Finalize. This method is called on each copied element once all the elements and links are processed.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and 
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        public virtual void ModelFinalize(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;
                Guid elementID = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelFinalize(elementP, groupMerger);
                }

                NodeShape shape = this.Store.ElementDirectory.FindElement(
                    groupMerger.GetIdMapping(protoElement.ElementId)) as NodeShape;

                // restore layout
                Store store = new Microsoft.VisualStudio.Modeling.Store(typeof(DiagramsDSLDomainModel));
                
                LayoutInfo info;
                using (Transaction t = store.TransactionManager.BeginTransaction())
                {
                    info = options.GetLayoutInfo(store);
                    t.Commit();
                }
                LayoutHelper.ApplyLayout(this, this.Diagram, info);
                store.Dispose();

                if (!shape.IsRelativeChildShape)
                {
                    shape.SetLocation(new PointD(RelativePastePoint.X + options.RelativeLocation.X,
                            RelativePastePoint.Y + options.RelativeLocation.Y));
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Adds a proto element to the current element.
        /// </summary>
        /// <param name="protoElement">Proto element representation of the element that is to be added.</param>
        /// <param name="groupMerger">
        /// Group merger class used to track id mapping, merge errors/warnings and 
        /// postprocess merging by rebuilding reference relationships.
        /// </param>
        /// <param name="isRoot">Root element?</param>
        public virtual void ModelMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger, bool isRoot)
        {
            if (protoElement.CustomArguments is DiagramModelMergeOptions)
            {
                DiagramModelMergeOptions options = protoElement.CustomArguments as DiagramModelMergeOptions;
                
                Guid elementID = options.ElementId;
                ModelProtoElement elementP = groupMerger.GetElementById(elementID);
                if (elementP != null)
                {
                    (this.Element as IModelMergeElements).ModelMerge(elementP, groupMerger, isRoot);
                }

                ModelElement copiedElement = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(options.ElementId));
                
                // create shape for that element
                this.FixUpMissingShapes();

                NodeShape shape = DiagramHelper.FindShape(this.Store, options.ShapeDomainClassId, copiedElement.Id) as NodeShape;
                if (shape != null)
                {
                    groupMerger.SetIdMapping(protoElement.ElementId, shape.Id);
                }
            }
        }
コード例 #7
0
        private void FinalizeDomainClassMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger)
        {
            DomainClass domainClass = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as DomainClass;

            if (domainClass == null)
            {
                return;
            }

            if (protoElement.CustomArguments != null)
            {
                if (protoElement.CustomArguments is DomainClassSerializationInfo)
                {
                    DomainClassSerializationInfo info = (DomainClassSerializationInfo)protoElement.CustomArguments;
                    if (info != null)
                    {
                        for (int i = 0; i < info.AttributesOrder.Count; i++)
                        {
                            #region Attributes
                            ElementSerializationInfo eInfo = info.AttributesOrder[i] as ElementSerializationInfo;
                            Guid newId = Guid.Empty;
                            if (eInfo.ElementName != "SerializedIdProperty")
                            {
                                try
                                {
                                    newId = groupMerger.GetIdMapping(eInfo.ElementId);
                                }
                                catch
                                {
                                    newId = Guid.Empty;
                                }

                                if (newId == Guid.Empty)
                                {
                                    ModelElement m = this.Store.ElementDirectory.FindElement(eInfo.ElementId);
                                    if (m != null)
                                    {
                                        newId = m.Id;
                                    }
                                }
                            }
                            for (int y = 0; y < domainClass.SerializedDomainClass.Attributes.Count; y++)
                            {
                                if (domainClass.SerializedDomainClass.Attributes[y] is SerializedIdProperty && eInfo.ElementName == "SerializedIdProperty")
                                {
                                    (domainClass.SerializedDomainClass.Attributes[y] as SerializedIdProperty).OmitIdProperty = eInfo.OmitElement;
                                    if (y != i)
                                    {
                                        domainClass.SerializedDomainClass.Attributes.Move(y, i);
                                    }
                                    break;
                                }
                                else if (eInfo.ElementName != "SerializedIdProperty" && !(domainClass.SerializedDomainClass.Attributes[y] is SerializedIdProperty))
                                {
                                    SerializedDomainProperty p = domainClass.SerializedDomainClass.Attributes[y] as SerializedDomainProperty;
                                    p.OmitProperty = eInfo.OmitElement;
                                    if (p.DomainProperty.Id == newId && y != i)
                                    {
                                        domainClass.SerializedDomainClass.Attributes.Move(y, i);
                                        break;
                                    }
                                }
                            }
                            #endregion
                        }

                        for (int i = 0; i < info.ChildrenOrder.Count; i++)
                        {
                            #region Children
                            ElementSerializationInfo eInfo = info.ChildrenOrder[i] as ElementSerializationInfo;
                            Guid newId = Guid.Empty;

                            try
                            {
                                newId = groupMerger.GetIdMapping(eInfo.ElementId);
                            }
                            catch
                            {
                                newId = Guid.Empty;
                            }

                            if (newId == Guid.Empty)
                            {
                                ModelElement m = this.Store.ElementDirectory.FindElement(eInfo.ElementId);
                                if (m != null)
                                {
                                    newId = m.Id;
                                }
                            }

                            for (int y = i; y < domainClass.SerializedDomainClass.Children.Count; y++)
                            {
                                if (domainClass.SerializedDomainClass.Children[y] is SerializedReferenceRelationship)
                                {
                                    SerializedReferenceRelationship sDomainRel = domainClass.SerializedDomainClass.Children[y] as SerializedReferenceRelationship;
                                    if (sDomainRel.ReferenceRelationship.Id == newId)
                                    {
                                        sDomainRel.OmitRelationship = eInfo.OmitElement;

                                        if (y != i)
                                        {
                                            domainClass.SerializedDomainClass.Children.Move(y, i);
                                        }
                                        break;
                                    }
                                }
                                else if (domainClass.SerializedDomainClass.Children[y] is SerializedEmbeddingRelationship)
                                {
                                    SerializedEmbeddingRelationship sDomainRel = domainClass.SerializedDomainClass.Children[y] as SerializedEmbeddingRelationship;
                                    if (sDomainRel.EmbeddingRelationship.Id == newId)
                                    {
                                        sDomainRel.OmitRelationship = eInfo.OmitElement;

                                        if (y != i)
                                        {
                                            domainClass.SerializedDomainClass.Children.Move(y, i);
                                        }
                                        break;
                                    }
                                }
                                else if (domainClass.SerializedDomainClass.Children[y] is SerializedDomainProperty)
                                {
                                    SerializedDomainProperty p = domainClass.SerializedDomainClass.Children[y] as SerializedDomainProperty;
                                    if (p.DomainProperty.Id == newId)
                                    {
                                        p.OmitProperty = eInfo.OmitElement;

                                        if (y != i)
                                        {
                                            domainClass.SerializedDomainClass.Children.Move(y, i);
                                        }
                                        break;
                                    }
                                }
                            }
                            #endregion
                        }
                    }
                }
            }
        }