Exemple #1
0
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            PropertyGridEditor propertyGridEditor = e.ModelElement as PropertyGridEditor;

            if (propertyGridEditor != null)
            {
                if (System.String.IsNullOrEmpty(propertyGridEditor.Namespace) ||
                    System.String.IsNullOrWhiteSpace(propertyGridEditor.Namespace))
                {
                    propertyGridEditor.Namespace = propertyGridEditor.MetaModel.Namespace;
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ReferenceRSNodeReferencesShapeRelationshipNodes con = e.ModelElement as ReferenceRSNodeReferencesShapeRelationshipNodes;

            if (con != null)
            {
                if (con.ShapeRelationshipNode != null)
                {
                    con.ShapeRelationshipNode.Delete();
                }
            }
        }
Exemple #3
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DiagramClassViewReferencesDiagramClass con = e.ModelElement as DiagramClassViewReferencesDiagramClass;

            if (con != null)
            {
                if (con.DiagramClassView != null)
                {
                    con.DiagramClassView.Delete();
                }
            }
        }
        /// <summary>
        /// Constructor. This view model constructed with 'bHookUpEvents=true' does react on model changes.
        /// </summary>
        /// <param name="viewModelStore">The store this view model belongs to.</param>
        /// <param name="element">Element represented by this view model.</param>
        /// <param name="bHookUpEvents">Hook up into model events to update the created view model on changes in model if true.</param>
        public BaseModelElementViewModel(ViewModelStore viewModelStore, ModelElement element, bool bHookUpEvents)
            : base(viewModelStore)
        {
            this.element       = element;
            this.bHookUpEvents = bHookUpEvents;


            if (element != null)
            {
                if (ImmutabilityExtensionMethods.GetLocks(element) != Locks.None)
                {
                    this.IsLocked = true;
                }
            }

            if (this.bHookUpEvents)
            {
                if (element != null)
                {
                    DomainPropertyInfo info = element.GetDomainClass().NameDomainProperty;
                    if (info != null)
                    {
                        this.EventManager.GetEvent <ModelElementPropertyChangedEvent>().Subscribe(
                            info, this.Element.Id, new System.Action <ElementPropertyChangedEventArgs>(NamePropertyChanged));
                    }
                }
            }
        }
Exemple #5
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainClass domainClass = e.ModelElement as DomainClass;

            if (domainClass != null)
            {
                if (domainClass.SerializedDomainClass != null)
                {
                    domainClass.SerializedDomainClass.Delete();
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            LibraryModelContext libraryModelContext = e.ModelElement as LibraryModelContext;

            if (libraryModelContext != null)
            {
                if (libraryModelContext.ViewContext != null)
                {
                    libraryModelContext.ViewContext.Delete();
                }
            }
        }
Exemple #7
0
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            SerializedDomainModel serializedDomainModel = e.ModelElement as SerializedDomainModel;

            if (serializedDomainModel != null)
            {
                /*string idElementName = serializedDomainModel.SerializedIdAttributeName;
                 * ReadOnlyCollection<ModelElement> elements = serializedDomainModel.Store.ElementDirectory.FindElements(SerializedIdProperty.DomainClassId);
                 * foreach (ModelElement m in elements)
                 *  (m as SerializedIdProperty).SerializationName = idElementName;
                 * */
                serializedDomainModel.Model.SerializedIdAttributeName = serializedDomainModel.SerializedIdAttributeName;
            }
        }
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainRoleReferencesCustomPropertyGridEditor con = e.ModelElement as DomainRoleReferencesCustomPropertyGridEditor;

            if (con != null)
            {
                if (con.DomainRole.Relationship is EmbeddingRelationship)
                {
                    (con.DomainRole.Relationship as EmbeddingRelationship).SerializedEmbeddingRelationship.IsTargetIncludedSubmodel = true;
                }
            }
        }
Exemple #9
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainProperty domainProperty = e.ModelElement as DomainProperty;

            if (domainProperty != null)
            {
                AttributedDomainElement element = domainProperty.Element;
                domainProperty.Element = null;

                // update properties
                SerializationHelper.UpdateDerivedElementsSerializationProperties(element);
            }
        }
