public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMClassUnion classUnion)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMClassUnion classUnionOldVersion =
                (PSMClassUnion)classUnion.GetInVersion(v1);

            foreach (PSMAssociationChild associationChild in classUnionOldVersion.Components)
            {
                /* must not exist in new version, testing whether it disappeard from components of the new
                 * version is not enough. It could have been moved, but not deleted.
                 */
                if (associationChild.GetInVersion(v2) == null)
                {
                    ClassUnionComponentRemovedChange change =
                        new ClassUnionComponentRemovedChange(classUnion)
                    {
                        RemovedComponent = associationChild,
                        OldVersion       = v1,
                        NewVersion       = v2
                    };
                    result.Add(change);
                }
            }
            return(result);
        }
Esempio n. 2
0
        private void TranslateClassUnion(PSMClassUnion classUnion, DataGeneratorContext context)
        {
            PSMAssociationChild selectedPath = classUnion.Components.ChooseOneRandomly();

            TranslateComments(classUnion, context);
            TranslateAssociationChild(selectedPath, context);
        }
Esempio n. 3
0
        private void ConvertPSMAssociation(PSMAssociation psmAssociation, PSMAssociationViewHelper psmAssociationViewHelper)
        {
            EvoX.Model.PSM.PSMAssociation evoxPSMAssociation;
            if (!TranslatedAlready(psmAssociation, out evoxPSMAssociation))
            {
                PSMAssociationMember parent = (PSMAssociationMember)ElementRef(psmAssociation.Parent);
                PSMAssociationMember child  = (PSMAssociationMember)ElementRef(psmAssociation.Child);
                evoxPSMAssociation = new EvoX.Model.PSM.PSMAssociation(evoxProject, parent, child, psmSchema);
                associationOrder[evoxPSMAssociation] = psmAssociation.ComponentIndex();
                translatedElements[psmAssociation]   = evoxPSMAssociation;
            }

            PSMClass childPSMClass = psmAssociation.Child as PSMClass;

            if (childPSMClass != null && childPSMClass.HasElementLabel)
            {
                evoxPSMAssociation.Name = childPSMClass.ElementName;
            }
            else
            {
                evoxPSMAssociation.Name = null;
            }
            PSMClassUnion psmClassUnion = psmAssociation.Child as PSMClassUnion;

            if (psmClassUnion != null)
            {
                evoxPSMAssociation.Name = null;
            }

            evoxPSMAssociation.Lower = ConvertToUint(psmAssociation.Lower);
            evoxPSMAssociation.Upper = ConvertToUnlimitedInt(psmAssociation.Upper);
        }
Esempio n. 4
0
        /// <summary>
        /// Checks if the subtree starting in the given class union contains
        /// the given item.
        /// </summary>
        /// <param name="root">References the class union that is the root of searched subtree</param>
        /// <param name="item">References the item being searched</param>
        /// <returns>True if the item is present, false otherwise</returns>
        private static bool ClassUnionContains(PSMClassUnion root, object item)
        {
            if (root == item)
            {
                return(true);
            }

            foreach (PSMAssociationChild child in root.Components)
            {
                if (child == item)
                {
                    return(true);
                }
                if (child is PSMClass)
                {
                    if (SubtreeContains(child as PSMClass, item))
                    {
                        return(true);
                    }
                }
                else
                if (ClassUnionContains(child as PSMClassUnion, item))
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 5
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMClassUnion classUnion)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            {
                foreach (PSMAssociationChild associationChild in classUnion.Components)
                {
                    /* must not exist in old version, testing whether it is not among components of the old
                     * version is not enough. It could have been moved, but not created as new.
                     */
                    if (associationChild.GetInVersion(v1) == null)
                    {
                        ClassUnionComponentAddedChange change =
                            new ClassUnionComponentAddedChange(classUnion)
                        {
                            AddedComponent = associationChild,
                            OldVersion     = v1,
                            NewVersion     = v2
                        };
                        result.Add(change);
                    }
                }
            }

            return(result);
        }
