/// <summary> /// Creates the view model for the given link shape. /// </summary> /// <param name="nodeShapeType">Shape type for which the view model is to be created.</param> /// <param name="diagram">Diagram surface vm.</param> /// <param name="nodeShape">Link shape.</param> /// <returns> /// View model of type BaseDiagramItemLinkViewModel if a view model can be created for the given element. Null otherwise.</returns> public override DslEditorViewModel.DiagramSurface.BaseDiagramItemLinkViewModel CreateDiagramLinkViewModel(System.Guid nodeShapeType, DslEditorViewDiagrams::DiagramSurfaceViewModel diagram, DslEditorDiagrams::LinkShape nodeShape) { if( nodeShapeType == global::Tum.FamilyTreeDSL.ParentOfShape.DomainClassId ) return new Tum.FamilyTreeDSL.ViewModel.ParentOfShapeDiagramItemLinkViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.FamilyTreeDSL.MarriedToShape.DomainClassId ) return new Tum.FamilyTreeDSL.ViewModel.MarriedToShapeDiagramItemLinkViewModel(this.Store, diagram, nodeShape); return null; }
/// <summary> /// Creates the view model for the given node shape. /// </summary> /// <param name="nodeShapeType">Shape type for which the view model is to be created.</param> /// <param name="diagram">Diagram surface vm.</param> /// <param name="nodeShape">Node shape.</param> /// <returns> /// View model of type DiagramItemElementViewModel if a view model can be created for the given element. Null otherwise. /// </returns> public override DslEditorViewModel.DiagramSurface.DiagramItemElementViewModel CreateDiagramItemViewModel(System.Guid nodeShapeType, DslEditorViewDiagrams::DiagramSurfaceViewModel diagram, DslEditorDiagrams::NodeShape nodeShape) { if( nodeShapeType == global::Tum.FamilyTreeDSL.PersonShape.DomainClassId ) return new Tum.FamilyTreeDSL.ViewModel.PersonShapeDiagramItemViewModel(this.Store, diagram, nodeShape); return null; }
/// <summary> /// Creates the view model for the given node shape. /// </summary> /// <param name="nodeShapeType">Shape type for which the view model is to be created.</param> /// <param name="diagram">Diagram surface vm.</param> /// <param name="nodeShape">Node shape.</param> /// <returns> /// View model of type DiagramItemElementViewModel if a view model can be created for the given element. Null otherwise. /// </returns> public override DslEditorViewModel.DiagramSurface.DiagramItemElementViewModel CreateDiagramItemViewModel(System.Guid nodeShapeType, DslEditorViewDiagrams::DiagramSurfaceViewModel diagram, DslEditorDiagrams::NodeShape nodeShape) { if( nodeShapeType == global::Tum.VModellXT.RolleDependencyShape.DomainClassId ) return new Tum.VModellXT.ViewModel.RolleDependencyShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.DisziplinDependencyShape.DomainClassId ) return new Tum.VModellXT.ViewModel.DisziplinDependencyShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.ErzAbhDependencyShape.DomainClassId ) return new Tum.VModellXT.ViewModel.ErzAbhDependencyShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.AblaufbausteinShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.AblaufbausteinShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.StartpunktShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.StartpunktShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.EndepunktShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.EndepunktShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.AblaufentscheidungspunktShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.AblaufentscheidungspunktShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.AblaufbausteinpunktShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.AblaufbausteinpunktShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.SplitShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.SplitShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.SplitEingangShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.SplitEingangShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.SplitAusgangShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.SplitAusgangShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.JoinShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.JoinShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.JoinEingangShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.JoinEingangShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.JoinAusgangShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.JoinAusgangShapeDiagramItemViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.AblaufbausteinspezifikationShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.AblaufbausteinspezifikationShapeDiagramItemViewModel(this.Store, diagram, nodeShape); return null; }
/// <summary> /// Creates the view model for the given link shape. /// </summary> /// <param name="nodeShapeType">Shape type for which the view model is to be created.</param> /// <param name="diagram">Diagram surface vm.</param> /// <param name="nodeShape">Link shape.</param> /// <returns> /// View model of type BaseDiagramItemLinkViewModel if a view model can be created for the given element. Null otherwise.</returns> public override DslEditorViewModel.DiagramSurface.BaseDiagramItemLinkViewModel CreateDiagramLinkViewModel(System.Guid nodeShapeType, DslEditorViewDiagrams::DiagramSurfaceViewModel diagram, DslEditorDiagrams::LinkShape nodeShape) { if( nodeShapeType == global::Tum.PDE.ModelingDSL.ReferenceShape.DomainClassId ) return new Tum.PDE.ModelingDSL.ViewModel.ReferenceShapeDiagramItemLinkViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.PDE.ModelingDSL.EmbeddingShape.DomainClassId ) return new Tum.PDE.ModelingDSL.ViewModel.EmbeddingShapeDiagramItemLinkViewModel(this.Store, diagram, nodeShape); return null; }
/// <summary> /// Creates a relationship based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <param name="shapeToCreate">Type of the relationship shape</param> public override void CreateRelationship(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info, System.Guid shapeToCreate) { if( shapeToCreate == global::Tum.StateMachineDSL.TransitionShape.DomainClassId) { using(DslModeling::Transaction transaction = this.Store.TransactionManager.BeginTransaction("Add global::Tum.VModellXT.Dynamik.UebergangShape ") ) { CreateRelationship<global::Tum.StateMachineDSL.Transition>(info.Source.ShapeElement.Element, info.Target.ShapeElement.Element); transaction.Commit(); } } foreach(DslEditorViewDiagrams::DiagramSurfaceViewModel vm in this.IncludedSurfaceViewModels) { vm.CreateRelationship(info, shapeToCreate); } }
/// <summary> /// Creates the view model for the given link shape. /// </summary> /// <param name="nodeShapeType">Shape type for which the view model is to be created.</param> /// <param name="diagram">Diagram surface vm.</param> /// <param name="nodeShape">Link shape.</param> /// <returns> /// View model of type BaseDiagramItemLinkViewModel if a view model can be created for the given element. Null otherwise.</returns> public override DslEditorViewModel.DiagramSurface.BaseDiagramItemLinkViewModel CreateDiagramLinkViewModel(System.Guid nodeShapeType, DslEditorViewDiagrams::DiagramSurfaceViewModel diagram, DslEditorDiagrams::LinkShape nodeShape) { if( nodeShapeType == global::Tum.VModellXT.Dynamik.AblaufbausteinpunktRAblaufbausteinspezShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.AblaufbausteinpunktRAblaufbausteinspezShapeDiagramItemLinkViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.AblaufbausteinRAblaufbausteinspezShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.AblaufbausteinRAblaufbausteinspezShapeDiagramItemLinkViewModel(this.Store, diagram, nodeShape); if( nodeShapeType == global::Tum.VModellXT.Dynamik.UebergangShape.DomainClassId ) return new Tum.VModellXT.Dynamik.ViewModel.UebergangShapeDiagramItemLinkViewModel(this.Store, diagram, nodeShape); return null; }
/// <summary> /// Verifies if a relationship shape of type EmbeddingShape can be created based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <returns>True if a relationship can be created. False otherwise.</returns> protected virtual bool CanCreateRelationshipShapeEmbeddingShape(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { if( info.Source.Element is global::Tum.PDE.ModelingDSL.EmbeddableElement && info.Target.Element is global::Tum.PDE.ModelingDSL.EmbeddableElement ) { // see if a relationship already exists (can not create new one of the same type as no duplicates are allowed) if( global::Tum.PDE.ModelingDSL.EmbeddingRelationship.GetLinks(info.Source.Element as global::Tum.PDE.ModelingDSL.EmbeddableElement, info.Target.Element as global::Tum.PDE.ModelingDSL.EmbeddableElement).Count > 0 ) return false; return true; } return false; }
/// <summary> /// Creates a relationship based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <param name="shapeToCreate">Type of the relationship shape</param> public override void CreateRelationship(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info, System.Guid shapeToCreate) { foreach(DslEditorViewDiagrams::DiagramSurfaceViewModel vm in this.IncludedSurfaceViewModels) { vm.CreateRelationship(info, shapeToCreate); } }
/// <summary> /// Creates the view model for the given link shape. /// </summary> /// <param name="nodeShapeType">Shape type for which the view model is to be created.</param> /// <param name="diagram">Diagram surface vm.</param> /// <param name="nodeShape">Link shape.</param> /// <returns> /// View model of type BaseDiagramItemLinkViewModel if a view model can be created for the given element. Null otherwise.</returns> public override DslEditorViewModel.DiagramSurface.BaseDiagramItemLinkViewModel CreateDiagramLinkViewModel(System.Guid nodeShapeType, DslEditorViewDiagrams::DiagramSurfaceViewModel diagram, DslEditorDiagrams::LinkShape nodeShape) { return null; }
/// <summary> /// Verifies if a relationship shape of type ReferenceShape can be created based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <returns>True if a relationship can be created. False otherwise.</returns> protected virtual bool CanCreateRelationshipShapeReferenceShape(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { if( info.Source.Element is global::Tum.PDE.ModelingDSL.ReferenceableElement && info.Target.Element is global::Tum.PDE.ModelingDSL.ReferenceableElement ) { return true; } return false; }
/// <summary> /// Gets creatable relationship shapes. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> public override System.Collections.Generic.List<DslEditorSelection::SearchRSType.SearchRSTypeStruct> GetCreatableRelationships(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { System.Collections.Generic.List<DslEditorSelection::SearchRSType.SearchRSTypeStruct> shapesPossible = base.GetCreatableRelationships(info); if( CanCreateRelationshipShapeParentOfShape(info) ) { shapesPossible.Add(new DslEditorSelection::SearchRSType.SearchRSTypeStruct( global::Tum.FamilyTreeDSL.ParentOfShape.DomainClassId, "Parent Of", "Parent Of Shape")); } if( CanCreateRelationshipShapeMarriedToShape(info) ) { shapesPossible.Add(new DslEditorSelection::SearchRSType.SearchRSTypeStruct( global::Tum.FamilyTreeDSL.MarriedToShape.DomainClassId, "Married To", "Married To Shape")); } foreach(DslEditorViewDiagrams::DiagramSurfaceViewModel vm in this.IncludedSurfaceViewModels) { shapesPossible.AddRange(vm.GetCreatableRelationships(info)); } return shapesPossible; }
/// <summary> /// Verifies if a relationship shape of type MarriedToShape can be created based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <returns>True if a relationship can be created. False otherwise.</returns> protected virtual bool CanCreateRelationshipShapeMarriedToShape(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { if( info.Source.Element is global::Tum.FamilyTreeDSL.FamilyTreePerson && info.Target.Element is global::Tum.FamilyTreeDSL.FamilyTreePerson ) { System.Collections.ObjectModel.ReadOnlyCollection<global::Tum.FamilyTreeDSL.MarriedTo> allMMarriedToInstances1 = DslModeling::DomainRoleInfo.GetElementLinks<global::Tum.FamilyTreeDSL.MarriedTo>(info.Target.Element, global::Tum.FamilyTreeDSL.MarriedTo.WifeDomainRoleId); if(allMMarriedToInstances1.Count > 0 ) return false; // see if a relationship already exists (can not create new one of the same type as no duplicates are allowed) if( global::Tum.FamilyTreeDSL.MarriedTo.GetLinks(info.Source.Element as global::Tum.FamilyTreeDSL.FamilyTreePerson, info.Target.Element as global::Tum.FamilyTreeDSL.FamilyTreePerson).Count > 0 ) return false; return true; } return false; }
/// <summary> /// Verifies if a relationship shape of type ParentOfShape can be created based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <returns>True if a relationship can be created. False otherwise.</returns> protected virtual bool CanCreateRelationshipShapeParentOfShape(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { if( info.Source.Element is global::Tum.FamilyTreeDSL.FamilyTreePerson && info.Target.Element is global::Tum.FamilyTreeDSL.FamilyTreePerson ) { // see if a relationship already exists (can not create new one of the same type as no duplicates are allowed) if( global::Tum.FamilyTreeDSL.ParentOf.GetLinks(info.Source.Element as global::Tum.FamilyTreeDSL.FamilyTreePerson, info.Target.Element as global::Tum.FamilyTreeDSL.FamilyTreePerson).Count > 0 ) return false; return true; } return false; }
/// <summary> /// Verifies if a relationship can be created based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <returns>True if a relationship can be created. False otherwise.</returns> public override bool CanCreateRelationship(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { if( info.Source == null || info.Target == null ) return false; if( info.Source.ShapeElement == null || info.Target.ShapeElement == null ) return false; if( info.Source.ShapeElement.Element == null || info.Target.ShapeElement.Element == null ) return false; if (!info.Source.ShapeElement.TakesPartInRelationship) return false; bool bCanCreate = false; if( !bCanCreate ) { foreach(DslEditorViewDiagrams::DiagramSurfaceViewModel vm in this.IncludedSurfaceViewModels) { if( vm.CanCreateRelationship(info) ) return true; } } return bCanCreate; }
/// <summary> /// Creates a relationship based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <param name="shapeToCreate">Type of the relationship shape</param> public override void CreateRelationship(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info, System.Guid shapeToCreate) { if( shapeToCreate == global::Tum.PDE.ModelingDSL.ReferenceShape.DomainClassId) { using(DslModeling::Transaction transaction = this.Store.TransactionManager.BeginTransaction("Add global::Tum.VModellXT.Dynamik.UebergangShape ") ) { CreateRelationship<global::Tum.PDE.ModelingDSL.ReferenceRelationship>(info.Source.ShapeElement.Element, info.Target.ShapeElement.Element); transaction.Commit(); } } if( shapeToCreate == global::Tum.PDE.ModelingDSL.EmbeddingShape.DomainClassId) { using(DslModeling::Transaction transaction = this.Store.TransactionManager.BeginTransaction("Add global::Tum.VModellXT.Dynamik.UebergangShape ") ) { System.Collections.ObjectModel.ReadOnlyCollection<global::Tum.PDE.ModelingDSL.EmbeddingRelationship> allInstances = DslModeling::DomainRoleInfo.GetElementLinks<global::Tum.PDE.ModelingDSL.EmbeddingRelationship>(info.Source.Element, global::Tum.PDE.ModelingDSL.EmbeddingRelationship.ChildDomainRoleId); if(allInstances.Count > 0 ) { allInstances[0].Delete(); } CreateRelationship<global::Tum.PDE.ModelingDSL.EmbeddingRelationship>(info.Source.ShapeElement.Element, info.Target.ShapeElement.Element); transaction.Commit(); } } foreach(DslEditorViewDiagrams::DiagramSurfaceViewModel vm in this.IncludedSurfaceViewModels) { vm.CreateRelationship(info, shapeToCreate); } }
/// <summary> /// Creates a relationship based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> public override void CreateRelationship(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { if( info.Source == null || info.Target == null ) return; if( info.Source.ShapeElement == null || info.Target.ShapeElement == null ) return; if( info.Source.ShapeElement.Element == null || info.Target.ShapeElement.Element == null ) return; if (!info.Source.ShapeElement.TakesPartInRelationship) return; // gather creatable shapes System.Collections.Generic.List<DslEditorSelection::SearchRSType.SearchRSTypeStruct> shapesPossible = this.GetCreatableRelationships(info); System.Guid shapeToCreate = System.Guid.Empty; if( shapesPossible.Count == 0 ) return; else if (shapesPossible.Count == 1) shapeToCreate = shapesPossible[0].DomainClassId; else { // let user choose what shape type he wants to create DslEditorSelection::SelectGenericViewModel<DslEditorSelection::SearchRSType.SearchRSTypeStruct> selectionViewModel = new DslEditorSelection.SelectGenericViewModel<DslEditorSelection::SearchRSType.SearchRSTypeStruct>( this.ViewModelStore, shapesPossible, new DslEditorSelection.GenericSearchDelegate<DslEditorSelection::SearchRSType.SearchRSTypeStruct>(DslEditorSelection::SearchRSType.Search), new DslEditorSelection.GenericSortDelegate<DslEditorSelection::SearchRSType.SearchRSTypeStruct>(DslEditorSelection::SearchRSType.Sort)); // show dialog bool? result = this.GlobalServiceProvider.Resolve<DslEditorServices::IUIVisualizerService>().ShowDialog("SelectRSTypePopup", selectionViewModel); if (result == true && selectionViewModel.SelectedElement != null) { shapeToCreate = selectionViewModel.SelectedElement.Value.DomainClassId; } selectionViewModel.Dispose(); System.GC.Collect(); } if( shapeToCreate == System.Guid.Empty ) return; this.CreateRelationship(info, shapeToCreate); }
/// <summary> /// Gets creatable relationship shapes. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> public override System.Collections.Generic.List<DslEditorSelection::SearchRSType.SearchRSTypeStruct> GetCreatableRelationships(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { System.Collections.Generic.List<DslEditorSelection::SearchRSType.SearchRSTypeStruct> shapesPossible = base.GetCreatableRelationships(info); if( CanCreateRelationshipShapeReferenceShape(info) ) { shapesPossible.Add(new DslEditorSelection::SearchRSType.SearchRSTypeStruct( global::Tum.PDE.ModelingDSL.ReferenceShape.DomainClassId, "Reference Relationship", "Reference Shape")); } if( CanCreateRelationshipShapeEmbeddingShape(info) ) { shapesPossible.Add(new DslEditorSelection::SearchRSType.SearchRSTypeStruct( global::Tum.PDE.ModelingDSL.EmbeddingShape.DomainClassId, "Embedding Relationship", "Embedding Shape")); } foreach(DslEditorViewDiagrams::DiagramSurfaceViewModel vm in this.IncludedSurfaceViewModels) { shapesPossible.AddRange(vm.GetCreatableRelationships(info)); } return shapesPossible; }
/// <summary> /// Gets creatable relationship shapes. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> public override System.Collections.Generic.List<DslEditorSelection::SearchRSType.SearchRSTypeStruct> GetCreatableRelationships(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { System.Collections.Generic.List<DslEditorSelection::SearchRSType.SearchRSTypeStruct> shapesPossible = base.GetCreatableRelationships(info); foreach(DslEditorViewDiagrams::DiagramSurfaceViewModel vm in this.IncludedSurfaceViewModels) { shapesPossible.AddRange(vm.GetCreatableRelationships(info)); } return shapesPossible; }
/// <summary> /// Verifies if a relationship shape of type TransitionShape can be created based on the given data. /// </summary> /// <param name="info">Info specifying the relationship to create.</param> /// <returns>True if a relationship can be created. False otherwise.</returns> protected virtual bool CanCreateRelationshipShapeTransitionShape(DslEditorViewDiagrams::ViewModelRelationshipCreationInfo info) { if( info.Source.Element is global::Tum.StateMachineDSL.StateBase && info.Target.Element is global::Tum.StateMachineDSL.StateBase ) { // see if a relationship already exists (can not create new one of the same type as no duplicates are allowed) if( global::Tum.StateMachineDSL.Transition.GetLinks(info.Source.Element as global::Tum.StateMachineDSL.StateBase, info.Target.Element as global::Tum.StateMachineDSL.StateBase).Count > 0 ) return false; return true; } return false; }