Exemple #10
0
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainProperty domainProperty = e.ModelElement as DomainProperty;

            if (domainProperty != null)
            {
                DomainProperty          p       = domainProperty;
                AttributedDomainElement element = p.Element;

                if (element is DomainRelationship)
                {
                    // we have to set serialized in full form, unless it is embedded somewhere in the model
                    bool bIsEmbedded = false;
                    foreach (DomainRole role in element.RolesPlayed)
                    {
                        if (role.Relationship.Target == role && role.Relationship.InheritanceModifier != InheritanceModifier.Abstract && role.Relationship is EmbeddingRelationship)
                        {
                            bIsEmbedded = true;
                            continue;
                        }
                    }

                    if (!bIsEmbedded)
                    {
                        // we have to set is serialized in full form to true
                        if (element is EmbeddingRelationship)
                        {
                            (element as EmbeddingRelationship).SerializedEmbeddingRelationship.IsInFullSerialization = true;
                        }
                        else if (element is ReferenceRelationship)
                        {
                            (element as ReferenceRelationship).SerializedReferenceRelationship.IsInFullSerialization = true;
                        }
                    }
                }

                SerializationHelper.UpdateDerivedElementsSerializationProperties(element);
            }
        }
Exemple #11
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ShapeClass shapeClass = e.ModelElement as ShapeClass;

            if (shapeClass != null)
            {
                for (int i = shapeClass.Children.Count - 1; i >= 0; i--)
                {
                    shapeClass.Children[i].Delete();
                }
            }
        }
Exemple #12
0
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ShapeClassNode node = e.ModelElement as ShapeClassNode;

            if (node != null)
            {
                if (node.ShapeClass != null)
                {
                    node.ShapeClass.DomainClass = null;
                }
            }
        }
Exemple #13
0
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainRelationship domainRelationship = e.ModelElement as DomainRelationship;

            if (domainRelationship != null)
            {
                if (e.DomainProperty.Id == DomainRelationship.NameDomainPropertyId)
                {
                    if (domainRelationship.IsNameTracking == TrackingEnum.True)
                    {
                        domainRelationship.IsNameTracking = TrackingEnum.False;
                    }
                    else if (domainRelationship.IsNameTracking == TrackingEnum.IgnoreOnce)
                    {
                        domainRelationship.IsNameTracking = TrackingEnum.True;
                    }

                    foreach (DomainRole role in domainRelationship.RolesPlayed)
                    {
                        if (role.IsNameTracking == TrackingEnum.True)
                        {
                            if (role.Name != domainRelationship.Name)
                            {
                                role.Name           = domainRelationship.Name;
                                role.IsNameTracking = TrackingEnum.IgnoreOnce;
                            }
                        }
                    }
                }
                else if (e.DomainProperty.Id == DomainRelationship.InheritanceModifierDomainPropertyId)
                {
                    if (((InheritanceModifier)e.NewValue) == InheritanceModifier.Abstract || ((InheritanceModifier)e.OldValue) == InheritanceModifier.Abstract)
                    {
                        SerializationHelper.UpdateDerivedElementsSerializationDomainRoles(domainRelationship.Source.RolePlayer);
                    }
                }
            }
        }
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            NamedDomainElement namedDomainElement = e.ModelElement as NamedDomainElement;

            if (namedDomainElement != null)
            {
                if (namedDomainElement.IsDeleting || namedDomainElement.IsDeleted)
                {
                    return;
                }

                if (e.DomainProperty.Id == NamedDomainElement.NameDomainPropertyId)
                {
                    if (namedDomainElement.IsDisplayNameTracking == TrackingEnum.True)
                    {
                        if (namedDomainElement.Name.Trim() != namedDomainElement.DisplayName &&
                            namedDomainElement.DisplayName != StringHelper.BreakUpper(namedDomainElement.Name))
                        {
                            namedDomainElement.DisplayName           = StringHelper.BreakUpper(namedDomainElement.Name);
                            namedDomainElement.IsDisplayNameTracking = TrackingEnum.IgnoreOnce;
                        }
                    }
                }
                else if (e.DomainProperty.Id == NamedDomainElement.DisplayNameDomainPropertyId)
                {
                    if (namedDomainElement.IsDisplayNameTracking == TrackingEnum.True)
                    {
                        namedDomainElement.IsDisplayNameTracking = TrackingEnum.False;
                    }
                    else if (namedDomainElement.IsDisplayNameTracking == TrackingEnum.IgnoreOnce)
                    {
                        namedDomainElement.IsDisplayNameTracking = TrackingEnum.True;
                    }
                }
            }
        }