Esempio n. 6
0
        public void MoveToClassUnion(PSMClassUnion classUnion)
        {
            MoveClassToClassUnionMacroCommand c = (MoveClassToClassUnionMacroCommand)MoveClassToClassUnionMacroCommandFactory.Factory().Create(DiagramController);

            c.InitializeCommand(new[] { PSMAssociation }, classUnion);
            if (c.Commands.Count > 0)
            {
                c.Execute();
            }
        }
        /// <summary>
        /// Sets this command for use.
        /// </summary>
        /// <param name="sourceUnion">Reference to the source class union</param>
        /// <param name="targetUnion">Reference to the target class union holder</param>
        public void Set(PSMClassUnion sourceUnion, Helpers.ElementHolder <PSMClassUnion> targetUnion)
        {
            if (SourceUnion == null)
            {
                SourceUnion = new Helpers.ElementHolder <PSMClassUnion>();
            }

            SourceUnion.Element = sourceUnion;
            TargetUnion         = targetUnion;
        }
Esempio n. 8
0
        private void ConvertPSMClassUnion(PSMClassUnion psmClassUnion, PSMElementViewHelper psmElementViewHelper)
        {
            PSMContentModel contentModel;

            if (!TranslatedAlready(psmClassUnion, out contentModel))
            {
                contentModel = new PSMContentModel(evoxProject, psmSchema, false);
                translatedElements[psmClassUnion] = contentModel;
            }

            contentModel.Type = PSMContentModelType.Choice;
        }
Esempio n. 9
0
        private void TranslateClassUnion(PSMClassUnion classUnion, ChangesDetectorContext context)
        {
            context.ScopeStack.Push(EChangeScope.ClassUnion);
            context.CurrentPSMElement = classUnion;

            ChangesLookupManager.DetectLocalChanges(context);

            foreach (PSMAssociationChild psmAssociationChild in classUnion.Components)
            {
                TranslateAssociationChild(psmAssociationChild, context);
            }

            EChangeScope pcu = context.ScopeStack.Pop();

            Debug.Assert(pcu == EChangeScope.ClassUnion);
        }
Esempio n. 10
0
 private void AddClassUnionDependencies(Element root, PSMClassUnion union)
 {
     foreach (PSMAssociationChild psmAssociationChild in union.Components)
     {
         AddDependency(root, psmAssociationChild);
         elementsToDo.Enqueue(new KeyValuePair <Element, Element>(root, psmAssociationChild));
     }
     if (union.ParentUnion != null)
     {
         AddDependency(root, union.ParentUnion);
         AddClassUnionDependencies(root, union.ParentUnion);
     }
     if (union.ParentAssociation != null)
     {
         AddDependency(root, union.ParentAssociation);
     }
 }
Esempio n. 11
0
        public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMClassUnion classUnion)
        {
            List <EvolutionChange> result = new List <EvolutionChange>();

            PSMClassUnion oldVersion = (PSMClassUnion)classUnion.GetInVersion(v1);
            PSMClassUnion newVersion = (PSMClassUnion)classUnion.GetInVersion(v2);

            if (newVersion != null && oldVersion != null &&
                oldVersion.ParentAssociation != newVersion.ParentAssociation.GetInVersion(v1))
            {
                result.Add(new ClassUnionMovedChange(classUnion)
                {
                    OldVersion = v1, NewVersion = v2
                });
            }

            return(result);
        }
Esempio n. 12
0
        internal override void CommandOperation()
        {
            if (CreatedUnion == null)
            {
                CreatedUnion = new Helpers.ElementHolder <PSMClassUnion>();
            }

            PSMClassUnion union = Parent.CreateClassUnion();

            if (Parent is PSMClassUnion)
            {
            }

            CreatedUnion.Element = union;

            Diagram.AddModelElement(union, ViewHelper = new PSMElementViewHelper(Diagram));
            AssociatedElements.Add(union);
        }
