private static void SetUniqueName(DslModeling::ElementLink link) { if (DslModeling::DomainClassInfo.HasNameProperty(link)) { DslModeling::DomainClassInfo.SetUniqueName(link); } }
/// <summary> /// Helper method to find shapes for either end of a connector by looking for shapes associated with either end of the relationship mapped to the connector. /// </summary> private DslDiagrams::NodeShape[] GetEndShapesForConnector(DslDiagrams::BinaryLinkShape connector) { DslModeling::ElementLink link = connector.ModelElement as DslModeling::ElementLink; DslDiagrams::NodeShape sourceShape = null, targetShape = null; if (link != null) { global::System.Collections.ObjectModel.ReadOnlyCollection <DslModeling::ModelElement> linkedElements = link.LinkedElements; if (linkedElements.Count == 2) { DslDiagrams::Diagram currentDiagram = this.Diagram; DslModeling::LinkedElementCollection <DslDiagrams::PresentationElement> presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[0]); foreach (DslDiagrams::PresentationElement presentationElement in presentationElements) { DslDiagrams::NodeShape shape = presentationElement as DslDiagrams::NodeShape; if (shape != null && shape.Diagram == currentDiagram) { sourceShape = shape; break; } } presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[1]); foreach (DslDiagrams::PresentationElement presentationElement in presentationElements) { DslDiagrams::NodeShape shape = presentationElement as DslDiagrams::NodeShape; if (shape != null && shape.Diagram == currentDiagram) { targetShape = shape; break; } } } } return(new DslDiagrams::NodeShape[] { sourceShape, targetShape }); }
/// <summary> /// Called to ask the filter if a particular role player should be Visited during traversal /// </summary> /// <param name="walker">ElementWalker traversing the model</param> /// <param name="sourceElement">Model Element playing the source role</param> /// <param name="elementLink">Element Link that forms the relationship to the role player in question</param> /// <param name="targetDomainRole">DomainRoleInfo of the target role</param> /// <param name="targetRolePlayer">Model Element that plays the target role in the relationship</param> /// <returns></returns> public virtual DslModeling::VisitorFilterResult ShouldVisitRolePlayer(DslModeling::ElementWalker walker, DslModeling::ModelElement sourceElement, DslModeling::ElementLink elementLink, DslModeling::DomainRoleInfo targetDomainRole, DslModeling::ModelElement targetRolePlayer) { return(this.DomainRoles.ContainsKey(targetDomainRole.Id) ? DslModeling::VisitorFilterResult.Yes : DslModeling::VisitorFilterResult.DoNotCare); }
/// <summary> /// Called to ask the filter if a particular relationship from a source element should be included in the traversal /// </summary> /// <param name="walker">ElementWalker traversing the model</param> /// <param name="sourceElement">Model Element playing the source role</param> /// <param name="sourceRoleInfo">DomainRoleInfo of the role that the source element is playing in the relationship</param> /// <param name="domainRelationshipInfo">DomainRelationshipInfo for the ElementLink in question</param> /// <param name="targetRelationship">Relationship in question</param> /// <returns>Yes if the relationship should be traversed</returns> public virtual DslModeling::VisitorFilterResult ShouldVisitRelationship(DslModeling::ElementWalker walker, DslModeling::ModelElement sourceElement, DslModeling::DomainRoleInfo sourceRoleInfo, DslModeling::DomainRelationshipInfo domainRelationshipInfo, DslModeling::ElementLink targetRelationship) { return(this.DomainRoles.ContainsKey(sourceRoleInfo.Id) ? DslModeling::VisitorFilterResult.Yes : DslModeling::VisitorFilterResult.DoNotCare); }
/// <summary> /// Called to ask the filter if a particular relationship from a source element should be included in the traversal /// </summary> /// <param name="walker">ElementWalker that is traversing the model</param> /// <param name="sourceElement">Model Element playing the source role</param> /// <param name="sourceRoleInfo">DomainRoleInfo of the role that the source element is playing in the relationship</param> /// <param name="domainRelationshipInfo">DomainRelationshipInfo for the ElementLink in question</param> /// <param name="targetRelationship">Relationship in question</param> /// <returns>Yes if the relationship should be traversed</returns> public virtual DslModeling::VisitorFilterResult ShouldVisitRelationship(DslModeling::ElementWalker walker, DslModeling::ModelElement sourceElement, DslModeling::DomainRoleInfo sourceRoleInfo, DslModeling::DomainRelationshipInfo domainRelationshipInfo, DslModeling::ElementLink targetRelationship) { return(DslModeling::VisitorFilterResult.Yes); }
/// <summary> /// Called to ask the filter if a particular role player should be Visited during traversal /// </summary> /// <param name="walker">ElementWalker that is traversing the model</param> /// <param name="sourceElement">Model Element playing the source role</param> /// <param name="elementLink">Element Link that forms the relationship to the role player in question</param> /// <param name="targetDomainRole">DomainRoleInfo of the target role</param> /// <param name="targetRolePlayer">Model Element that plays the target role in the relationship</param> /// <returns></returns> public virtual DslModeling::VisitorFilterResult ShouldVisitRolePlayer(DslModeling::ElementWalker walker, DslModeling::ModelElement sourceElement, DslModeling::ElementLink elementLink, DslModeling::DomainRoleInfo targetDomainRole, DslModeling::ModelElement targetRolePlayer) { if (targetDomainRole == null) { throw new global::System.ArgumentNullException("targetDomainRole"); } return(this.DomainRoles.Contains(targetDomainRole.Id) ? DslModeling::VisitorFilterResult.Yes : DslModeling::VisitorFilterResult.DoNotCare); }
private static DslModeling::ModelElement GetParentForRelationship(DslModeling::ElementLink elementLink) { global::System.Collections.ObjectModel.ReadOnlyCollection <DslModeling::ModelElement> linkedElements = elementLink.LinkedElements; if (linkedElements.Count == 2) { DslDiagrams::ShapeElement sourceShape = linkedElements[0] as DslDiagrams::ShapeElement; DslDiagrams::ShapeElement targetShape = linkedElements[1] as DslDiagrams::ShapeElement; if (sourceShape == null) { DslModeling::LinkedElementCollection <DslDiagrams::PresentationElement> presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[0]); foreach (DslDiagrams::PresentationElement presentationElement in presentationElements) { DslDiagrams::ShapeElement shape = presentationElement as DslDiagrams::ShapeElement; if (shape != null) { sourceShape = shape; break; } } } if (targetShape == null) { DslModeling::LinkedElementCollection <DslDiagrams::PresentationElement> presentationElements = DslDiagrams::PresentationViewsSubject.GetPresentation(linkedElements[1]); foreach (DslDiagrams::PresentationElement presentationElement in presentationElements) { DslDiagrams::ShapeElement shape = presentationElement as DslDiagrams::ShapeElement; if (shape != null) { targetShape = shape; break; } } } if (sourceShape == null || targetShape == null) { global::System.Diagnostics.Debug.Fail("Unable to find source and/or target shape for view fixup."); return(null); } DslDiagrams::ShapeElement sourceParent = sourceShape.ParentShape; DslDiagrams::ShapeElement targetParent = targetShape.ParentShape; while (sourceParent != targetParent && sourceParent != null) { DslDiagrams::ShapeElement curParent = targetParent; while (sourceParent != curParent && curParent != null) { curParent = curParent.ParentShape; } if (sourceParent == curParent) { break; } else { sourceParent = sourceParent.ParentShape; } } while (sourceParent != null) { // ensure that the parent can parent connectors (i.e., a diagram or a swimlane). if (sourceParent is DslDiagrams::Diagram || sourceParent is DslDiagrams::SwimlaneShape) { break; } else { sourceParent = sourceParent.ParentShape; } } global::System.Diagnostics.Debug.Assert(sourceParent != null && sourceParent.ModelElement != null, "Unable to find common parent for view fixup."); return(sourceParent.ModelElement); } return(null); }
public override DslEditorViewModelModelTree::ModelElementTreeViewModel CreateModelElementTreeViewModel(DslModeling::ModelElement element, DslModeling::ElementLink link, System.Guid domainRoleId, DslEditorViewModelModelTree::ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, DslEditorViewModel::MainModelTreeViewModel mainModelTreeVm) { if (element is DslEditorModeling::IDomainModelOwnable) { if (global::Tum.TestLanguage.TestLanguageDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId()) { return(new Tum.TestLanguage.ViewModel.ModelTree.ModelTreeTestLanguageViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); } } return(new DslEditorViewModelModelTree::ModelElementTreeViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); }
public ModelTreeVSPluginDSLViewModel(DslEditorViewModelData::ViewModelStore viewModelStore, DslModeling::ModelElement element, DslModeling::ElementLink link, System.Guid domainRoleId, DslEditorTreeViewModel::ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, DslEditorViewModel::MainModelTreeViewModel mainModelTreeVm) : base(viewModelStore, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm) { }
public override DslEditorViewModelModelTree::ModelElementTreeViewModel CreateModelElementTreeViewModel(DslModeling::ModelElement element, DslModeling::ElementLink link, System.Guid domainRoleId, DslEditorViewModelModelTree::ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, DslEditorViewModel::MainModelTreeViewModel mainModelTreeVm) { if (element is DslEditorModeling::IDomainModelOwnable) { if (global::Tum.VModellXT.VModellXTDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId()) { return(new Tum.VModellXT.ViewModel.ModelTree.ModelTreeVModellXTViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); } if (global::Tum.VModellXT.Basis.VModellXTBasisDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId()) { return(new Tum.VModellXT.Basis.ViewModel.ModelTree.ModelTreeVModellXTBasisViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); } if (global::Tum.VModellXT.Statik.VModellXTStatikDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId()) { return(new Tum.VModellXT.Statik.ViewModel.ModelTree.ModelTreeVModellXTStatikViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); } if (global::Tum.VModellXT.Dynamik.VModellXTDynamikDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId()) { return(new Tum.VModellXT.Dynamik.ViewModel.ModelTree.ModelTreeVModellXTDynamikViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); } if (global::Tum.VModellXT.Anpassung.VModellXTAnpassungDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId()) { return(new Tum.VModellXT.Anpassung.ViewModel.ModelTree.ModelTreeVModellXTAnpassungViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); } if (global::Tum.VModellXT.Konventionsabbildungen.VModellXTKonventionsabbildungenDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId()) { return(new Tum.VModellXT.Konventionsabbildungen.ViewModel.ModelTree.ModelTreeVModellXTKonventionsabbildungenViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); } if (global::Tum.VModellXT.Aenderungsoperationen.VModellXTAenderungesoperationenDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId()) { return(new Tum.VModellXT.Aenderungsoperationen.ViewModel.ModelTree.ModelTreeVModellXTAenderungesoperationenViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); } } return(new DslEditorViewModelModelTree::ModelElementTreeViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm)); }
/// <summary> /// Called to ask the filter if a particular relationship from a source element should be included in the traversal /// </summary> /// <param name="walker">ElementWalker traversing the model</param> /// <param name="sourceElement">Model Element playing the source role</param> /// <param name="sourceRoleInfo">DomainRoleInfo of the role that the source element is playing in the relationship</param> /// <param name="domainRelationshipInfo">DomainRelationshipInfo for the ElementLink in question</param> /// <param name="targetRelationship">Relationship in question</param> /// <returns>Yes if the relationship should be traversed</returns> public virtual DslModeling::VisitorFilterResult ShouldVisitRelationship(DslModeling::ElementWalker walker, DslModeling::ModelElement sourceElement, DslModeling::DomainRoleInfo sourceRoleInfo, DslModeling::DomainRelationshipInfo domainRelationshipInfo, DslModeling::ElementLink targetRelationship) { if (sourceRoleInfo == null) { throw new global::System.ArgumentNullException("sourceRoleInfo"); } return(this.DomainRoles.Contains(sourceRoleInfo.Id) ? DslModeling::VisitorFilterResult.Yes : DslModeling::VisitorFilterResult.DoNotCare); }
/// <summary> /// Method used to add a element into a sorted collection without destroying the sorting order. /// </summary> /// <param name="collection">Sorted collection to add the new view models to.</param> /// <param name="link">Embedding relationship including the model element as the child (target).</param> /// <param name="c">View model representing the model element to be added to the collection.</param> public override void InsertElement(DslEditorTreeViewModel::BaseModelElementTreeViewModel parent, System.Collections.ObjectModel.ObservableCollection <DslEditorTreeViewModel::BaseModelElementTreeViewModel> collection, DslModeling::ElementLink link, DslEditorTreeViewModel::BaseModelElementTreeViewModel c) { if (parent.ElementLinkOrder.Count <= 1) { InsertElement(0, parent, collection, link, c); } else { int index = 0; System.Collections.Generic.List <System.Guid> typesBeforeCurrent = new System.Collections.Generic.List <System.Guid>(); System.Guid currentType = c.ElementLinkDomainClassId; for (int i = 0; i < parent.ElementLinkOrder.Count; i++) { if (parent.ElementLinkOrder[i] == currentType) { index = i; break; } else { typesBeforeCurrent.Add(parent.ElementLinkOrder[i]); } } if (index > 0) { for (int i = 0; i < collection.Count; i++) { if (typesBeforeCurrent.Contains(collection[i].ElementLinkDomainClassId)) { continue; } InsertElement(i, parent, collection, link, c); return; } InsertElement(collection.Count, parent, collection, link, c); return; } InsertElement(index, parent, collection, link, c); } }
/// <summary> /// Method used to add a element into a sorted collection without destroying the sorting order. /// </summary> /// <param name="typeIndex">Index in the collection at which the link type's elements start.</param> /// <param name="collection">Sorted collection to add the new view models to.</param> /// <param name="link">Embedding relationship including the model element as the child (target).</param> /// <param name="c">View model representing the model element to be added to the collection.</param> protected virtual void InsertElement(int typeIndex, DslEditorTreeViewModel::BaseModelElementTreeViewModel parent, System.Collections.ObjectModel.ObservableCollection <DslEditorTreeViewModel::BaseModelElementTreeViewModel> collection, DslModeling::ElementLink link, DslEditorTreeViewModel::BaseModelElementTreeViewModel c) { System.Collections.ObjectModel.ReadOnlyCollection <DslModeling::ElementLink> lllinks = DslModeling::DomainRoleInfo.GetElementLinks <DslModeling::ElementLink>(parent.Element, DslEditorModeling::DomainModelElement.GetSourceDomainRole(link.GetDomainRelationship()).Id); int indexOfLink = lllinks.IndexOf(link) + typeIndex; if (indexOfLink >= collection.Count) { collection.Add(c); } else { collection.Insert(indexOfLink, c); } }