Exemple #15
0
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            RelationshipShapeClassReferencesReferenceRelationship con = e.ModelElement as RelationshipShapeClassReferencesReferenceRelationship;

            if (con != null)
            {
                if (con.DomainRelationship is ReferenceRelationship)
                {
                    ReferenceRelationship rel  = con.DomainRelationship as ReferenceRelationship;
                    ReferenceRSNode       node = rel.ReferenceRSNode;

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

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

                    if (rel.SerializedReferenceRelationship != null)
                    {
                        if (!rel.SerializedReferenceRelationship.IsInFullSerialization)
                        {
                            if (System.Windows.MessageBox.Show("Shape mapping has been defined for the ReferenceRelationship '" +
                                                               rel.Name + "'. The Relationship is not serialized in full form. Would you like to change the serialization of this relationship to full form (strongly adviced)?",
                                                               "Serialization",
                                                               System.Windows.MessageBoxButton.YesNo,
                                                               System.Windows.MessageBoxImage.Question) == System.Windows.MessageBoxResult.Yes)
                            {
                                rel.SerializedReferenceRelationship.IsInFullSerialization = true;
                            }
                        }
                    }
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainClass domainClass = e.ModelElement as DomainClass;

            if (domainClass != null)
            {
                for (int i = domainClass.DomainModelTreeNodes.Count - 1; i >= 0; i--)
                {
                    if (i < domainClass.DomainModelTreeNodes.Count)
                    {
                        domainClass.DomainModelTreeNodes[i].Delete();
                    }
                }
            }

            List <DomainRole> roles = new List <DomainRole>();

            foreach (DomainRole role in domainClass.RolesPlayed)
            {
                roles.Add(role);
            }

            for (int i = roles.Count - 1; i >= 0; i--)
            {
                if (roles[i] != null)
                {
                    if (roles[i].Relationship != null)
                    {
                        roles[i].Relationship.Delete();
                    }
                }
            }
        }
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            LibraryModelContext modelContext = e.ModelElement as LibraryModelContext;

            if (modelContext != null && !(modelContext is ModelContext))
            {
                ViewContext viewContext = new ViewContext(modelContext.Store);
                viewContext.DomainModelTreeView = new DomainModelTreeView(modelContext.Store);
                viewContext.DiagramView         = new DiagramView(modelContext.Store);
                modelContext.ViewContext        = viewContext;
                modelContext.MetaModel.View.ViewContexts.Add(viewContext);

                /*
                 * DesignerDiagramClass ddC = new DesignerDiagramClass(modelContext.Store);
                 * ddC.Name = NameHelper.GetUniqueName(modelContext.Store, DesignerDiagramClass.DomainClassId);
                 * //ddC.Name = "DesignerDiagram";
                 * ddC.Title = "Designer";
                 * modelContext.DiagramClasses.Add(ddC);
                 *
                 * DiagramClassView vm = new DiagramClassView(modelContext.Store);
                 * vm.IsExpanded = true;
                 * vm.DiagramClass = ddC;
                 * modelContext.ViewContext.DiagramView.DiagramClassViews.Add(vm);
                 */

                if (modelContext.SerializationModel == null)
                {
                    modelContext.SerializationModel = new SerializationModel(modelContext.Store);
                }
            }
        }
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            AttributedDomainElement attributedDomainElement = e.ModelElement as AttributedDomainElement;

            if (attributedDomainElement != null)
            {
                if (e.DomainProperty.Id == AttributedDomainElement.NameDomainPropertyId)
                {
                    if (attributedDomainElement.IsSerializationNameTracking == TrackingEnum.True)
                    {
                        if (attributedDomainElement.SerializationName != attributedDomainElement.Name)
                        {
                            attributedDomainElement.SerializationName           = attributedDomainElement.Name;
                            attributedDomainElement.IsSerializationNameTracking = TrackingEnum.IgnoreOnce;
                        }
                    }
                }
                else if (e.DomainProperty.Id == AttributedDomainElement.SerializationNameDomainPropertyId)
                {
                    if (attributedDomainElement.IsSerializationNameTracking == TrackingEnum.IgnoreOnce)
                    {
                        attributedDomainElement.IsSerializationNameTracking = TrackingEnum.True;
                    }
                    else if (attributedDomainElement.IsSerializationNameTracking == TrackingEnum.True)
                    {
                        attributedDomainElement.IsSerializationNameTracking = TrackingEnum.False;
                    }
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ShapeClassReferencesDomainClass shapeCon = e.ModelElement as ShapeClassReferencesDomainClass;

            if (shapeCon != null)
            {
                PresentationDomainClassElement shapeClass = shapeCon.ShapeClass;
                ShapeClassNode node = shapeClass.ShapeClassNode;

                if (node != null)
                {
                    // delete
                    DomainClass domainClass = shapeCon.DomainClass;
                    foreach (TreeNode n in domainClass.DomainModelTreeNodes)
                    {
                        if (n.IsElementHolder)
                        {
                            if (n.ShapeClassNodes.Contains(node))
                            {
                                n.ShapeClassNodes.Remove(node);
                            }
                            break;
                        }
                    }

                    node.Delete();
                }
            }
        }
Exemple #20
0
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            SerializedDomainRole serializedDomainRole = e.ModelElement as SerializedDomainRole;

            if (serializedDomainRole != null)
            {
                if (e.DomainProperty.Id == SerializedDomainRole.SerializationNameDomainPropertyId && serializedDomainRole.DomainRole.Relationship is ReferenceRelationship)
                {
                    if (serializedDomainRole.DomainRole == serializedDomainRole.DomainRole.Relationship.Source)
                    {
                        //if ((serializedDomainRole.DomainRole.Relationship as ReferenceRelationship).SerializationSourceName != serializedDomainRole.SerializationName)
                        //    (serializedDomainRole.DomainRole.Relationship as ReferenceRelationship).SerializationSourceName = serializedDomainRole.SerializationName;
                    }
                    else
                    {
                        if ((serializedDomainRole.DomainRole.Relationship as ReferenceRelationship).SerializationTargetName != serializedDomainRole.SerializationName)
                        {
                            (serializedDomainRole.DomainRole.Relationship as ReferenceRelationship).SerializationTargetName = serializedDomainRole.SerializationName;
                        }
                    }
                }
                else if (e.DomainProperty.Id == SerializedDomainRole.SerializationAttributeNameDomainPropertyId && serializedDomainRole.DomainRole.Relationship is ReferenceRelationship)
                {
                    //if ((serializedDomainRole.DomainRole.Relationship as ReferenceRelationship).SerializationAttributeName != serializedDomainRole.SerializationAttributeName)
                    //    (serializedDomainRole.DomainRole.Relationship as ReferenceRelationship).SerializationAttributeName = serializedDomainRole.SerializationAttributeName;
                }
            }
        }
        public override void ElementDeleting(ElementDeletingEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            RelationshipShapeClassReferencesReferenceRelationship con = e.ModelElement as RelationshipShapeClassReferencesReferenceRelationship;

            if (con != null)
            {
                if (con.DomainRelationship is ReferenceRelationship)
                {
                    RelationshipShapeClass shape = con.RelationshipShapeClass;
                    ShapeRelationshipNode  node  = shape.ShapeRelationshipNode;
                    if (node != null)
                    {
                        // delete
                        ReferenceRelationship rel = con.DomainRelationship as ReferenceRelationship;
                        ReferenceRSNode       n   = rel.ReferenceRSNode;
                        if (n != null)
                        {
                            if (n.ShapeRelationshipNodes.Contains(node))
                            {
                                n.ShapeRelationshipNodes.Remove(node);
                            }
                        }
                        node.Delete();
                    }
                }
            }
        }
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            SerializedDomainClass serializedDomainClass = e.ModelElement as SerializedDomainClass;

            if (serializedDomainClass != null)
            {
                if (e.DomainProperty.Id == SerializedDomainClass.SerializationNameDomainPropertyId)
                {
                    if (serializedDomainClass.IsSerializationNameTracking == TrackingEnum.True)
                    {
                        serializedDomainClass.IsSerializationNameTracking = TrackingEnum.False;
                    }
                    else if (serializedDomainClass.IsSerializationNameTracking == TrackingEnum.IgnoreOnce)
                    {
                        serializedDomainClass.IsSerializationNameTracking = TrackingEnum.True;
                    }

                    if (serializedDomainClass.DomainClass.SerializationName != serializedDomainClass.SerializationName)
                    {
                        serializedDomainClass.DomainClass.SerializationName           = serializedDomainClass.SerializationName;
                        serializedDomainClass.DomainClass.IsSerializationNameTracking = serializedDomainClass.IsSerializationNameTracking;
                    }
                }
            }
        }