Esempio n. 13
0
        public void Set(PSMClassUnion classUnion, IEnumerable <PSMAssociation> associations)
        {
            AddedAssociations.AddRange(associations);
            ClassUnion = classUnion;

            ElementHolder <PSMAssociation> leadingAssociationHolder = new ElementHolder <PSMAssociation>(ClassUnion.ParentAssociation);
            ElementHolder <PSMClassUnion>  unionHolder = new ElementHolder <PSMClassUnion>(ClassUnion);

            CopyNestingJoinsCommand c3 = CopyNestingJoinsCommandFactory.Factory().Create(Controller.ModelController) as CopyNestingJoinsCommand;

            c3.Set(leadingAssociationHolder, AddedAssociations);
            this.Commands.Add(c3);

            /*GetClassUnionContentCommand c4 = GetClassUnionContentCommandFactory.Factory().Create(Controller.ModelController) as GetClassUnionContentCommand;
             * c4.Set(joinedAssociations, CreatedUnion);
             * Commands.Add(c4);*/

            DeleteFromPSMDiagramCommand delCommand = DeleteFromPSMDiagramCommandFactory.Factory().Create(Controller) as DeleteFromPSMDiagramCommand;

            delCommand.DeletedElements = new List <Element>(AddedAssociations.Cast <Element>());
            delCommand.CheckOrdering   = false;
            Commands.Add(delCommand);

            PutClassesToUnionCommand c4 = PutClassesToUnionCommandFactory.Factory().Create(Controller.ModelController) as PutClassesToUnionCommand;

            c4.Set(AddedAssociations, unionHolder);
            Commands.Add(c4);

            foreach (PSMAssociation assoc in AddedAssociations)
            {
                PSMClassUnion union = assoc.Child as PSMClassUnion;
                if (union != null)
                {
                    MoveClassUnionContentCommand moveCommand = MoveClassUnionContentCommandFactory.Factory().Create(Controller) as MoveClassUnionContentCommand;
                    moveCommand.Set(union, unionHolder);
                    Commands.Add(moveCommand);
                    DeleteFromPSMDiagramCommand delUnion = DeleteFromPSMDiagramCommandFactory.Factory().Create(Controller) as DeleteFromPSMDiagramCommand;
                    delUnion.DeletedElements = new List <Element>();
                    delUnion.DeletedElements.Add(union);
                    Commands.Add(delUnion);
                }
            }
        }
Esempio n. 14
0
        public string GetUnionTemplate(PSMClassUnion classUnion, bool forceCallable)
        {
            Dictionary <PSMElement, string> templateCollection = forceCallable ? forceCallableUnionTemplates : unionTemplates;

            if (templateCollection.ContainsKey(classUnion))
            {
                return(templateCollection[classUnion]);
            }
            else
            {
                string name = suggestNameFromXPath(classUnion) + UNION_SUFFIX;
                if (forceCallable)
                {
                    name += FORCE_CALLABLE_SUFFIX;
                }
                templateCollection[classUnion] = name;
                return(name);
            }
        }
Esempio n. 15
0
        public static IEnumerable <Element> GetChildrenOfElement(Element element)
        {
            PSMSuperordinateComponent superordinateComponent = element as PSMSuperordinateComponent;

            if (superordinateComponent != null && superordinateComponent.Components.Count > 0)
            {
                return(superordinateComponent.Components);
            }
            PSMClassUnion union = element as PSMClassUnion;

            if (union != null && union.Components.Count > 0)
            {
                return(union.Components);
            }
            PSMAssociation association = element as PSMAssociation;

            if (association != null)
            {
                return(new Element[] { association.Child });
            }

            PSMClass psmClass = element as PSMClass;

            if (psmClass != null)
            {
                if (psmClass.Specifications.Count > 0)
                {
                    return(psmClass.Specifications);
                }
            }

            Generalization generalization = element as Generalization;

            if (generalization != null)
            {
                return(new Element[] { generalization.Specific });
            }
            return(new Element[0]);
        }
Esempio n. 16
0
        public static Element GetFirstChildOfElement(Element element)
        {
            PSMSuperordinateComponent superordinateComponent = element as PSMSuperordinateComponent;

            if (superordinateComponent != null && superordinateComponent.Components.Count > 0)
            {
                return(superordinateComponent.Components[0]);
            }
            PSMClassUnion union = element as PSMClassUnion;

            if (union != null && union.Components.Count > 0)
            {
                return(union.Components[0]);
            }
            PSMAssociation association = element as PSMAssociation;

            if (association != null)
            {
                return(association.Child);
            }

            PSMClass psmClass = element as PSMClass;

            if (psmClass != null)
            {
                if (psmClass.Specifications.Count > 0)
                {
                    return(psmClass.Specifications.First());
                }
            }

            Generalization generalization = element as Generalization;

            if (generalization != null)
            {
                return(generalization.Specific);
            }
            return(null);
        }
