Exemplo n.º 1
0
 /// <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);
     }
 }
Exemplo n.º 2
0
        /// <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);
            }
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
        /// <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);
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
        /// <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)
            {
                bCanCreate = CanCreateRelationshipShapeReferenceShape(info);
            }

            if (!bCanCreate)
            {
                bCanCreate = CanCreateRelationshipShapeEmbeddingShape(info);
            }

            if (!bCanCreate)
            {
                foreach (DslEditorViewDiagrams::DiagramSurfaceViewModel vm in this.IncludedSurfaceViewModels)
                {
                    if (vm.CanCreateRelationship(info))
                    {
                        return(true);
                    }
                }
            }

            return(bCanCreate);
        }
Exemplo n.º 8
0
        /// <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);
            }
        }
Exemplo n.º 9
0
        /// <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);
        }
Exemplo n.º 10
0
        /// <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);
        }
Exemplo n.º 11
0
        /// <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);
        }
Exemplo n.º 12
0
        /// <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);
        }
Exemplo n.º 13
0
        /// <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);
        }