public override void ModelFinalize(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroupMerger groupMerger) { base.ModelFinalize(protoElement, groupMerger); RootDiagramNode node = new RootDiagramNode(this.Store); node.PresentationElementClass = this; this.DiagramClass.DiagramClassView.RootDiagramNodes.Add(node); }
/// <summary> /// Executes the paste operation. /// </summary> /// <param name="rootElement">Root element, on which to paste the current data object's data.</param> /// <param name="dataObject">Data to be pasted.</param> /// <returns>ValidationResult holding errors, warning or information messages.</returns> public static ValidationResult Merge(ModelElement rootElement, IDataObject dataObject) { if (!CanMerge(rootElement, dataObject)) { return(null); } ModelProtoGroup group = GetModelProtoGroup(dataObject); ModelProtoGroupMerger protoMerger = new ModelProtoGroupMerger(group, rootElement); return(protoMerger.MergeResult); }
public override void ModelFinalize(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroupMerger groupMerger) { base.ModelFinalize(protoElement, groupMerger); if (protoElement.Name == "ReferenceRelationship") { FinalizeReferenceRelationshipMerge(protoElement, groupMerger, true); } else if (protoElement.Name == "EmbeddingRelationship") { FinalizeEmbeddingRelationshipsMerge(protoElement, groupMerger, true); } FinalizeRelationshipMerge(protoElement, groupMerger); }
public override void ModelFinalize(CopyPaste.ModelProtoElement protoElement, CopyPaste.ModelProtoGroupMerger groupMerger) { base.ModelFinalize(protoElement, groupMerger); DomainClass domainClass = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as DomainClass; if (domainClass == null) { return; } if (domainClass.IsDomainModel) { domainClass.IsDomainModel = false; } if (domainClass.BaseClass != null) { ReadOnlyCollection <DomainClassReferencesBaseClass> col = DomainRoleInfo.GetElementLinks <DomainClassReferencesBaseClass>(domainClass, DomainClassReferencesBaseClass.DerivedClassDomainRoleId); if (col.Count != 1) { throw new ArgumentNullException("Domain class can only reference one base class"); } DomainClassReferencesBaseClass r = col[0]; r.InhNodeId = Guid.Empty; // otherwise node id of the source element would be used } 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); } SerializationDomainClassAddRule.OnDomainClassAdded(domainClass); SerializationHelper.UpdateDerivedElementsSerializationProperties(domainClass); }
private void FinalizeRelationshipMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger) { SerializationClass sClass; if (this is ReferenceRelationship) { sClass = (this as ReferenceRelationship).SerializedReferenceRelationship; } else { sClass = (this as EmbeddingRelationship).SerializedEmbeddingRelationship; } if (protoElement.CustomArguments != null) if (protoElement.CustomArguments is DomainRelationshipSerializationInfo) { DomainRelationshipSerializationInfo info = (DomainRelationshipSerializationInfo)protoElement.CustomArguments; if (this is ReferenceRelationship) { (this as ReferenceRelationship).SerializedReferenceRelationship.IsInFullSerialization = info.IsInFullSerialization; } else { (this as EmbeddingRelationship).SerializedEmbeddingRelationship.IsInFullSerialization = info.IsInFullSerialization; (this as EmbeddingRelationship).SerializedEmbeddingRelationship.IsTargetIncludedSubmodel = info.IsTargetIncludedSubmodel; } 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 < sClass.Attributes.Count; y++) { if (sClass.Attributes[y] is SerializedIdProperty && eInfo.ElementName == "SerializedIdProperty") { (sClass.Attributes[y] as SerializedIdProperty).OmitIdProperty = eInfo.OmitElement; if (y != i) sClass.Attributes.Move(y, i); break; } else if (eInfo.ElementName != "SerializedIdProperty" && !(sClass.Attributes[y] is SerializedIdProperty)) { SerializedDomainProperty p = sClass.Attributes[y] as SerializedDomainProperty; p.OmitProperty = eInfo.OmitElement; if (p.DomainProperty.Id == newId && y != i) { sClass.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 < sClass.Children.Count; y++) { if (sClass.Children[y] is SerializedDomainProperty) { SerializedDomainProperty p = sClass.Children[y] as SerializedDomainProperty; if (p.DomainProperty.Id == newId) { p.OmitProperty = eInfo.OmitElement; if (y != i) sClass.Children.Move(y, i); break; } } } #endregion } } } }
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); }