Example #1
0
        private static void FixUpDomainClassInTreeView(DomainClass domainClass)
        {
            // add embedding relationships
            foreach (DomainRole role in domainClass.RolesPlayed)
            {
                if (role.Relationship.Source == role && role.Relationship is EmbeddingRelationship)
                {
                    EmbeddingRelationship emb = role.Relationship as EmbeddingRelationship;

                    if (emb.Target.RolePlayer.DomainModelTreeNodes.Count > 0)
                    {
                        ModelTreeHelper.AddNewEmbeddingRS(emb, emb.Source.RolePlayer as DomainClass, emb.Target.RolePlayer, false);
                    }
                    else
                    {
                        ModelTreeHelper.AddNewEmbeddingRS(emb, emb.Source.RolePlayer as DomainClass, emb.Target.RolePlayer, true);
                        FixUpDomainClassInTreeView(emb.Target.RolePlayer as DomainClass);

                        emb.Target.RolePlayer.DomainModelTreeNodes[0].IsEmbeddingTreeExpanded    = true;
                        emb.Target.RolePlayer.DomainModelTreeNodes[0].IsReferenceTreeExpanded    = true;
                        emb.Target.RolePlayer.DomainModelTreeNodes[0].IsInheritanceTreeExpanded  = true;
                        emb.Target.RolePlayer.DomainModelTreeNodes[0].IsShapeMappingTreeExpanded = true;
                    }
                }
            }
        }
        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);
        }
        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);
        }
Example #4
0
        private static void FixUpDomainModelTreeView(LibraryModelContext model)
        {
            // create root nodes and embedding rs
            foreach (DomainClass domainClass in model.Classes)
            {
                if (!domainClass.HasParent())
                {
                    RootNode node = new RootNode(model.Store);
                    node.DomainElement   = domainClass;
                    node.IsElementHolder = true;
                    domainClass.ModelContext.ViewContext.DomainModelTreeView.RootNodes.Add(node);
                    domainClass.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(node);

                    node.IsEmbeddingTreeExpanded    = true;
                    node.IsReferenceTreeExpanded    = true;
                    node.IsInheritanceTreeExpanded  = true;
                    node.IsShapeMappingTreeExpanded = true;

                    FixUpDomainClassInTreeView(domainClass);
                }
            }

            // reference relationships + shapes
            foreach (DomainRelationship relationship in model.Relationships)
            {
                if (relationship is ReferenceRelationship)
                {
                    ReferenceRelationship rel = relationship as ReferenceRelationship;
                    ModelTreeHelper.AddNewReferenceRelationship(rel, rel.Source.RolePlayer as DomainClass, rel.Target.RolePlayer);

                    // shape
                    foreach (RelationshipShapeClass s in rel.RelationshipShapeClasses)
                    {
                        ReferenceRSNode node = rel.ReferenceRSNode;

                        // create new shape relationship node
                        ShapeRelationshipNode shapeNode = new ShapeRelationshipNode(rel.Store);
                        shapeNode.RelationshipShapeClass = s;

                        node.ShapeRelationshipNodes.Add(shapeNode);
                        rel.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(shapeNode);
                    }
                }
            }

            // inheritance
            foreach (DomainClass domainClass in model.Classes)
            {
                if (domainClass.BaseClass != null)
                {
                    DomainClassReferencesBaseClass refBase = DomainClassReferencesBaseClass.GetLink(domainClass, domainClass.BaseClass);
                    if (refBase != null)
                    {
                        if (domainClass.DomainModelTreeNodes.Count > 0)
                        {
                            ModelTreeHelper.AddNewInheritanceRelationship(refBase, domainClass, domainClass.BaseClass, false);
                        }
                        else
                        {
                            ModelTreeHelper.AddNewInheritanceRelationship(refBase, domainClass, domainClass.BaseClass, true);
                        }
                    }
                }
            }

            // shapes
            foreach (DomainClass domainClass in model.Classes)
            {
                foreach (PresentationDomainClassElement p in domainClass.ShapeClasses)
                {
                    foreach (TreeNode node in domainClass.DomainModelTreeNodes)
                    {
                        if (node.IsElementHolder)
                        {
                            ShapeClassNode shapeNode = new ShapeClassNode(domainClass.Store);
                            shapeNode.ShapeClass = p;

                            node.ShapeClassNodes.Add(shapeNode);
                            domainClass.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(shapeNode);
                            break;
                        }
                    }
                }
            }
        }