Esempio n. 17
0
        public IEnumerable <PSMElement> GetChildNodes()
        {
            {
                PSMSuperordinateComponent cs = CurrentNode as PSMSuperordinateComponent;
                if (cs != null)
                {
                    //return cs.Components.Select(c => (c is PSMAssociation) ? (PSMElement)((PSMAssociation)c).Child : (PSMElement)c);
                    return(cs.Components.Cast <PSMElement>());
                }
            }

            {
                PSMClassUnion cu = CurrentNode as PSMClassUnion;
                if (cu != null)
                {
                    return(cu.Components.Cast <PSMElement>());
                }
            }

            {
                PSMAssociation a = CurrentNode as PSMAssociation;
                if (a != null)
                {
                    return(new PSMElement[] { a.Child });
                }
            }

            {
                PSMAttributeContainer ac = CurrentNode as PSMAttributeContainer;
                if (ac != null)
                {
                    return(ac.PSMAttributes.Cast <PSMElement>());
                }
            }

            return(new PSMElement[0]);
        }
Esempio n. 18
0
 public PSM_ClassUnionController(PSMClassUnion classUnion, DiagramController diagramController) :
     base(classUnion, diagramController)
 {
 }
Esempio n. 19
0
        public PSMElement GetParent()
        {
            PSMElement parent = null;

            {
                PSMClass cl = CurrentNode as PSMClass;
                if (cl != null)
                {
                    if (cl.ParentAssociation != null)
                    {
                        parent = cl.ParentAssociation.Parent;
                        return(parent);
                    }
                    if (cl.ParentUnion != null)
                    {
                        parent = cl.ParentUnion;
                        return(parent);
                    }
                    if (Diagram.Roots.Contains(cl))
                    {
                        return(null);
                    }
                    if (cl.Generalizations.Count > 0)
                    {
                        PSMTreeIterator tmp = new PSMTreeIterator((PSMClass)cl.Generalizations[0].General);
                        return(tmp.GetParent());
                    }
                }
            }

            {
                PSMSubordinateComponent cs = CurrentNode as PSMSubordinateComponent;
                if (cs != null)
                {
                    parent = cs.Parent;
                    return(parent);
                }
            }

            {
                PSMClassUnion cu = CurrentNode as PSMClassUnion;
                if (cu != null)
                {
                    parent = cu.ParentAssociation.Parent;
                    return(parent);
                }
            }

            {
                PSMAttribute ca = CurrentNode as PSMAttribute;
                if (ca != null)
                {
                    if (ca.AttributeContainer != null)
                    {
                        return(ca.AttributeContainer);
                    }
                    else
                    {
                        return(ca.Class);
                    }
                }
            }

            return(parent);
        }
