Esempio n. 1
0
        protected override void Initialize()
        {
            base.Initialize();

            List <Guid> relationshipOrder;

            ParentChildrenMapping[this.ModelData.CurrentModelContext.ModelContextId].TryGetValue(this.ElementInfo.Id, out relationshipOrder);

            if (relationshipOrder != null)
            {
                foreach (Guid relationshipDCId in relationshipOrder)
                {
                    DomainRelationshipInfo relationshipInfo = this.Store.DomainDataDirectory.GetDomainRelationship(relationshipDCId);
                    if (DoHookUpEvents)
                    {
                        DomainRelationshipAdvancedInfo advancedInfo = this.Store.DomainDataAdvDirectory.GetRelationshipInfo(relationshipDCId);
                        //if (!advancedInfo.TargetRoleIsUIBrowsable || !advancedInfo.TargetRoleIsGenerated)
                        //if (!advancedInfo.SourceRoleIsUIBrowsable || !advancedInfo.SourceRoleIsGenerated)
                        if (!advancedInfo.SourceRoleIsUIBrowsable)
                        {
                            continue;
                        }

                        // Subscribe to add and delete element events
                        this.EventManager.GetEvent <ModelElementLinkAddedEvent>().Subscribe(
                            this.Store.DomainDataDirectory.GetDomainRelationship(relationshipInfo.Id), true,
                            this.Element.Id, new System.Action <ElementAddedEventArgs>(OnChildElementAdded));

                        this.EventManager.GetEvent <ModelElementLinkDeletedEvent>().Subscribe(
                            this.Store.DomainDataDirectory.GetDomainRelationship(relationshipInfo.Id), true,
                            this.Element.Id, new System.Action <ElementDeletedEventArgs>(OnChildElementDeleted));

                        // Subscribe to role player change events
                        this.EventManager.GetEvent <ModelRolePlayerChangedEvent>().Subscribe(
                            this.Store.DomainDataDirectory.GetDomainRelationship(relationshipInfo.Id), true,
                            this.Element.Id, new System.Action <RolePlayerChangedEventArgs>(OnRolePlayerChanged));

                        this.EventManager.GetEvent <ModelRolePlayerMovedEvent>().Subscribe(
                            this.Store.DomainDataDirectory.GetDomainRelationship(relationshipInfo.Id),
                            this.Element.Id, new System.Action <RolePlayerOrderChangedEventArgs>(OnRolePlayerMoved));
                    }

                    // element link order
                    this.ElementLinkOrder.Add(relationshipInfo.Id);

                    System.Collections.ObjectModel.ReadOnlyCollection <ElementLink> links = DomainRoleInfo.GetElementLinks <ElementLink>(this.Element, GetSourceDomainRole(relationshipInfo).Id);
                    foreach (ElementLink link in links)
                    {
                        BaseModelElementTreeViewModel vm = AddChildElement(link, DomainRoleInfo.GetTargetRolePlayer(link), true);
                        vm.RelationshipInfo = relationshipInfo;
                        vm.ElementInfo      = GetTargetDomainRole(relationshipInfo).RolePlayer;
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Verifies if a specified domain relationship is an embedding relationship.
        /// </summary>
        /// <param name="relationshipDomainClassId">Relationship DomainClassId.</param>
        /// <returns>True if a specified domain relationship is an embedding relationship; False otherwise.</returns>
        public bool IsEmbeddingRelationship(Guid relationshipDomainClassId)
        {
            if (this.Element == null)
            {
                return(false);
            }

            DomainRelationshipAdvancedInfo info = this.Store.DomainDataAdvDirectory.FindRelationshipInfo(relationshipDomainClassId);

            if (info is EmbeddingRelationshipAdvancedInfo)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 3
0
        protected override void CreateAddElementsContextMenu(MenuItemViewModel menuItemAdd)
        {
            base.CreateAddElementsContextMenu(menuItemAdd);

            List <Guid> omittedItems;

            ParentChildrenCMMapping[this.ModelData.CurrentModelContext.ModelContextId].TryGetValue(this.ElementInfo.Id, out omittedItems);

            IModelElementParentProvider parentProvider = (this.Element as IDomainModelOwnable).GetDomainModelServices().ElementParentProvider;
            DomainClassInfo             info           = this.Element.GetDomainClass();

            foreach (DomainRoleInfo roleInfo in info.AllDomainRolesPlayed)
            {
                if (roleInfo.IsSource)
                {
                    DomainRelationshipAdvancedInfo infoAdv = this.Store.DomainDataAdvDirectory.FindRelationshipInfo(roleInfo.DomainRelationship.Id);
                    if (infoAdv is EmbeddingRelationshipAdvancedInfo)
                    {
                        if (!infoAdv.SourceRoleIsUIReadOnly && infoAdv.SourceRoleIsUIBrowsable)
                        //if (!infoAdv.SourceRoleIsUIReadOnly && infoAdv.SourceRoleIsUIBrowsable && infoAdv.SourceRoleIsGenerated)
                        //if (!infoAdv.TargetRoleIsUIReadOnly && infoAdv.TargetRoleIsUIBrowsable && infoAdv.TargetRoleIsGenerated)
                        {
                            if (omittedItems != null)
                            {
                                if (omittedItems.Contains(roleInfo.DomainRelationship.Id))
                                {
                                    continue;
                                }
                            }

                            ProcessRoleForContextMenu(parentProvider, menuItemAdd, roleInfo);
                        }
                    }
                }
            }
        }