/// <summary> /// Deletes the element view model that is hosting the given element. /// </summary> /// <param name="node">Element.</param> public void DeleteChild(SerializationElement element) { if (!this.HasLoadedChildren) { return; } for (int i = this.childrenVMs.Count - 1; i >= 0; i--) { if (this.childrenVMs[i].SerializationElement.Id == element.Id) { this.childrenVMs[i].Dispose(); this.childrenVMs.RemoveAt(i); } } OnPropertyChanged("HasChildren"); }
/// <summary> /// Adds a new element view model for the given element. /// </summary> /// <param name="element">Element.</param> public void AddChild(SerializationElement element) { if (!HasLoadedChildren) { if (!HasDummyChild) { this.childrenVMs.Add(DummyChild); } return; } // verify that node hasnt been added yet foreach (SerializationElementViewModel viewModel in this.childrenVMs) { if (viewModel.SerializationElement.Id == element.Id) { return; } } if (element is SerializedDomainClass) { SerializedDomainClassViewModel vm = new SerializedDomainClassViewModel(this.ViewModelStore, element as SerializedDomainClass, this); this.childrenVMs.Add(vm); } else if (element is SerializedEmbeddingRelationship) { SerializedEmbeddingRelationshipViewModel vm = new SerializedEmbeddingRelationshipViewModel(this.ViewModelStore, element as SerializedEmbeddingRelationship, this); this.childrenVMs.Add(vm); } else if (element is SerializedReferenceRelationship) { SerializedReferenceRelationshipViewModel vm = new SerializedReferenceRelationshipViewModel(this.ViewModelStore, element as SerializedReferenceRelationship, this); this.childrenVMs.Add(vm); } else if (element is SerializedDomainProperty) { SerializedDomainPropertyViewModel vm = new SerializedDomainPropertyViewModel(this.ViewModelStore, element as SerializedDomainProperty, this); this.childrenVMs.Add(vm); } OnPropertyChanged("HasChildren"); }
/// <summary> /// Adds a new element view model for the given element. /// </summary> /// <param name="element">Element.</param> public void AddAttribute(SerializationElement element) { if (element == null) { return; } /* * if (!HasLoadedAttributes) * { * if (!HasDummyAttribute) * this.attributesVMs.Add(DummyAttribute); * * return; * }*/ // verify that node hasnt been added yet foreach (SerializationAttributeElementViewModel viewModel in this.attributesVMs) { if (viewModel.SerializationElement.Id == element.Id) { return; } } if (element is SerializedIdProperty) { SerializedIdPropertyViewModel vm = new SerializedIdPropertyViewModel(this.ViewModelStore, element as SerializedIdProperty, this); this.attributesVMs.Add(vm); } else if (element is SerializedDomainProperty) { SerializedDomainPropertyViewModel vm = new SerializedDomainPropertyViewModel(this.ViewModelStore, element as SerializedDomainProperty, this); this.attributesVMs.Add(vm); } OnPropertyChanged("HasAttributes"); }
public override void ModelProcessMergeCopy(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroup protoGroup) { base.ModelProcessMergeCopy(protoElement, protoGroup); // copy rs and target elements if required if (CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyEmbeddingTree || CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyAllTree || CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyReferenceTree) { foreach (DomainRole role in this.RolesPlayed) { if (role.Relationship is EmbeddingRelationship && role.Relationship.Source == role) { if (CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyEmbeddingTree || CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyAllTree) { ModelProtoElement e = (role.Relationship as IModelMergeElements).ModelCreateMergeCopy(protoGroup); protoGroup.AddNewRootElement(e); // continue with target element if (ImmutabilityExtensionMethods.GetLocks(role.Relationship.Target.RolePlayer) == Locks.None) { if (!protoGroup.HasProtoElementFor(role.Relationship.Target.RolePlayer.Id, this.Partition)) { ModelProtoElement d = (role.Relationship.Target.RolePlayer as IModelMergeElements).ModelCreateMergeCopy(protoGroup); protoGroup.InsertNewRootElement(d, 0); } } } } else if (role.Relationship is ReferenceRelationship && role.Relationship.Source == role) { if (CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyAllTree || CopyPaste.CopyAndPasteOperations.Operation == CopyPaste.CopyAndPasteOperation.CopyReferenceTree) { ModelProtoElement e = (role.Relationship as IModelMergeElements).ModelCreateMergeCopy(protoGroup); protoGroup.AddNewRootElement(e); } } } // sort proto elements: bring domain classes to the top protoGroup.SortProtoElements(SortProtoElements); } // copy order of attributes and children DomainClassSerializationInfo info = new DomainClassSerializationInfo( this.SerializedDomainClass.Children.Count, this.SerializedDomainClass.Attributes.Count); for (int i = 0; i < this.SerializedDomainClass.Attributes.Count; i++) { SerializationAttributeElement aatr = this.SerializedDomainClass.Attributes[i]; if (aatr is SerializedDomainProperty) { SerializedDomainProperty sP = aatr as SerializedDomainProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo( sP.DomainProperty.Name, sP.DomainProperty.Id); if (sP.OmitProperty) { sInfo.OmitElement = true; } info.AttributesOrder.Add(sInfo); } else if (aatr is SerializedIdProperty) { SerializedIdProperty sI = aatr as SerializedIdProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo("SerializedIdProperty", Guid.Empty); if (sI.OmitIdProperty) { sInfo.OmitElement = true; } info.AttributesOrder.Add(sInfo); } } for (int i = 0; i < this.SerializedDomainClass.Children.Count; i++) { SerializationElement sE = this.SerializedDomainClass.Children[i]; if (sE is SerializedReferenceRelationship) { SerializedReferenceRelationship sDomainRel = sE as SerializedReferenceRelationship; ElementSerializationInfo sInfo = new ElementSerializationInfo( sDomainRel.ReferenceRelationship.Name, sDomainRel.ReferenceRelationship.Id); if (sDomainRel.OmitRelationship) { sInfo.OmitElement = true; } info.ChildrenOrder.Add(sInfo); } else if (sE is SerializedEmbeddingRelationship) { SerializedEmbeddingRelationship sDomainRel = sE as SerializedEmbeddingRelationship; ElementSerializationInfo sInfo = new ElementSerializationInfo( sDomainRel.EmbeddingRelationship.Name, sDomainRel.EmbeddingRelationship.Id); if (sDomainRel.OmitRelationship) { sInfo.OmitElement = true; } info.ChildrenOrder.Add(sInfo); } else if (sE is SerializedDomainProperty) { SerializedDomainProperty sP = sE as SerializedDomainProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo( sP.DomainProperty.Name, sP.DomainProperty.Id); if (sP.OmitProperty) { sInfo.OmitElement = true; } info.ChildrenOrder.Add(sInfo); } } protoElement.CustomArguments = info; }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> /// <param name="serializationElement">SerializationElement.</param> /// <param name="referencedElement">Element that is referenced by the serialization element. Can be null.</param> protected SerializationElementViewModel(ViewModelStore viewModelStore, SerializationElement serializationElement, ModelElement referencedElement) : base(viewModelStore, referencedElement) { this.serializationElement = serializationElement; }
/// <summary> /// Adds a new element view model for the given element. /// </summary> /// <param name="element">Element.</param> public void AddAttribute(SerializationElement element) { if (element == null) return; /* if (!HasLoadedAttributes) { if (!HasDummyAttribute) this.attributesVMs.Add(DummyAttribute); return; }*/ // verify that node hasnt been added yet foreach (SerializationAttributeElementViewModel viewModel in this.attributesVMs) if (viewModel.SerializationElement.Id == element.Id) return; if (element is SerializedIdProperty) { SerializedIdPropertyViewModel vm = new SerializedIdPropertyViewModel(this.ViewModelStore, element as SerializedIdProperty, this); this.attributesVMs.Add(vm); } else if( element is SerializedDomainProperty ) { SerializedDomainPropertyViewModel vm = new SerializedDomainPropertyViewModel(this.ViewModelStore, element as SerializedDomainProperty, this); this.attributesVMs.Add(vm); } OnPropertyChanged("HasAttributes"); }
/// <summary> /// Deletes the element view model that is hosting the given element. /// </summary> /// <param name="node">Element.</param> public void DeleteChild(SerializationElement element) { if (!this.HasLoadedChildren) return; for (int i = this.childrenVMs.Count - 1; i >= 0; i--) if (this.childrenVMs[i].SerializationElement.Id == element.Id) { this.childrenVMs[i].Dispose(); this.childrenVMs.RemoveAt(i); } OnPropertyChanged("HasChildren"); }
/// <summary> /// Adds a new element view model for the given element. /// </summary> /// <param name="element">Element.</param> public void AddChild(SerializationElement element) { if (!HasLoadedChildren) { if (!HasDummyChild) this.childrenVMs.Add(DummyChild); return; } // verify that node hasnt been added yet foreach (SerializationElementViewModel viewModel in this.childrenVMs) if (viewModel.SerializationElement.Id == element.Id) return; if (element is SerializedDomainClass) { SerializedDomainClassViewModel vm = new SerializedDomainClassViewModel(this.ViewModelStore, element as SerializedDomainClass, this); this.childrenVMs.Add(vm); } else if (element is SerializedEmbeddingRelationship) { SerializedEmbeddingRelationshipViewModel vm = new SerializedEmbeddingRelationshipViewModel(this.ViewModelStore, element as SerializedEmbeddingRelationship, this); this.childrenVMs.Add(vm); } else if (element is SerializedReferenceRelationship) { SerializedReferenceRelationshipViewModel vm = new SerializedReferenceRelationshipViewModel(this.ViewModelStore, element as SerializedReferenceRelationship, this); this.childrenVMs.Add(vm); } else if (element is SerializedDomainProperty) { SerializedDomainPropertyViewModel vm = new SerializedDomainPropertyViewModel(this.ViewModelStore, element as SerializedDomainProperty, this); this.childrenVMs.Add(vm); } OnPropertyChanged("HasChildren"); }
public override void ModelProcessMergeCopy(ModelProtoElement protoElement, ModelProtoGroup protoGroup) { base.ModelProcessMergeCopy(protoElement, protoGroup); bool isInFull = false; bool isTargetInc = false; SerializationClass sClass; if (this is ReferenceRelationship) { sClass = (this as ReferenceRelationship).SerializedReferenceRelationship; isInFull = (this as ReferenceRelationship).SerializedReferenceRelationship.IsInFullSerialization; } else { sClass = (this as EmbeddingRelationship).SerializedEmbeddingRelationship; isInFull = (this as EmbeddingRelationship).SerializedEmbeddingRelationship.IsInFullSerialization; isTargetInc = (this as EmbeddingRelationship).SerializedEmbeddingRelationship.IsTargetIncludedSubmodel; } // copy order of attributes and children DomainRelationshipSerializationInfo info = new DomainRelationshipSerializationInfo( sClass.Children.Count, sClass.Attributes.Count); info.IsInFullSerialization = isInFull; info.IsTargetIncludedSubmodel = isTargetInc; for (int i = 0; i < sClass.Attributes.Count; i++) { SerializationAttributeElement aatr = sClass.Attributes[i]; if (aatr is SerializedDomainProperty) { SerializedDomainProperty sP = aatr as SerializedDomainProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo( sP.DomainProperty.Name, sP.DomainProperty.Id); if (sP.OmitProperty) { sInfo.OmitElement = true; } info.AttributesOrder.Add(sInfo); } else if (aatr is SerializedIdProperty) { SerializedIdProperty sI = aatr as SerializedIdProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo("SerializedIdProperty", Guid.Empty); if (sI.OmitIdProperty) { sInfo.OmitElement = true; } info.AttributesOrder.Add(sInfo); } } for (int i = 0; i < sClass.Children.Count; i++) { SerializationElement sE = sClass.Children[i]; if (sE is SerializedDomainProperty) { SerializedDomainProperty sP = sE as SerializedDomainProperty; ElementSerializationInfo sInfo = new ElementSerializationInfo( sP.DomainProperty.Name, sP.DomainProperty.Id); if (sP.OmitProperty) { sInfo.OmitElement = true; } info.ChildrenOrder.Add(sInfo); } } protoElement.CustomArguments = info; }