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; } } } }
public static bool GenerateSpecificVMHandlerForRole(DomainClass domainClass, DomainRole role) { if (role.Relationship.InheritanceModifier == InheritanceModifier.Abstract) return false; if (role.Relationship.Source != role) { if (!domainClass.GenerateSpecificViewModelOppositeReferences) return false; if (!(role.Relationship is ReferenceRelationship)) return false; } //if( !role.IsPropertyGenerator ) // continue; if (role.Relationship is EmbeddingRelationship && !domainClass.GenerateSpecificViewModelEmbeddings) return false; if (role.Relationship is ReferenceRelationship && !domainClass.GenerateSpecificViewModelReferences) if (role.Relationship.Source == role) return false; return 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) { if (domainClass.SerializedDomainClass != null) { domainClass.SerializedDomainClass.Delete(); } } }
/// <summary> /// Adds a new derived class to each of the given domain classes. /// </summary> /// <param name="sources">DomainClasses to add a derived from.</param> public static void AddNewInheritanceRelationshipNewDerivedClass(List <DomainClass> sources) { if (sources.Count == 0) { return; } using (Transaction transaction = sources[0].Store.TransactionManager.BeginTransaction("Create new inheritance rs")) { foreach (DomainClass source in sources) { // Create new domain class to act as the derived class DomainClass target = source.Store.ElementFactory.CreateElement(DomainClass.DomainClassId) as DomainClass; Microsoft.VisualStudio.Modeling.ElementOperations elementOperations = new Microsoft.VisualStudio.Modeling.ElementOperations(source.Store as IServiceProvider, source.Store.DefaultPartition); Microsoft.VisualStudio.Modeling.ElementGroup elementGroup = new Microsoft.VisualStudio.Modeling.ElementGroup(source.Store.DefaultPartition); elementGroup.Add(target); elementGroup.MarkAsRoot(target); elementOperations.MergeElementGroup(source.ModelContext, elementGroup); target.Name = NameHelper.GetUniqueName(source.Store, DomainClass.DomainClassId); // create a new embedding relationship AddNewInheritanceRelationship(target, source, true); } transaction.Commit(); } }
/// <summary> /// Adds a new referece relationship instance. /// </summary> /// <param name="source">Domain class representing the source.</param> /// <param name="target">Domain class representing the target.</param> public static ReferenceRelationship AddNewReferenceRelationship(DomainClass source, AttributedDomainElement target) { // create rs ReferenceRelationship refRel = new ReferenceRelationship(source.Store); source.ModelContext.Relationships.Add(refRel); // create roles DomainRole sourceRole = new DomainRole(source.Store); sourceRole.PropagatesDelete = false; DomainRole targetRole = new DomainRole(source.Store); targetRole.PropagatesDelete = false; sourceRole.RolePlayer = source; targetRole.RolePlayer = target; sourceRole.Opposite = targetRole; targetRole.Opposite = sourceRole; // assign roles to rs refRel.Roles.Add(sourceRole); refRel.Roles.Add(targetRole); refRel.Source = sourceRole; refRel.Target = targetRole; // properties + names if (refRel.Source.RolePlayer.Name == refRel.Target.RolePlayer.Name) { sourceRole.Name = source.Name + "Source"; } else { sourceRole.Name = source.Name; } sourceRole.IsNameTracking = TrackingEnum.IgnoreOnce; if (refRel.Source.RolePlayer.Name == refRel.Target.RolePlayer.Name) { targetRole.Name = target.Name + "Target"; } else { targetRole.Name = target.Name; } targetRole.IsNameTracking = TrackingEnum.IgnoreOnce; refRel.SerializationSourceName = sourceRole.Name + "Ref"; refRel.IsSerializationSourceNameTracking = TrackingEnum.IgnoreOnce; refRel.SerializationTargetName = targetRole.Name + "Ref"; refRel.IsSerializationTargetNameTracking = TrackingEnum.IgnoreOnce; AddNewReferenceRelationship(refRel, source, target); return(refRel); }
internal virtual bool ShouldIncludeCandidate(DomainClass currentRoleplayer, DomainClass eachCandidate) { if (eachCandidate != currentRoleplayer) { return(!eachCandidate.IsDerivedFrom(currentRoleplayer)); } return(false); }
/// <summary> /// True if this DomainClass is derived from the given class /// </summary> public bool IsDerivedFrom(DomainClass candidateBase) { for (DomainClass domainClass = this; domainClass != null; domainClass = domainClass.BaseClass) { if (domainClass.Equals(candidateBase)) return true; } return false; }
/// <summary> /// Adds a new embedding relationship instance. Needs to be called within a modeling transaction. /// </summary> /// <param name="source">Domain class representing the parent.</param> /// <param name="target">Domain class representing the child.</param> public static EmbeddingRelationship AddNewEmbeddingRS(DomainClass source, AttributedDomainElement target, bool bTargetElementHolder) { // create rs EmbeddingRelationship emb = new EmbeddingRelationship(source.Store); source.ModelContext.Relationships.Add(emb); // create roles DomainRole sourceRole = new DomainRole(source.Store); sourceRole.PropagatesDelete = false; DomainRole targetRole = new DomainRole(source.Store); targetRole.Multiplicity = Multiplicity.One; targetRole.PropagatesDelete = true; sourceRole.RolePlayer = source; targetRole.RolePlayer = target; sourceRole.Opposite = targetRole; targetRole.Opposite = sourceRole; // assign roles to rs emb.Roles.Add(sourceRole); emb.Roles.Add(targetRole); emb.Source = sourceRole; emb.Target = targetRole; // properties + names if (emb.Source.RolePlayer.Name == emb.Target.RolePlayer.Name) { sourceRole.Name = source.Name + "Source"; } else { sourceRole.Name = source.Name; } sourceRole.IsNameTracking = TrackingEnum.IgnoreOnce; if (emb.Source.RolePlayer.Name == emb.Target.RolePlayer.Name) { targetRole.Name = target.Name + "Target"; } else { targetRole.Name = target.Name; } targetRole.IsNameTracking = TrackingEnum.IgnoreOnce; AddNewEmbeddingRS(emb, source, target, bTargetElementHolder); return(emb); }
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(); } } } }
/// <summary> /// True if this DomainClass is derived from the given class /// </summary> public bool IsDerivedFrom(DomainClass candidateBase) { for (DomainClass domainClass = this; domainClass != null; domainClass = domainClass.BaseClass) { if (domainClass.Equals(candidateBase)) { return(true); } } return(false); }
public static void OnDomainClassAdded(DomainClass domainClass) { if (domainClass.SerializedDomainClass == null) { SerializedDomainClass child = new SerializedDomainClass(domainClass.Store); child.DomainClass = domainClass; child.SerializationName = domainClass.SerializationName; domainClass.ModelContext.SerializationModel.Children.Add(child); SerializationHelper.AddSerializationDomainProperties(domainClass.Store, domainClass); } }
private static void FixUpDerivedClasses(DomainClass domainClass, MetaModel model) { if (domainClass.ModelContext.MetaModel == model) { SerializationHelper.UpdateSerializationDomainProperties(domainClass.Store, domainClass.SerializedDomainClass, domainClass); SerializationHelper.UpdateSerializationDomainRoles(domainClass.Store, domainClass.SerializedDomainClass, domainClass); } foreach (DomainClass derivedClass in domainClass.DerivedClasses) { FixUpDerivedClasses(derivedClass, model); } }
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(); } } }
public void ValidateDomainRelationship(ValidationContext context) { if (this.CustomPropertyGridEditor != null) { if (this.CustomPropertyGridEditor.Name == "ReferencedModelRoleViewModel") { if (!(this.Relationship is EmbeddingRelationship)) { context.LogError("DomainRole " + this.Name + " of relationship " + this.Relationship.Name + " can not have CustomPropertyGridEditor set to ReferencedModelRoleViewModel, because the relationship is not an EmbeddingRelationship", "", null); //element); return; } if (this.Relationship.Source.Multiplicity == LanguageDSL.Multiplicity.OneMany || this.Relationship.Source.Multiplicity == LanguageDSL.Multiplicity.ZeroMany) { context.LogError("DomainRole " + this.Name + " of relationship " + this.Relationship.Name + " can not have CustomPropertyGridEditor set to ReferencedModelRoleViewModel, because the Multiplicity is required to be One or ZeroOne", "", null); //element); return; } if (!this.Relationship.Source.IsPropertyGenerator) { context.LogError("DomainRole " + this.Name + " of relationship " + this.Relationship.Name + " can not have CustomPropertyGridEditor set to ReferencedModelRoleViewModel, because the IsPropertyGenerator is set to 'false'", "", null); //element); return; } if (String.IsNullOrEmpty(this.PropertyDisplayName)) { context.LogError("DomainRole " + this.Name + " of relationship " + this.Relationship.Name + " has PropertyDisplayName 'null'", "", null); //element); return; } if ((this.Relationship as EmbeddingRelationship).SerializedEmbeddingRelationship.IsInFullSerialization) { context.LogError("DomainRole " + this.Name + " of relationship " + this.Relationship.Name + " can not have CustomPropertyGridEditor set to ReferencedModelRoleViewModel, because the relationship is set to be serialized in full mode", "", null); //element); return; } DomainClass domainClass = this.RolePlayer as DomainClass; if (domainClass == null) { context.LogError("DomainRole " + this.Name + " of relationship " + this.Relationship.Name + " can not have CustomPropertyGridEditor set to ReferencedModelRoleViewModel, because its target roleplayer is not a DomainClass", "", null); //element); } else if (!domainClass.IsDomainModel) { context.LogError("DomainRole " + this.Name + " of relationship " + this.Relationship.Name + " can not have CustomPropertyGridEditor set to ReferencedModelRoleViewModel, because its target roleplayer is not marked as DomainModel", "", null); //element); } } } }
private static void FixUpModelContext(MetaModel model) { ModelContext modelContext = new ModelContext(model.Store); modelContext.Name = "DefaultContext"; modelContext.IsDefault = true; model.ModelContexts.Add(modelContext); DomainClass domainClass = new DomainClass(model.Store); domainClass.Name = "DomainModel"; domainClass.IsDomainModel = true; domainClass.DisplayName = "DomainModel"; domainClass.SerializationName = "DomainModel"; modelContext.Classes.Add(domainClass); }
/// <summary> /// Adds a new inheritance relationship instance for each source. /// </summary> /// <param name="sources">DomainClass to be the derived classes.</param> /// <param name="target">DomainClass to act as the base class.</param> public static void AddNewInheritanceRelationship(List <DomainClass> sources, DomainClass target) { if (sources.Count == 0) { return; } using (Transaction transaction = sources[0].Store.TransactionManager.BeginTransaction("Create new inheritance rs")) { foreach (DomainClass source in sources) { // create a new embedding relationship AddNewInheritanceRelationship(source, target, false); } transaction.Commit(); } }
public void ValidateSerializedEmbeddingRelationship(ValidationContext context) { if (this.IsTargetIncludedSubmodel) { DomainClass target = this.EmbeddingRelationship.Target.RolePlayer as DomainClass; if (target == null) { context.LogError("IsTargetIncludedSubmodel is set to 'true' on SerializedEmbeddingRelationship of Relationship " + this.EmbeddingRelationship.Name + " but target element is not a domain class!", "SerializedEmbeddingRelationship", null); //this); } else if (!target.IsDomainModel) { context.LogError("IsTargetIncludedSubmodel is set to 'true' on SerializedEmbeddingRelationship of Relationship " + this.EmbeddingRelationship.Name + " but target element is not declared as domain model!", "SerializedEmbeddingRelationship", null); //this); } } }
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; } } } }
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); }
/// <summary> /// Adds a new embedding relationship instance. Needs to be called within a modeling transaction. /// </summary> /// <param name="source">Domain class representing the parent.</param> /// <param name="target">Domain class representing the child.</param> public static void AddNewEmbeddingRS(EmbeddingRelationship emb, DomainClass source, AttributedDomainElement target, bool bTargetElementHolder) { // tree nodes // 1. find the element holder node for source // 2. add new EmbeddingRSNode, connect to rs // 3. add new EmbeddingNode for target TreeNode elementHolderNode = null; foreach (TreeNode node in source.DomainModelTreeNodes) { if (node.IsElementHolder) { elementHolderNode = node; break; } } if (elementHolderNode == null) { throw new ArgumentNullException("elementHolderNode"); } EmbeddingRSNode rsNode = new EmbeddingRSNode(source.Store); rsNode.Relationship = emb; EmbeddingNode embNode = new EmbeddingNode(source.Store); embNode.DomainElement = target; embNode.IsElementHolder = bTargetElementHolder; if (!bTargetElementHolder) { embNode.IsExpanded = false; } elementHolderNode.EmbeddingRSNodes.Add(rsNode); rsNode.EmbeddingNode = embNode; source.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(rsNode); source.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(embNode); }
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); } } }
/// <summary> /// Adds a new referece relationship instance. /// </summary> /// <param name="source">Domain class representing the source.</param> /// <param name="target">Domain class representing the target.</param> public static void AddNewReferenceRelationship(ReferenceRelationship refRel, DomainClass source, AttributedDomainElement target) { // tree nodes // 1. find the element holder node for source // 2. add new ReferenceRSNode, connect to rs // 3. add new ReferenceNode for target TreeNode elementHolderNode = null; foreach (TreeNode node in source.DomainModelTreeNodes) { if (node.IsElementHolder) { elementHolderNode = node; break; } } if (elementHolderNode == null) { throw new ArgumentNullException("elementHolderNode"); } ReferenceRSNode rsNode = new ReferenceRSNode(source.Store); rsNode.ReferenceRelationship = refRel; ReferenceNode refNode = new ReferenceNode(source.Store); refNode.DomainElement = target; refNode.IsElementHolder = false; refNode.IsExpanded = false; elementHolderNode.ReferenceRSNodes.Add(rsNode); rsNode.ReferenceNode = refNode; source.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(rsNode); source.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(refNode); }
/// <summary> /// Get a list of the valid role players for this property value of the specified component. /// </summary> /// <param name="component">The represented element, or null to use the stored represented element when in instance mode.</param> /// <returns>List of ModelElements that could be chosen as the role player for the property</returns> protected override IList <Microsoft.VisualStudio.Modeling.ModelElement> BuildElementList(object component) { Microsoft.VisualStudio.Modeling.DomainClassInfo domainClassInfo = DomainRoleInfo.RolePlayer; if (domainClassInfo == null || component == null) { return(new System.Collections.Generic.List <Microsoft.VisualStudio.Modeling.ModelElement>()); } Microsoft.VisualStudio.Modeling.Store store = this.GetStore(component); System.Collections.Generic.IList <Microsoft.VisualStudio.Modeling.ModelElement> ilist = store.ElementDirectory.FindElements(domainClassInfo, false); System.Collections.Generic.List <Microsoft.VisualStudio.Modeling.ModelElement> list = new System.Collections.Generic.List <Microsoft.VisualStudio.Modeling.ModelElement>(); DomainClass domainClass1 = component as DomainClass; foreach (Microsoft.VisualStudio.Modeling.ModelElement modelElement in ilist) { DomainClass domainClass2 = modelElement as DomainClass; if ((domainClass2 != null) && ShouldIncludeCandidate(domainClass1, domainClass2)) { list.Add(modelElement); } } return(list); }
/// <summary> /// Returns a collection of ModelTreeChildElementCreationInfo for the given domain class. /// </summary> /// <param name="d"></param> /// <returns></returns> public static Collection<ModelTreeChildElementCreationInfo> GetModelTreeChildElementCreationInfo(DomainClass d) { DomainClass domainClass = d; SortedDictionary<string, ModelTreeChildElementCreationInfo> connections = new SortedDictionary<string, ModelTreeChildElementCreationInfo>(); Collection<ModelTreeChildElementCreationInfo> connectionsRet = new Collection<ModelTreeChildElementCreationInfo>(); foreach (DomainRole r in domainClass.RolesPlayed) { if (r.Relationship is EmbeddingRelationship && r.Relationship.Source == r && r.Relationship.InheritanceModifier != InheritanceModifier.Abstract) { EmbeddingRelationship emb = r.Relationship as EmbeddingRelationship; ModelTreeChildElementCreationInfo info = new ModelTreeChildElementCreationInfo(); List<AttributedDomainElement> classes = new List<AttributedDomainElement>(); info.Role = r.Opposite; info.TargetElements = new List<AttributedDomainElement>(); if (emb.Target.RolePlayer.InheritanceModifier != InheritanceModifier.Abstract) classes.Add(emb.Target.RolePlayer); connections.Add(emb.Target.Name, info); // include derived classes o the child side AttributedDomainElement child = emb.Target.RolePlayer; classes.AddRange(GetNonAbstractDerivedElements(child)); // sort by inheritance info.TargetElements.AddRange(SortDomainClassesByInheritance(classes)); } } foreach (string key in connections.Keys) connectionsRet.Add(connections[key]); return connectionsRet; }
/// <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); }
/// <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(DomainClass source, DomainClass target, bool bTargetElementHolder) { DomainClassReferencesBaseClass con = new DomainClassReferencesBaseClass(source, target); AddNewInheritanceRelationship(con, source, target, bTargetElementHolder); }
/// <summary> /// Updates the domain roles of the given element. (Roles from derived elements are included here). /// </summary> /// <param name="store">Store containing the domain model.</param> /// <param name="serializationElement"></param> /// <param name="domainClass"></param> public static void UpdateSerializationDomainRoles(Store store, SerializedDomainClass serializationElement, DomainClass domainClass) { if (serializationElement == null || domainClass == null) return; //if (!serializationElement.DomainClass.ParentModelContext.MetaModel.IsTopMost) // return; List<SerializationElement> handledRS = new List<SerializationElement>(); // get roles DomainClass temp = domainClass; SerializedDomainClass tempElement = serializationElement; while (temp != null && tempElement != null) { foreach (SerializationElement sP in tempElement.Children) { if (sP is SerializedReferenceRelationship || sP is SerializedEmbeddingRelationship) { // see whether the relationship is abstract or not. If it is abstract, than we dont // need to add its role players DomainRelationship relationship = null; SerializedReferenceRelationship s = sP as SerializedReferenceRelationship; if (s != null) { relationship = s.ReferenceRelationship; if (s.ReferenceRelationship.InheritanceModifier == InheritanceModifier.Abstract && s.ReferenceRelationship.Source.RolePlayer != domainClass) continue; } SerializedEmbeddingRelationship sE = sP as SerializedEmbeddingRelationship; if (sE != null) { relationship = sE.EmbeddingRelationship; if (sE.EmbeddingRelationship.InheritanceModifier == InheritanceModifier.Abstract && sE.EmbeddingRelationship.Source.RolePlayer != domainClass) continue; } // see if the current element is still active bool bActive = false; foreach (DomainRole role in temp.RolesPlayed) { if (role.Relationship.Source == role && role.Relationship == relationship) { bActive = true; continue; } } if (!bActive) continue; handledRS.Add(sP); if (tempElement != serializationElement) { // see if we already have this element embedded bool bAdd = true; foreach (SerializationElement elem in serializationElement.Children) if (elem == sP) { bAdd = false; break; } if (bAdd) { serializationElement.Children.Add(sP); } } } } temp = temp.BaseClass; if (temp != null) tempElement = temp.SerializedDomainClass; else tempElement = null; } // remove unneded rs List<SerializationElement> toRemove = new List<SerializationElement>(); foreach (SerializationElement sP in serializationElement.Children) { if (sP is SerializedReferenceRelationship || sP is SerializedEmbeddingRelationship) if (!handledRS.Contains(sP)) { toRemove.Add(sP); } } foreach (SerializationElement sP in toRemove) serializationElement.Children.Remove(sP); }
private void FinalizeDomainClassMerge(ModelProtoElement protoElement, ModelProtoGroupMerger groupMerger) { DomainClass domainClass = this.Store.ElementDirectory.FindElement(groupMerger.GetIdMapping(protoElement.ElementId)) as DomainClass; if (domainClass == null) { return; } if (protoElement.CustomArguments != null) { if (protoElement.CustomArguments is DomainClassSerializationInfo) { DomainClassSerializationInfo info = (DomainClassSerializationInfo)protoElement.CustomArguments; 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 < domainClass.SerializedDomainClass.Attributes.Count; y++) { if (domainClass.SerializedDomainClass.Attributes[y] is SerializedIdProperty && eInfo.ElementName == "SerializedIdProperty") { (domainClass.SerializedDomainClass.Attributes[y] as SerializedIdProperty).OmitIdProperty = eInfo.OmitElement; if (y != i) { domainClass.SerializedDomainClass.Attributes.Move(y, i); } break; } else if (eInfo.ElementName != "SerializedIdProperty" && !(domainClass.SerializedDomainClass.Attributes[y] is SerializedIdProperty)) { SerializedDomainProperty p = domainClass.SerializedDomainClass.Attributes[y] as SerializedDomainProperty; p.OmitProperty = eInfo.OmitElement; if (p.DomainProperty.Id == newId && y != i) { domainClass.SerializedDomainClass.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 < domainClass.SerializedDomainClass.Children.Count; y++) { if (domainClass.SerializedDomainClass.Children[y] is SerializedReferenceRelationship) { SerializedReferenceRelationship sDomainRel = domainClass.SerializedDomainClass.Children[y] as SerializedReferenceRelationship; if (sDomainRel.ReferenceRelationship.Id == newId) { sDomainRel.OmitRelationship = eInfo.OmitElement; if (y != i) { domainClass.SerializedDomainClass.Children.Move(y, i); } break; } } else if (domainClass.SerializedDomainClass.Children[y] is SerializedEmbeddingRelationship) { SerializedEmbeddingRelationship sDomainRel = domainClass.SerializedDomainClass.Children[y] as SerializedEmbeddingRelationship; if (sDomainRel.EmbeddingRelationship.Id == newId) { sDomainRel.OmitRelationship = eInfo.OmitElement; if (y != i) { domainClass.SerializedDomainClass.Children.Move(y, i); } break; } } else if (domainClass.SerializedDomainClass.Children[y] is SerializedDomainProperty) { SerializedDomainProperty p = domainClass.SerializedDomainClass.Children[y] as SerializedDomainProperty; if (p.DomainProperty.Id == newId) { p.OmitProperty = eInfo.OmitElement; if (y != i) { domainClass.SerializedDomainClass.Children.Move(y, i); } break; } } } #endregion } } } } }
public string GenerateModelMergeMembers(DomainClass domainClass) { this.GenerationEnvironment = null; this.GenerateModelMergeMembersInternal(domainClass); return this.GenerationEnvironment.ToString(); }
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; } ModelContext modelContext = e.ModelElement as ModelContext; if (modelContext != null) { if (modelContext.ViewContext == null) { 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); } if (modelContext.DiagramClasses.Count == 0) { DesignerDiagramClass ddC = new DesignerDiagramClass(modelContext.Store); //ddC.Name = "DesignerDiagram"; ddC.Name = NameHelper.GetUniqueName(modelContext.Store, DesignerDiagramClass.DomainClassId); 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); } DomainClass domainClass = modelContext.Store.ElementFactory.CreateElement(DomainClass.DomainClassId) as DomainClass; domainClass.IsDomainModel = true; Microsoft.VisualStudio.Modeling.ElementOperations elementOperations = new Microsoft.VisualStudio.Modeling.ElementOperations(modelContext.Store as IServiceProvider, modelContext.Store.DefaultPartition); Microsoft.VisualStudio.Modeling.ElementGroup elementGroup = new Microsoft.VisualStudio.Modeling.ElementGroup(modelContext.Store.DefaultPartition); elementGroup.Add(domainClass); elementGroup.MarkAsRoot(domainClass); elementOperations.MergeElementGroup(modelContext, elementGroup); domainClass.Name = NameHelper.GetUniqueName(modelContext.Store, DomainClass.DomainClassId); SerializedDomainModel child = new SerializedDomainModel(domainClass.Store); child.DomainClass = domainClass; child.SerializationName = domainClass.SerializationName; if (modelContext.SerializationModel == null) { modelContext.SerializationModel = new SerializationModel(modelContext.Store); } modelContext.SerializationModel.SerializedDomainModel = child; SerializationHelper.AddSerializationDomainProperties(domainClass.Store, domainClass); } }
/// <summary> /// Updates the domain roles of the given element. (Roles from derived elements are included here). /// </summary> /// <param name="store">Store containing the domain model.</param> /// <param name="serializationElement"></param> /// <param name="domainClass"></param> public static void UpdateSerializationDomainRoles(Store store, SerializedDomainClass serializationElement, DomainClass domainClass) { if (serializationElement == null || domainClass == null) { return; } //if (!serializationElement.DomainClass.ParentModelContext.MetaModel.IsTopMost) // return; List <SerializationElement> handledRS = new List <SerializationElement>(); // get roles DomainClass temp = domainClass; SerializedDomainClass tempElement = serializationElement; while (temp != null && tempElement != null) { foreach (SerializationElement sP in tempElement.Children) { if (sP is SerializedReferenceRelationship || sP is SerializedEmbeddingRelationship) { // see whether the relationship is abstract or not. If it is abstract, than we dont // need to add its role players DomainRelationship relationship = null; SerializedReferenceRelationship s = sP as SerializedReferenceRelationship; if (s != null) { relationship = s.ReferenceRelationship; if (s.ReferenceRelationship.InheritanceModifier == InheritanceModifier.Abstract && s.ReferenceRelationship.Source.RolePlayer != domainClass) { continue; } } SerializedEmbeddingRelationship sE = sP as SerializedEmbeddingRelationship; if (sE != null) { relationship = sE.EmbeddingRelationship; if (sE.EmbeddingRelationship.InheritanceModifier == InheritanceModifier.Abstract && sE.EmbeddingRelationship.Source.RolePlayer != domainClass) { continue; } } // see if the current element is still active bool bActive = false; foreach (DomainRole role in temp.RolesPlayed) { if (role.Relationship.Source == role && role.Relationship == relationship) { bActive = true; continue; } } if (!bActive) { continue; } handledRS.Add(sP); if (tempElement != serializationElement) { // see if we already have this element embedded bool bAdd = true; foreach (SerializationElement elem in serializationElement.Children) { if (elem == sP) { bAdd = false; break; } } if (bAdd) { serializationElement.Children.Add(sP); } } } } temp = temp.BaseClass; if (temp != null) { tempElement = temp.SerializedDomainClass; } else { tempElement = null; } } // remove unneded rs List <SerializationElement> toRemove = new List <SerializationElement>(); foreach (SerializationElement sP in serializationElement.Children) { if (sP is SerializedReferenceRelationship || sP is SerializedEmbeddingRelationship) { if (!handledRS.Contains(sP)) { toRemove.Add(sP); } } } foreach (SerializationElement sP in toRemove) { serializationElement.Children.Remove(sP); } }
internal virtual bool ShouldIncludeCandidate(DomainClass currentRoleplayer, DomainClass eachCandidate) { if (eachCandidate != currentRoleplayer) return !eachCandidate.IsDerivedFrom(currentRoleplayer); return false; }
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 GenerateModelMergeMembersInternal(DomainClass domainClass) { #line default #line hidden #line 19 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" this.Write("#region IModelMergeElements\r\n"); #line default #line hidden #line 21 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" if( !domainClass.CanCopy ) { #line default #line hidden #line 24 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" this.Write("/// <summary>\r\n/// Decides whether the element can be copied or not.\r\n/// </summa" + "ry>\r\n/// <returns>True if the element can be copied. False otherwise.</returns>\r" + "\npublic override bool ModelIsCopyAllowed()\r\n{\r\n\treturn false;\r\n}\r\n\r\n"); #line default #line hidden #line 34 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" } if( !domainClass.CanMove ) { #line default #line hidden #line 38 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" this.Write("/// <summary>\r\n/// Decides whether the element can be moved or not.\r\n/// </summar" + "y>\r\n/// <returns>True if the element can be moved. False otherwise.</returns>\r\np" + "ublic override bool ModelIsMoveAllowed()\r\n{\r\n\treturn false;\r\n}\r\n\r\n"); #line default #line hidden #line 48 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" } if( !domainClass.CanPaste ) { #line default #line hidden #line 52 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" this.Write(@"/// <summary> /// Decides whether the element can be pasted or not based on the operation. /// </summary> /// <param name=""protoGroupOperation"">Proto group operation.</param> /// <returns>True if the element can be pasted. False otherwise.</returns> public override bool ModelIsPasteAllowed(DslEditorModeling::ModelProtoGroupOperation protoGroupOperation) { if( protoGroupOperation == DslEditorModeling.ModelProtoGroupOperation.Move ) return ModelIsMoveAllowed(); return false; } "); #line default #line hidden #line 66 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" } #line default #line hidden #line 69 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" this.Write("#endregion\r\n"); #line default #line hidden #line 71 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\MergeGenerator.tt" }
public void GenerateDomainClass(DomainClass domainClass) { //string baseClass = "DslModeling::ModelElement"; string baseClass = "DslEditorModeling::DomainModelElement"; baseClass = CodeGenerationUtilities.GetBaseClass(domainClass, baseClass); string namespaceString = domainClass.Namespace; if(!string.IsNullOrEmpty(namespaceString)) { #line default #line hidden #line 24 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("namespace "); #line default #line hidden #line 25 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(namespaceString)); #line default #line hidden #line 25 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\r\n{\r\n"); #line default #line hidden #line 27 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" PushIndent("\t"); } int inheritanceDepth = CodeGenerationUtilities.CalculateInheritanceDepth (domainClass); this.Write(Utilities.Instance.GenerateSummary("DomainClass", domainClass, true)); if (domainClass.GeneratesDoubleDerived) { if (inheritanceDepth > 6) { #line default #line hidden #line 38 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("[global::System.Diagnostics.CodeAnalysis.SuppressMessage(\"Microsoft.Maintainabili" + "ty\", \"CA1501:AvoidExcessiveInheritance\", Justification = \"Generated code.\")]\r\n"); #line default #line hidden #line 40 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } } else if (inheritanceDepth > 5) { #line default #line hidden #line 45 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("[global::System.Diagnostics.CodeAnalysis.SuppressMessage(\"Microsoft.Maintainabili" + "ty\", \"CA1501:AvoidExcessiveInheritance\", Justification = \"Generated code.\")]\r\n"); #line default #line hidden #line 47 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } this.Write(Utilities.Instance.GenerateResourceAttributes(domainClass, GeneratedResourceName)); this.Write(Utilities.Instance.GenerateDebuggerDisplayAttribute(domainClass)); #line default #line hidden #line 51 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("[DslModeling::DomainObjectId(\""); #line default #line hidden #line 52 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.Id.ToString("D"))); #line default #line hidden #line 52 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\")]\r\n"); #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetAccessModifier(domainClass.AccessModifier))); #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetGenerationInheritanceModifier(domainClass))); #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(" partial class "); #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetGenerationClassName(domainClass))); #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(" : "); #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(baseClass)); #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" if(domainClass.IsDomainModel) { #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(", DslEditorModeling::IParentModelElement "); #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } #line default #line hidden #line 53 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(" \r\n{\r\n\t#region Constructors, domain class Id\r\n\r\n\t/// <summary>\r\n\t/// "); #line default #line hidden #line 58 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.Name)); #line default #line hidden #line 58 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(" domain class Id.\r\n\t/// </summary>\r\n\tpublic static readonly new global::System.Gu" + "id DomainClassId = new System.Guid(\""); #line default #line hidden #line 60 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.Id.ToString("D"))); #line default #line hidden #line 60 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\");\r\n"); #line default #line hidden #line 61 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" PushIndent("\t"); GenerateDomainClassConstructors(domainClass, true); PopIndent(); #line default #line hidden #line 65 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t#endregion\r\n"); #line default #line hidden #line 67 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" PushIndent("\t"); DomainProperty nameProperty = null; foreach(DomainProperty property in domainClass.Properties) { this.Write(DomainPropertyGenerator.Instance.GenerateDomainProperty(property)); if( property.IsElementName ) nameProperty = property; } foreach(DomainRole role in domainClass.RolesPlayed) { this.Write(DomainRoleGenerator.Instance.GenerateOppositeRoleAccessor(role)); } this.Write(MergeGenerator.Instance.GenerateModelMergeMembers(domainClass)); PopIndent(); if( domainClass.IsDomainModel ) { #line default #line hidden #line 89 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t#region DomainFilePath\r\n\t/// <summary>\r\n\t/// Gets or sets the domain file path.\r" + "\n\t/// </summary>\r\n\tpublic string DomainFilePath{ get; set; }\r\n\t#endregion\r\n"); #line default #line hidden #line 96 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } string domainModelType = domainClass.GetMetaModel().GetFullName(true)+"DomainModel"; string modifier = "override "; #line default #line hidden #line 101 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t#region IDomainModelOwnable\r\n\t/*\r\n \t/// <summary>\r\n /// Gets the document dat" + "a\r\n /// </summary>\r\n public override DslEditorModeling::ModelData Document" + "Data\r\n {\r\n get\r\n\t\t{\r\n"); #line default #line hidden #line 111 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" if( this.EditorType == GenerationEditorType.VSPlugin ) { #line default #line hidden #line 114 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\t// Null because in the visual studio plugin environment there can be multiple " + "model datas present at once. Therefore there\r\n\t\t\t// is no singleton accessor for" + " the model data.\r\n\t\t\treturn null;\r\n"); #line default #line hidden #line 118 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { #line default #line hidden #line 122 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn "); #line default #line hidden #line 123 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.GetMetaModel().GetFullName(true))); #line default #line hidden #line 123 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("DocumentData.Instance;\r\n"); #line default #line hidden #line 124 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } #line default #line hidden #line 126 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t}\r\n }*/\r\n\t\t\r\n\t/// <summary>\r\n /// Gets the domain model type.\r\n /// </" + "summary>\r\n /// <returns>Domain model type.</returns>\r\n public "); #line default #line hidden #line 134 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(modifier)); #line default #line hidden #line 134 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("System.Type GetDomainModelType()\r\n\t{\r\n\t\treturn typeof("); #line default #line hidden #line 136 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainModelType)); #line default #line hidden #line 136 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(");\r\n\t}\r\n\r\n /// <summary>\r\n /// Gets the domain model services.\r\n /// </s" + "ummary>\r\n /// <returns>Domain model services.</returns>\r\n public "); #line default #line hidden #line 143 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(modifier)); #line default #line hidden #line 143 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("DslEditorModeling::IDomainModelServices GetDomainModelServices()\r\n\t{\r\n\t\treturn "); #line default #line hidden #line 145 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.MetaModel.GetFullName(true))); #line default #line hidden #line 145 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("DomainModelServices.Instance;\r\n\t}\r\n\t\r\n /// <summary>\r\n /// Gets the domain " + "model DomainClassId.\r\n /// </summary>\r\n /// <returns></returns>\r\n publi" + "c "); #line default #line hidden #line 152 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(modifier)); #line default #line hidden #line 152 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("System.Guid GetDomainModelTypeId()\r\n\t{\r\n\t\treturn "); #line default #line hidden #line 154 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainModelType)); #line default #line hidden #line 154 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(".DomainModelId;\r\n\t}\t\r\n\r\n /// <summary>\r\n /// Gets or sets the value of the " + "property (which is marked as element name)\r\n /// </summary>\r\n public "); #line default #line hidden #line 160 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(modifier)); #line default #line hidden #line 160 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("string DomainElementName\r\n\t{\r\n\t\tget\r\n\t\t{\r\n"); #line default #line hidden #line 164 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" if( nameProperty != null ) { #line default #line hidden #line 167 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn this."); #line default #line hidden #line 168 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(nameProperty.Name)); #line default #line hidden #line 168 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(";\r\n"); #line default #line hidden #line 169 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { if( domainClass.BaseClass != null ) { #line default #line hidden #line 175 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn base.DomainElementName;\r\n"); #line default #line hidden #line 177 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { #line default #line hidden #line 181 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn null;\r\n"); #line default #line hidden #line 183 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } } #line default #line hidden #line 186 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t}\r\n\t\tset\r\n\t\t{\r\n"); #line default #line hidden #line 190 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" if( nameProperty != null ) { #line default #line hidden #line 193 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\tthis."); #line default #line hidden #line 194 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(nameProperty.Name)); #line default #line hidden #line 194 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(" = value;\r\n"); #line default #line hidden #line 195 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { if( domainClass.BaseClass != null ) { #line default #line hidden #line 201 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\tbase.DomainElementName = value;\r\n"); #line default #line hidden #line 203 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } } #line default #line hidden #line 206 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t}\r\n\t}\r\n\t\r\n /// <summary>\r\n /// Gets whether the domain element has a prop" + "erty marked as element name.\r\n /// </summary>\r\n public "); #line default #line hidden #line 213 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(modifier)); #line default #line hidden #line 213 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("bool DomainElementHasName \r\n {\r\n\t\tget\r\n\t\t{\r\n"); #line default #line hidden #line 217 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" if( nameProperty != null ) { #line default #line hidden #line 220 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn true;\r\n"); #line default #line hidden #line 222 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { if( domainClass.BaseClass != null ) { #line default #line hidden #line 228 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn base.DomainElementHasName;\r\n"); #line default #line hidden #line 230 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { #line default #line hidden #line 234 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn false;\r\n"); #line default #line hidden #line 236 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } } #line default #line hidden #line 239 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t}\r\n }\t\r\n\t\r\n /// <summary>\r\n /// Gets the domain element name info if t" + "here is one; Null otherwise.\r\n /// </summary>\r\n public "); #line default #line hidden #line 246 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(modifier)); #line default #line hidden #line 246 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("DslModeling::DomainPropertyInfo DomainElementNameInfo\r\n {\r\n\t\tget\r\n\t\t{\r\n"); #line default #line hidden #line 250 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" if( nameProperty != null ) { #line default #line hidden #line 253 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn this.Store.DomainDataDirectory.GetDomainProperty("); #line default #line hidden #line 254 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.GetFullName(true))); #line default #line hidden #line 254 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("."); #line default #line hidden #line 254 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(nameProperty.Name)); #line default #line hidden #line 254 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("DomainPropertyId);\r\n"); #line default #line hidden #line 255 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { if( domainClass.BaseClass != null ) { #line default #line hidden #line 261 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn base.DomainElementNameInfo;\r\n"); #line default #line hidden #line 263 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { #line default #line hidden #line 267 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\treturn null;\r\n"); #line default #line hidden #line 269 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } } #line default #line hidden #line 273 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t}\r\n }\r\n\t\r\n\t/// <summary>\r\n /// Gets the type of the ModelElement as strin" + "g.\r\n /// </summary>\r\n public "); #line default #line hidden #line 280 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(modifier)); #line default #line hidden #line 280 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("string DomainElementType\r\n {\r\n get\r\n {\r\n return \""); #line default #line hidden #line 284 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.Name)); #line default #line hidden #line 284 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\";\r\n }\r\n }\r\n\r\n /// <summary>\r\n /// Gets the display name of the t" + "ype of the ModelElement.\r\n /// </summary>\r\n public "); #line default #line hidden #line 291 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(modifier)); #line default #line hidden #line 291 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("string DomainElementTypeDisplayName\r\n {\r\n get\r\n {\r\n r" + "eturn \""); #line default #line hidden #line 295 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.DisplayName)); #line default #line hidden #line 295 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\";\r\n }\r\n }\t\t\r\n\t#endregion\r\n\r\n\t/// <summary>\r\n /// Gets the domain cl" + "ass Id of this element.\r\n /// </summary>\r\n /// <returns>DomainClass Id.</r" + "eturns>\r\n public override System.Guid GetDomainClassId()\r\n {\r\n retu" + "rn "); #line default #line hidden #line 306 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.GetFullName(true))); #line default #line hidden #line 306 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(".DomainClassId;\r\n }\r\n}\r\n"); #line default #line hidden #line 309 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" // If this class is double-derived, generate the skeleton derived class (with just the // constructors) if ( domainClass.GeneratesDoubleDerived ) { this.Write(Utilities.Instance.GenerateSummary("DomainClass", domainClass, false)); if (inheritanceDepth > 5) { #line default #line hidden #line 317 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("[global::System.Diagnostics.CodeAnalysis.SuppressMessage(\"Microsoft.Maintainabili" + "ty\", \"CA1501:AvoidExcessiveInheritance\", Justification = \"Generated code.\")]\r\n"); #line default #line hidden #line 319 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } #line default #line hidden #line 321 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t\t\r\n"); #line default #line hidden #line 322 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetAccessModifier(domainClass.AccessModifier))); #line default #line hidden #line 322 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetInheritanceModifier(domainClass.InheritanceModifier))); #line default #line hidden #line 322 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(" partial class "); #line default #line hidden #line 322 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(domainClass.Name)); #line default #line hidden #line 322 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(" : "); #line default #line hidden #line 322 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(CodeGenerationUtilities.GetGenerationClassName(domainClass))); #line default #line hidden #line 322 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\r\n{\r\n\t#region Constructors\r\n"); #line default #line hidden #line 325 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" PushIndent("\t"); GenerateDomainClassConstructors(domainClass, false); PopIndent(); #line default #line hidden #line 329 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("\t#endregion\r\n}\r\n"); #line default #line hidden #line 332 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } if(!string.IsNullOrEmpty(namespaceString)) { PopIndent(); #line default #line hidden #line 337 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("}\r\n"); #line default #line hidden #line 339 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } }
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; } DomainClass domainClass = e.ModelElement as DomainClass; if (domainClass != null) { if (e.DomainProperty.Id == DomainClass.SerializationNameDomainPropertyId) { SerializedDomainClass c = domainClass.SerializedDomainClass; if (c != null) { if (c.SerializationName != domainClass.SerializationName) { c.SerializationName = domainClass.SerializationName; if (domainClass.IsSerializationNameTracking != TrackingEnum.False) { c.IsSerializationNameTracking = TrackingEnum.IgnoreOnce; } else { c.IsSerializationNameTracking = TrackingEnum.False; } } } } else if (e.DomainProperty.Id == DomainClass.NameDomainPropertyId) { foreach (DomainRole role in domainClass.RolesPlayed) { if (ImmutabilityExtensionMethods.GetLocks(role) != Locks.None) { continue; } if (role.IsNameTracking == TrackingEnum.True) { if (role.Name != domainClass.Name) { if (role.RolePlayer == role.Opposite.RolePlayer) { if (role.Relationship.Source == role) { role.Name = domainClass.Name + "Source"; } else { role.Name = domainClass.Name + "Target"; } } else { role.Name = domainClass.Name; } role.IsNameTracking = TrackingEnum.IgnoreOnce; } } } } } }
public override void RolePlayerChanged(RolePlayerChangedEventArgs e) { if (e.ElementLink != null) { if (e.ElementLink.Store.TransactionManager.CurrentTransaction != null) { if (e.ElementLink.Store.TransactionManager.CurrentTransaction.IsSerializing) { return; } } } if (e.ElementLink == null) { return; } if (ImmutabilityExtensionMethods.GetLocks(e.ElementLink) != Locks.None) { return; } ShapeClassReferencesDomainClass shapeCon = e.ElementLink as ShapeClassReferencesDomainClass; if (shapeCon != null) { PresentationDomainClassElement shapeClass = shapeCon.ShapeClass; ShapeClassNode node = shapeClass.ShapeClassNode; // delete old DomainClass domainClass = e.OldRolePlayer as DomainClass; if (node != null) { foreach (TreeNode n in domainClass.DomainModelTreeNodes) { if (n.IsElementHolder) { if (n.ShapeClassNodes.Contains(node)) { n.ShapeClassNodes.Remove(node); } break; } } } // add new domainClass = e.NewRolePlayer as DomainClass; foreach (TreeNode n in domainClass.DomainModelTreeNodes) { if (n.IsElementHolder) { ShapeClassNode shapeNode = new ShapeClassNode(shapeCon.Store); shapeClass.ShapeClassNode = shapeNode; n.ShapeClassNodes.Add(shapeNode); domainClass.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(shapeNode); break; } } if (node != null) { node.Delete(); } } }
private static void FixUpDerivedClasses(DomainClass domainClass, MetaModel model) { if (domainClass.ModelContext.MetaModel == model) { SerializationHelper.UpdateSerializationDomainProperties(domainClass.Store, domainClass.SerializedDomainClass, domainClass); SerializationHelper.UpdateSerializationDomainRoles(domainClass.Store, domainClass.SerializedDomainClass, domainClass); } foreach (DomainClass derivedClass in domainClass.DerivedClasses) FixUpDerivedClasses(derivedClass, model); }
private bool ShouldGenerateSpecificVM(DomainClass domainClass) { bool bGenerate = false; if( domainClass.GenerateSpecificViewModel ) bGenerate = true; if( !bGenerate ) { foreach(DomainClass d in domainClass.DerivedClasses) if( ShouldGenerateSpecificVM(d) ) return true; } return bGenerate; }
/// <summary> /// Generate the constructors for a DomainClass /// </summary> /// <param name="domainClass">the domain class to generate constructors for</param> /// <param name="generatedClass">Whether this is the class carrying the generated code or the derived class in a double-derived pair</param> private void GenerateDomainClassConstructors(DomainClass domainClass, bool generatedClass) { if(domainClass.HasCustomConstructor && !(generatedClass && domainClass.GeneratesDoubleDerived)) { #line default #line hidden #line 354 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("// Constructors were not generated for this class because it had HasCustomConstru" + "ctor\r\n// set to true. Please provide the constructors below in a partial class.\r" + "\n"); #line default #line hidden #line 357 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" // We comment out the constructors if HasCustomConstructor is set to true PushIndent("//"); } string ctorName; if ( generatedClass ) { ctorName = CodeGenerationUtilities.GetGenerationClassName(domainClass); } else { ctorName = domainClass.Name; } if(domainClass.InheritanceModifier == InheritanceModifier.Abstract || (generatedClass && domainClass.GeneratesDoubleDerived )) { #line default #line hidden #line 372 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(@"/// <summary> /// Constructor. /// </summary> /// <param name=""partition"">Partition where new element is to be created.</param> /// <param name=""propertyAssignments"">List of domain property id/value pairs to set once the element is created.</param> protected "); #line default #line hidden #line 378 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ctorName)); #line default #line hidden #line 378 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("(DslModeling::Partition partition, DslModeling::PropertyAssignment[] propertyAssi" + "gnments)\r\n\t: base(partition, propertyAssignments)\r\n{\r\n}\r\n"); #line default #line hidden #line 382 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } else { #line default #line hidden #line 386 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("/// <summary>\r\n/// Constructor\r\n/// </summary>\r\n/// <param name=\"store\">Store whe" + "re new element is to be created.</param>\r\n/// <param name=\"propertyAssignments\">" + "List of domain property id/value pairs to set once the element is created.</para" + "m>\r\npublic "); #line default #line hidden #line 392 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ctorName)); #line default #line hidden #line 392 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(@"(DslModeling::Store store, params DslModeling::PropertyAssignment[] propertyAssignments) : this(store != null ? store.DefaultPartitionForClass(DomainClassId) : null, propertyAssignments) { } /// <summary> /// Constructor /// </summary> /// <param name=""partition"">Partition where new element is to be created.</param> /// <param name=""propertyAssignments"">List of domain property id/value pairs to set once the element is created.</param> public "); #line default #line hidden #line 402 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(ctorName)); #line default #line hidden #line 402 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("(DslModeling::Partition partition, params DslModeling::PropertyAssignment[] prope" + "rtyAssignments)\r\n\t: base(partition, "); #line default #line hidden #line 403 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.MetaModel.Namespace)); #line default #line hidden #line 403 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("."); #line default #line hidden #line 403 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write(this.ToStringHelper.ToStringWithCulture(this.MetaModel.Name)); #line default #line hidden #line 403 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" this.Write("DomainModelIdProvider.Instance.AssignId(propertyAssignments))\r\n{\r\n}\r\n"); #line default #line hidden #line 406 "J:\Uni\CC Processes\Werkzeuge\PDE 2\Tum.PDE.ToolFramework\Tum.PDE.ToolFramework.Templates\DomainClassGenerator.tt" } if(domainClass.HasCustomConstructor && !(generatedClass && domainClass.GeneratesDoubleDerived)) { PopIndent(); } }