Exemple #23
0
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainProperty domainProperty = e.ModelElement as DomainProperty;

            if (domainProperty != null)
            {
                if (domainProperty.Type == null)
                {
                    foreach (DomainType type in domainProperty.Element.ParentModelContext.MetaModel.DomainTypes)
                    {
                        if (type.Name == "String")
                        {
                            domainProperty.Type = type;
                            break;
                        }
                    }
                }

                if (domainProperty.SerializationName == "")
                {
                    domainProperty.SerializationName           = domainProperty.Name;
                    domainProperty.IsSerializationNameTracking = TrackingEnum.IgnoreOnce;
                }
            }
        }
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            EmbeddingRelationship embeddingRelationship = e.ModelElement as EmbeddingRelationship;

            if (embeddingRelationship != null)
            {
                if (e.DomainProperty.Id == EmbeddingRelationship.SerializationNameDomainPropertyId)
                {
                    SerializedEmbeddingRelationship c = embeddingRelationship.SerializedEmbeddingRelationship;
                    if (c.SerializationName != embeddingRelationship.SerializationName)
                    {
                        c.SerializationName = embeddingRelationship.SerializationName;
                        if (embeddingRelationship.IsSerializationNameTracking != TrackingEnum.False)
                        {
                            c.IsSerializationNameTracking = TrackingEnum.IgnoreOnce;
                        }
                        else
                        {
                            c.IsSerializationNameTracking = TrackingEnum.False;
                        }
                    }
                }
            }
        }
