public void Set(PIMClass RepresentedClass) { PSMClassHolder = new ElementHolder <PSMClass>(); NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller.ModelController) as NewPSMClassCommand; c1.RepresentedClass = RepresentedClass; c1.CreatedClass = PSMClassHolder; Commands.Add(c1); ElementToDiagramCommand <PSMClass, PSMElementViewHelper> c2 = ElementToDiagramCommandFactory <PSMClass, PSMElementViewHelper> .Factory().Create(Controller) as ElementToDiagramCommand <PSMClass, PSMElementViewHelper>; c2.IncludedElement = PSMClassHolder; Commands.Add(c2); AddPSMClassToRootsCommand c3 = AddPSMClassToRootsCommandFactory.Factory().Create(Controller) as AddPSMClassToRootsCommand; c3.Set(PSMClassHolder); Commands.Add(c3); }
/// <summary> /// Sets this command for execution /// </summary> /// <param name="c">PIMClass to be derived from</param> /// <param name="d">Diagram to which to add the PSM Class as one of roots</param> /// <param name="h">Optional Element holder where the final PSMClass will be placed</param> public void Set(PIMClass c, PSMDiagram d, ElementHolder <PSMClass> h) { Class = c; HolderBase <PSMDiagram> DiagramHolder = new HolderBase <PSMDiagram>() { Element = d }; if (h != null) { pSMClassHolder = h; } else { pSMClassHolder = new ElementHolder <PSMClass>(); } NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller) as NewPSMClassCommand; c1.RepresentedClass = Class; c1.CreatedClass = pSMClassHolder; Commands.Add(c1); PSMClassToDiagram_ModelCommand c3 = PSMClassToDiagram_ModelCommandFactory.Factory().Create(Controller) as PSMClassToDiagram_ModelCommand; c3.Set(pSMClassHolder, DiagramHolder); Commands.Add(c3); AddPSMClassToRoots_ModelCommand c4 = AddPSMClassToRoots_ModelCommandFactory.Factory().Create(Controller) as AddPSMClassToRoots_ModelCommand; c4.Set(pSMClassHolder, DiagramHolder); Commands.Add(c4); ActivateDiagramCommand c5 = ActivateDiagramCommandFactory.Factory().Create(Controller) as ActivateDiagramCommand; c5.Set(d); Commands.Add(c5); }
/// <summary> /// Sets this command for execution /// </summary> /// <param name="c">PIMClass to be derived from</param> /// <param name="h">Optional Element holder where the final PSMClass will be placed</param> public void Set(PIMClass c, ElementHolder <PSMClass> h) { Class = c; if (h != null) { pSMClassHolder = h; } else { pSMClassHolder = new ElementHolder <PSMClass>(); } NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller) as NewPSMClassCommand; c1.RepresentedClass = Class; c1.CreatedClass = pSMClassHolder; Commands.Add(c1); AddPSMDiagramCommand c2 = AddPSMDiagramCommandFactory.Factory().Create(Controller) as AddPSMDiagramCommand; if (DiagramHolder == null) { DiagramHolder = new HolderBase <PSMDiagram>(); } c2.Set(Controller.Project, DiagramHolder); Commands.Add(c2); PSMClassToDiagram_ModelCommand c3 = PSMClassToDiagram_ModelCommandFactory.Factory().Create(Controller) as PSMClassToDiagram_ModelCommand; c3.Set(pSMClassHolder, DiagramHolder); Commands.Add(c3); AddPSMClassToRoots_ModelCommand c4 = AddPSMClassToRoots_ModelCommandFactory.Factory().Create(Controller) as AddPSMClassToRoots_ModelCommand; c4.Set(pSMClassHolder, DiagramHolder); Commands.Add(c4); }
public void Set(PSMClass generalPSMClass, PIMClass specificPIMClass) { if (CreatedSpecificPSMClass == null) { CreatedSpecificPSMClass = new ElementHolder <PSMClass>(); } if (CreatedGeneralization == null) { CreatedGeneralization = new ElementHolder <Generalization>(); } NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller.ModelController) as NewPSMClassCommand; c1.RepresentedClass = specificPIMClass; c1.CreatedClass = CreatedSpecificPSMClass; Commands.Add(c1); NewPSMSpecializationCommand c2 = NewPSMSpecializationCommandFactory.Factory().Create(Controller.ModelController) as NewPSMSpecializationCommand; c2.GeneralPSMClass = new ElementHolder <PSMClass>() { Element = generalPSMClass }; c2.SpecificPSMClass = CreatedSpecificPSMClass; c2.CreatedGeneralization = CreatedGeneralization; Commands.Add(c2); ElementToDiagramCommand <PSMClass, PSMElementViewHelper> c3 = ElementToDiagramCommandFactory <PSMClass, PSMElementViewHelper> .Factory().Create(Controller) as ElementToDiagramCommand <PSMClass, PSMElementViewHelper>; c3.IncludedElement = CreatedSpecificPSMClass; Commands.Add(c3); ElementToDiagramCommand <Generalization, GeneralizationViewHelper> c4 = ElementToDiagramCommandFactory <Generalization, GeneralizationViewHelper> .Factory().Create(Controller) as ElementToDiagramCommand <Generalization, GeneralizationViewHelper>; c4.IncludedElement = CreatedGeneralization; Commands.Add(c4); }
/// <summary> /// Processes one selected TreeView item. Generates commands for addition of PSMClasses, PSMStructuralRepresentatives and PSMAssociations /// </summary> /// <param name="T">The item to be processed</param> private void GenerateCommands(TreeClasses T) { #region Holders ElementHolder <PSMClass> Child = new ElementHolder <PSMClass>(); ElementHolder <PSMAssociationChild> ChildAssociation = new ElementHolder <PSMAssociationChild>(); ElementHolder <PSMAssociation> AssociationHolder = new ElementHolder <PSMAssociation>(); #endregion #region Create new element if (T.RootClass == null) { NewPSMClassCommand c1 = NewPSMClassCommandFactory.Factory().Create(Controller.ModelController) as NewPSMClassCommand; c1.RepresentedClass = T.PIMClass; c1.CreatedClass = Child; Commands.Add(c1); if (T.Represented != null) //Creating PSM Structural Representative { SetRepresentedPSMClassCommand c1a = SetRepresentedPSMClassCommandFactory.Factory().Create(Controller) as SetRepresentedPSMClassCommand; c1a.Set(T.Represented, Child); Commands.Add(c1a); } //Put the newly created PSMClass to the diagram ElementToDiagramCommand <PSMClass, PSMElementViewHelper> c2 = ElementToDiagramCommandFactory <PSMClass, PSMElementViewHelper> .Factory().Create(Controller) as ElementToDiagramCommand <PSMClass, PSMElementViewHelper>; c2.IncludedElement = Child; Commands.Add(c2); } else //Connecting existing root { Child.Element = T.RootClass; RemovePSMClassFromRootsCommand c = RemovePSMClassFromRootsCommandFactory.Factory().Create(Controller) as RemovePSMClassFromRootsCommand; c.Set(Child); Commands.Add(c); } #endregion #region PSM Association #region Path generation //Prepare path for NestingJoin - Path from child to parent consisting of AssociationEnds (PIMSteps) List <NestingJoinStep> Path = new List <NestingJoinStep>(); uint?Lower = 1; NUml.Uml2.UnlimitedNatural Upper = 1; TreeClasses t = T; while (t.ParentTC != null) { Path.Add(new NestingJoinStep() { Association = t.Association, End = t.PIMClass, Start = t.ParentTC.PIMClass }); Lower *= t.Lower; if (t.Upper.IsInfinity) { Upper = NUml.Uml2.UnlimitedNatural.Infinity; } else if (!Upper.IsInfinity) { Upper = Upper.Value * t.Upper.Value; } t = t.ParentTC; } #endregion //Add PSMAssociation connecting the parent to the PSMClass Commands.Add(new HolderConvertorCommand <PSMClass, PSMAssociationChild>(Child, ChildAssociation)); NewPSMAssociationCommand c3 = NewPSMAssociationCommandFactory.Factory().Create(Controller.ModelController) as NewPSMAssociationCommand; c3.Set(new ElementHolder <PSMSuperordinateComponent>() { Element = SourcePSMClass }, ChildAssociation, AssociationHolder, null); //Set PSM association multiplicity c3.Upper = Upper; c3.Lower = Lower; c3.UsedGeneralizations = T.UsedGeneralizations; Commands.Add(c3); #endregion #region Nesting join //Set the nestingjoin AddSimpleNestingJoinCommand c4 = AddSimpleNestingJoinCommandFactory.Factory().Create(Controller.ModelController) as AddSimpleNestingJoinCommand; c4.Set(AssociationHolder, Path); Commands.Add(c4); #endregion #region Association to diagram //Add created PSMAssociations to the diagram ElementToDiagramCommand <PSMAssociation, PSMAssociationViewHelper> c5 = (ElementToDiagramCommand <PSMAssociation, PSMAssociationViewHelper>) ElementToDiagramCommandFactory <PSMAssociation, PSMAssociationViewHelper> .Factory().Create(Controller); c5.IncludedElement = AssociationHolder; Commands.Add(c5); #endregion }