Esempio n. 20
0
        /// <summary>
        /// Adds attributes under a node into <param name="attributeList"/> (when called for a superordinate component, attributes
        /// from all subordinate PSM classes without element labels are included in the result too)
        /// </summary>
        /// <param name="node">node where to search for attributes</param>
        /// <param name="firstCall">false value indicates recursive call</param>
        /// <param name="attributeList">list in which attributes are added</param>
        private static void GetAttributesUnderNode(PSMElement node, bool firstCall, ref List <NodeAttributeWrapper> attributeList)
        {
            if (!firstCall && node is PSMClass &&
                !((PSMClass)node).HasElementLabel &&
                ((PSMClass)node).IsStructuralRepresentative)
            {
                PSMClass representedClass = ((PSMClass)node).RepresentedPSMClass;
                attributeList.Add(new StructuralRepresentativeAttributes((PSMClass)node, representedClass));
            }

            {
                PSMClass psmClass = node as PSMClass;
                if (psmClass != null)
                {
                    if (firstCall || (!psmClass.HasElementLabel))
                    {
                        foreach (PSMAttribute psmAttribute in psmClass.PSMAttributes)
                        {
                            attributeList.Add(new SimpleNodeAttribute(psmAttribute));
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            if (node is PSMClass || (node is PSMContentContainer && firstCall))
            {
                foreach (PSMSubordinateComponent component in ((PSMSuperordinateComponent)node).Components)
                {
                    GetAttributesUnderNode(component, false, ref attributeList);
                }
            }

            if (node is PSMClassUnion)
            {
                //throw new NotImplementedException("Can't handle unions yet");
            }

            if (node is PSMContentChoice)
            {
                PSMContentChoice             contentChoice = (PSMContentChoice)node;
                PSMTreeIterator              it            = new PSMTreeIterator(contentChoice);
                List <ChoiceAttributeOption> options       = new List <ChoiceAttributeOption>();
                foreach (PSMElement childNode in it.GetChildNodes())
                {
                    List <NodeAttributeWrapper> choices = new List <NodeAttributeWrapper>();
                    GetAttributesUnderNode(childNode, false, ref choices);
                    if (choices.Count > 0)
                    {
                        ChoiceAttributeOption option = new ChoiceAttributeOption();
                        option.Items = choices;
                        options.Add(option);
                    }
                }
                if (options.Count > 0)
                {
                    ChoiceAttributes choiceAttributes = new ChoiceAttributes(contentChoice, options);
                    attributeList.Add(choiceAttributes);
                }
            }

            else if (node is PSMClassUnion)
            {
                PSMClassUnion   classUnion           = (PSMClassUnion)node;
                PSMTreeIterator it                   = new PSMTreeIterator(classUnion);
                List <ChoiceAttributeOption> options = new List <ChoiceAttributeOption>();
                foreach (PSMElement childNode in it.GetChildNodes())
                {
                    List <NodeAttributeWrapper> choices = new List <NodeAttributeWrapper>();
                    GetAttributesUnderNode(childNode, false, ref choices);
                    if (choices.Count > 0)
                    {
                        ChoiceAttributeOption option = new ChoiceAttributeOption();
                        option.Items = choices;
                        options.Add(option);
                    }
                }
                if (options.Count > 0)
                {
                    UnionAttributes choiceAttributes = new UnionAttributes(classUnion, options);
                    attributeList.Add(choiceAttributes);
                }
            }

            if (node is PSMAssociation)
            {
                GetAttributesUnderNode(((PSMAssociation)node).Child, false, ref attributeList);
            }
            return;
        }
Esempio n. 21
0
        public static void CheckDiagram(PSMDiagram diagram, out List <string> errors, out List <string> warnings)
        {
            errors   = new List <string>();
            warnings = new List <string>();

            #region diagram has roots

            if (diagram.Roots.Count == 0)
            {
                errors.Add(string.Format("Diagram has no roots. "));
            }

            #endregion

            #region diagram has global element

            if (diagram.Roots.Where(r => (r is PSMClass) && ((PSMClass)r).HasElementLabel).Count() == 0)
            {
                bool found = false;
                foreach (PSMSuperordinateComponent superordinate in diagram.Roots)
                {
                    if (superordinate is PSMContentContainer)
                    {
                        found = true;
                        break;
                    }
                    else
                    {
                        PSMClass c = superordinate as PSMClass;
                        if (c != null)
                        {
                            if (GetSpecificiationsRecursive(c).Any(s => s.HasElementLabel))
                            {
                                found = true;
                            }
                        }
                    }
                }

                if (!found)
                {
                    warnings.Add(string.Format("Diagram has no root with an element label, no global element is declared. "));
                }
            }

            #endregion

            #region not zero or only one component in choice

            foreach (Element element in diagram.DiagramElements.Keys)
            {
                {
                    PSMContentChoice cc = element as PSMContentChoice;
                    if (cc != null && cc.Components.Count == 1)
                    {
                        warnings.Add(string.Format("Only one component in {0}. ", cc));
                    }
                    if (cc != null && cc.Components.Count == 0)
                    {
                        warnings.Add(string.Format("Zero components in {0}. ", cc));
                    }
                }

                {
                    PSMClassUnion cu = element as PSMClassUnion;
                    if (cu != null && cu.Components.Count == 1)
                    {
                        warnings.Add(string.Format("Only one component in {0}. ", cu));
                    }
                    if (cu != null && cu.Components.Count == 0)
                    {
                        warnings.Add(string.Format("Zero components in {0}. ", cu));
                    }
                }
            }

            #endregion
        }
Esempio n. 22
0
 public bool ForceCallableUnionTemplateExists(PSMClassUnion classUnion)
 {
     return(forceCallableUnionTemplates.ContainsKey(classUnion));
 }
Esempio n. 23
0
        /// <summary>
        /// Draws all children of given root element and counts width of its subtree.
        /// </summary>
        /// <param name="diagram">Diagram to be layouted</param>
        /// <param name="root">Root element of layouted subtree</param>
        /// <param name="top">Location of the upper border of the root's children</param>
        /// <param name="left">Location of the left border of the entire subtree</param>
        /// <returns>Width of the subtree (root not included)</returns>
        private static double DrawSubtree(XCaseCanvas diagram, NamedElement root, double top, double left)
        {
            double right = left;

            if (root is PSMSuperordinateComponent)
            {
                PSMSuperordinateComponent aClass = root as PSMSuperordinateComponent;
                NamedElement child = null;
                if (aClass.Components.Count > 0)
                {
                    foreach (PSMSubordinateComponent component in aClass.Components)
                    {
                        if (component is PSMAssociation)
                        {
                            child = (component as PSMAssociation).Child;
                        }
                        else
                        {
                            if (component is PSMAttributeContainer)
                            {
                                child = component as PSMAttributeContainer;
                            }
                            else
                            {
                                if (component is PSMContentChoice || component is PSMContentContainer)
                                {
                                    child = component as PSMSuperordinateComponent;
                                }
                            }
                        }
                        if (child != null)
                        {
                            right += DrawTree(diagram, child, top, right) + horizontalSpace;
                        }
                        child = null;
                    }
                }
                if (aClass is PSMClass && (aClass as PSMClass).Specifications.Count > 0)
                {
                    foreach (Generalization specification in (aClass as PSMClass).Specifications)
                    {
                        right += DrawTree(diagram, specification.Specific, top, right) + horizontalSpace;
                    }
                }
                if (right != left)
                {
                    right -= horizontalSpace;
                }
            }
            else
            {
                if (root is PSMClassUnion)
                {
                    PSMClassUnion classUnion = root as PSMClassUnion;
                    if (classUnion.Components.Count > 0)
                    {
                        foreach (PSMAssociationChild component in classUnion.Components)
                        {
                            right += DrawTree(diagram, component, top, right) + horizontalSpace;
                        }
                        right = right - horizontalSpace;
                    }
                }
            }
            return(right - left);
        }
        public void InitializeCommand(IEnumerable <PSMAssociation> associations, PSMClassUnion container)
        {
            if (associations.Count() == 0)
            {
                return;
            }

            if (container == null)
            {
                PSMSuperordinateComponent parentClass;
                if (!PSMTree.AreComponentsOfCommonParent(associations))
                {
                    return;
                }
                parentClass = associations.First().Parent;

                List <PSMClassUnion> candidates = new List <PSMClassUnion>();
                FindCURecursive(parentClass, candidates);

                bool createNew = false;

                SelectItemsDialog d = new SelectItemsDialog();
                d.Title           = "Select class union";
                d.ShortMessage    = "Select class union";
                d.LongMessage     = String.Empty;
                d.UseRadioButtons = true;
                ArrayList    _c     = new ArrayList(candidates.ToList());
                const string _newAC = "<< new class union >>";
                _c.Add(_newAC);
                d.SetItems(_c);

                if (d.ShowDialog() == true)
                {
                    if (d.selectedObjects.FirstOrDefault().Equals(_newAC))
                    {
                        createNew = true;
                    }
                    else
                    {
                        ClassUnion = d.selectedObjects.FirstOrDefault() as PSMClassUnion;
                    }
                }

                if (createNew)
                {
                    JoinAssociationsToClassUnionMacroCommand createCUcommand =
                        (JoinAssociationsToClassUnionMacroCommand)
                        JoinAssociationsToClassUnionMacroCommandFactory.Factory().Create(Controller);
                    createCUcommand.Set(parentClass, associations);

                    Commands.Add(createCUcommand);
                    return;
                }
            }
            else
            {
                ClassUnion = container;
            }

            if (ClassUnion != null)
            {
                MoveClassToExistingClassUnionMacroCommand moveCommand =
                    (MoveClassToExistingClassUnionMacroCommand)
                    MoveClassToExistingClassUnionMacroCommandFactory.Factory().Create(Controller);
                moveCommand.Set(ClassUnion, associations);
                Commands.Add(moveCommand);
            }
        }
        /// <summary>
        /// Sets this command for use.
        /// </summary>
        /// <param name="parent">Reference to the PSM component that is the root of joined associations</param>
        /// <param name="joinedAssociations">List of associations to be joined to one class union</param>
        public void Set(PSMSuperordinateComponent parent, IEnumerable <PSMAssociation> joinedAssociations)
        {
            JoinedAssociations = new List <PSMAssociation>(joinedAssociations);

            PSMSubordinateComponent first = parent.Components.First(assoc => JoinedAssociations.Contains(assoc as PSMAssociation));
            int?index = parent.Components.IndexOf(first);


            if (ParentHolder == null)
            {
                ParentHolder = new Helpers.ElementHolder <PSMSuperordinateComponent>();
            }
            ParentHolder.Element = parent;

            if (CreatedUnion == null)
            {
                CreatedUnion = new Helpers.ElementHolder <PSMClassUnion>();
            }

            if (CreatedAssocChild == null)
            {
                CreatedAssocChild = new Helpers.ElementHolder <PSMAssociationChild>();
            }

            if (CreatedAssociationHolder == null)
            {
                CreatedAssociationHolder = new Helpers.ElementHolder <PSMAssociation>();
            }

            NewPSMClassUnionCommand c1 = NewPSMClassUnionCommandFactory.Factory().Create(Controller) as NewPSMClassUnionCommand;

            c1.CreatedUnion = CreatedUnion;
            c1.Parent       = parent;
            Commands.Add(c1);

            Helpers.HolderConvertorCommand <PSMClassUnion, PSMAssociationChild> cc =
                new Commands.Helpers.HolderConvertorCommand <PSMClassUnion, PSMAssociationChild>(CreatedUnion,
                                                                                                 CreatedAssocChild);
            Commands.Add(cc);

            NewPSMAssociationCommand newAssocCommand = NewPSMAssociationCommandFactory.Factory().Create(Controller.ModelController) as NewPSMAssociationCommand;

            newAssocCommand.Set(ParentHolder, CreatedAssocChild, CreatedAssociationHolder, index);
            Commands.Add(newAssocCommand);

            CopyNestingJoinsCommand copyNJcommand = CopyNestingJoinsCommandFactory.Factory().Create(Controller.ModelController) as CopyNestingJoinsCommand;

            copyNJcommand.Set(CreatedAssociationHolder, JoinedAssociations);
            Commands.Add(copyNJcommand);

            /*GetClassUnionContentCommand c4 = GetClassUnionContentCommandFactory.Factory().Create(Controller.ModelController) as GetClassUnionContentCommand;
             * c4.Set(joinedAssociations, CreatedUnion);
             * Commands.Add(c4);*/

            PutClassesToUnionCommand putCommand = PutClassesToUnionCommandFactory.Factory().Create(Controller.ModelController) as PutClassesToUnionCommand;

            putCommand.Set(joinedAssociations, CreatedUnion);
            Commands.Add(putCommand);

            DeleteFromPSMDiagramCommand delCommand = DeleteFromPSMDiagramCommandFactory.Factory().Create(Controller) as DeleteFromPSMDiagramCommand;

            delCommand.DeletedElements = new List <Element>(JoinedAssociations.Cast <Element>());
            delCommand.CheckOrdering   = false;
            Commands.Add(delCommand);

            foreach (PSMAssociation assoc in joinedAssociations)
            {
                PSMClassUnion union = assoc.Child as PSMClassUnion;
                if (union != null)
                {
                    MoveClassUnionContentCommand moveCommand = MoveClassUnionContentCommandFactory.Factory().Create(Controller) as MoveClassUnionContentCommand;
                    moveCommand.Set(union, CreatedUnion);
                    Commands.Add(moveCommand);
                    DeleteFromPSMDiagramCommand delUnion = DeleteFromPSMDiagramCommandFactory.Factory().Create(Controller) as DeleteFromPSMDiagramCommand;
                    delUnion.DeletedElements = new List <Element>();
                    delUnion.DeletedElements.Add(union);
                    Commands.Add(delUnion);
                }
            }

            ElementToDiagramCommand <PSMAssociation, PSMAssociationViewHelper> includeAssociation = (ElementToDiagramCommand <PSMAssociation, PSMAssociationViewHelper>) ElementToDiagramCommandFactory <PSMAssociation, PSMAssociationViewHelper> .Factory().Create(Controller);

            includeAssociation.IncludedElement = CreatedAssociationHolder;
            Commands.Add(includeAssociation);
        }
Esempio n. 26
0
 protected ClassUnionChange(PSMClassUnion classUnion)
 {
     Element = classUnion;
 }
Esempio n. 27
0
 public ClassUnionMovedChange(PSMClassUnion classUnion)
     : base(classUnion)
 {
 }
Esempio n. 28
0
 public ClassUnionComponentAddedChange(PSMClassUnion classUnion)
     : base(classUnion)
 {
 }