Exemple #25
0
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            ShapeClassReferencesDomainClass shapeCon = e.ModelElement as ShapeClassReferencesDomainClass;

            if (shapeCon != null)
            {
                DomainClass domainClass = shapeCon.DomainClass;
                PresentationDomainClassElement shapeClass = shapeCon.ShapeClass;

                foreach (TreeNode node in domainClass.DomainModelTreeNodes)
                {
                    if (node.IsElementHolder)
                    {
                        ShapeClassNode shapeNode = new ShapeClassNode(shapeCon.Store);
                        shapeNode.ShapeClass = shapeClass;

                        node.ShapeClassNodes.Add(shapeNode);
                        domainClass.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(shapeNode);
                        break;
                    }
                }
            }
        }
Exemple #26
0
        public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            SerializedReferenceRelationship serializedReferenceRelationship = e.ModelElement as SerializedReferenceRelationship;

            if (serializedReferenceRelationship != null)
            {
                if (serializedReferenceRelationship.IsSerializationNameTracking == TrackingEnum.True)
                {
                    serializedReferenceRelationship.IsSerializationNameTracking = TrackingEnum.False;
                }
                else if (serializedReferenceRelationship.IsSerializationNameTracking == TrackingEnum.IgnoreOnce)
                {
                    serializedReferenceRelationship.IsSerializationNameTracking = TrackingEnum.True;
                }

                if (serializedReferenceRelationship.ReferenceRelationship.SerializationName != serializedReferenceRelationship.SerializationName)
                {
                    serializedReferenceRelationship.ReferenceRelationship.SerializationName           = serializedReferenceRelationship.SerializationName;
                    serializedReferenceRelationship.ReferenceRelationship.IsSerializationNameTracking = serializedReferenceRelationship.IsSerializationNameTracking;
                }
            }
        }
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            GeneratedDomainElement generatedDomainElement = e.ModelElement as GeneratedDomainElement;

            if (generatedDomainElement != null)
            {
                System.Collections.ObjectModel.ReadOnlyCollection <ModelElement> elements = generatedDomainElement.Store.ElementDirectory.FindElements(DomainClass.DomainClassId);
                foreach (ModelElement m in elements)
                {
                    if (m is DomainClass)
                    {
                        if ((m as DomainClass).IsDomainModel)
                        {
                            generatedDomainElement.Namespace = (m as DomainClass).Namespace;

                            return;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Adds a new inheritance relationship instance. Needs to be called within a modeling transaction.
        /// </summary>
        /// <param name="source">Derived class</param>
        /// <param name="target">Base class</param>
        public static void AddNewInheritanceRelationship(DomainClassReferencesBaseClass con, DomainClass source, DomainClass target, bool bTargetElementHolder)
        {
            if (ImmutabilityExtensionMethods.GetLocks(target) != Locks.None)
            {
                return;
            }

            // tree nodes
            // 1. find the element holder node for source
            // 2. add new InheritanceNode
            TreeNode elementHolderNode = null;

            foreach (TreeNode node in target.DomainModelTreeNodes)
            {
                if (node.IsElementHolder)
                {
                    elementHolderNode = node;
                    break;
                }
            }

            if (elementHolderNode == null)
            {
                throw new ArgumentNullException("elementHolderNode");
            }

            InheritanceNode inhNode = new InheritanceNode(source.Store);

            inhNode.DomainElement   = source;
            inhNode.IsElementHolder = bTargetElementHolder;
            if (!inhNode.IsElementHolder)
            {
                inhNode.IsExpanded = false;
            }
            inhNode.InhRelationshipId = con.Id;
            con.InhNodeId             = inhNode.Id;

            source.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(inhNode);

            elementHolderNode.InheritanceNodes.Add(inhNode);
        }
Exemple #29
0
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            EnumerationLiteral enumerationLiteral = e.ModelElement as EnumerationLiteral;

            if (enumerationLiteral != null)
            {
                if (enumerationLiteral.DisplayName == "")
                {
                    enumerationLiteral.DisplayName           = StringHelper.BreakUpper(enumerationLiteral.Name);
                    enumerationLiteral.IsDisplayNameTracking = TrackingEnum.IgnoreOnce;
                }

                if (enumerationLiteral.SerializationName == "")
                {
                    enumerationLiteral.SerializationName           = enumerationLiteral.Name;
                    enumerationLiteral.IsSerializationNameTracking = TrackingEnum.IgnoreOnce;
                }
            }
        }
        public override void ElementAdded(ElementAddedEventArgs e)
        {
            if (e.ModelElement != null)
            {
                if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null)
                {
                    if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing)
                    {
                        return;
                    }
                }
            }

            if (e.ModelElement == null)
            {
                return;
            }

            if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None)
            {
                return;
            }

            DomainClass domainClass = e.ModelElement as DomainClass;

            if (domainClass != null)
            {
                if (domainClass.DomainModelTreeNodes.Count == 0)
                {
                    RootNode node = new RootNode(domainClass.Store);
                    node.DomainElement   = domainClass;
                    node.IsElementHolder = true;

                    // add to the domain model diagram tree
                    domainClass.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(node);
                    domainClass.ModelContext.ViewContext.DomainModelTreeView.RootNodes.Add(node);
                }
            }
        }