예제 #1
0
        internal override void GenerateSubCommands()
        {
            PSMClass psmClass = Project.TranslateComponent <PSMClass>(ClassGuid);

            foreach (PSMAttribute a in psmClass.PSMAttributes)
            {
                cmdDeletePSMAttribute da = new cmdDeletePSMAttribute(Controller);
                da.Set(a);
                Commands.Add(da);
            }
            foreach (PSMAssociation a in psmClass.ChildPSMAssociations)
            {
                cmdDeletePSMAssociation da = new cmdDeletePSMAssociation(Controller);
                da.Set(a);
                Commands.Add(da);
            }
            foreach (PSMGeneralization g in psmClass.GeneralizationsAsGeneral)
            {
                acmdDeletePSMGeneralization dg = new acmdDeletePSMGeneralization(Controller, g);
                Commands.Add(dg);
            }
            if (psmClass.GeneralizationAsSpecific != null)
            {
                Commands.Add(new acmdDeletePSMGeneralization(Controller, psmClass.GeneralizationAsSpecific));
            }

            Commands.Add(new acmdRenameComponent(Controller, ClassGuid, ""));
            foreach (PSMClass representant in psmClass.Representants)
            {
                Commands.Add(new acmdSetRepresentedClass(Controller, representant, Guid.Empty));
            }
            Commands.Add(new acmdSetRepresentedClass(Controller, ClassGuid, Guid.Empty));
            Commands.Add(new acmdSetPSMClassInterpretation(Controller, ClassGuid, Guid.Empty));
            Commands.Add(new acmdDeletePSMClass(Controller, ClassGuid));
        }
예제 #2
0
        internal override void GenerateSubCommands()
        {
            PSMContentModel psmContentModel = Project.TranslateComponent <PSMContentModel>(ContentModelGuid);

            foreach (PSMAssociation a in psmContentModel.ChildPSMAssociations)
            {
                cmdDeletePSMAssociation da = new cmdDeletePSMAssociation(Controller);
                da.Set(a);
                Commands.Add(da);
            }

            Commands.Add(new acmdDeletePSMContentModel(Controller, ContentModelGuid));
        }
예제 #3
0
        internal override void GenerateSubCommands()
        {
            PSMClass psmClass = Project.TranslateComponent <PSMClass>(ClassGuid);

            if (psmClass.ParentAssociation != null)
            {
                cmdDeletePSMAssociation cmddelete = new cmdDeletePSMAssociation(Controller)
                {
                    Propagate = Propagate
                };
                cmddelete.Set(psmClass.ParentAssociation);
                Commands.Add(cmddelete);
            }
            cmdDeleteRootPSMClass c = new cmdDeleteRootPSMClass(Controller)
            {
                Propagate = Propagate
            };

            c.Set(ClassGuid);
            Commands.Add(c);
        }
예제 #4
0
        private bool ApplyAssociationChanges()
        {
            #region check for deleted associations

            foreach (PSMAssociation psmAssociation in psmClass.ChildPSMAssociations)
            {
                bool found = false;
                foreach (FakePSMAssociation fakeAssociation in fakeAssociations)
                {
                    if (fakeAssociation.SourceAssociation == psmAssociation && fakeAssociation.Checked)
                    {
                        found = true;
                        break;
                    }
                    else if (fakeAssociation.SourceAssociation == psmAssociation && !fakeAssociation.Checked)
                    {
                        fakeAssociation.SourceAssociation = null;
                    }
                }
                if (!found)
                {
                    MessageBoxResult result = ExolutioYesNoBox.Show("Cut or delete", string.Format("Click 'Yes' if you want to delete the association '{0}' with the whole subtree.\nClick 'No' if you want to delete the association and make the subtree a new tree. ", psmAssociation));
                    if (result == MessageBoxResult.No)
                    {
                        Exolutio.Controller.Commands.Complex.PSM.cmdDeletePSMAssociation deleteCommand = new Exolutio.Controller.Commands.Complex.PSM.cmdDeletePSMAssociation(controller);
                        deleteCommand.Set(psmAssociation);
                        controller.CreatedMacro.Commands.Add(deleteCommand);
                    }
                    else if (result == MessageBoxResult.Yes)
                    {
                        cmdDeletePSMAssociationRecursive deleteCommand = new cmdDeletePSMAssociationRecursive(controller);
                        deleteCommand.Set(psmAssociation);
                        controller.CreatedMacro.Commands.Add(deleteCommand);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }

            #endregion

            // check for changes and new associations
            var modified = from FakePSMAssociation a in fakeAssociations
                           where a.SourceAssociation != null && a.SomethingChanged()
                           select a;
            var added = from FakePSMAssociation a in fakeAssociations where a.SourceAssociation == null && a.Checked select a;

            #region editing exisiting association
            foreach (FakePSMAssociation modifiedAssociation in modified)
            {
                PSMAssociation sourceAssociation = modifiedAssociation.SourceAssociation;
                uint           lower;
                UnlimitedInt   upper;
                if (
                    !IHasCardinalityExt.ParseMultiplicityString(modifiedAssociation.Multiplicity, out lower,
                                                                out upper))
                {
                    error = true;
                    return(!error);
                }

                cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller);
                updateCommand.Set(sourceAssociation, modifiedAssociation.Name, lower, upper);
                updateCommand.InterpretedAssociation = modifiedAssociation.RepresentedPIMAssociation;
                controller.CreatedMacro.Commands.Add(updateCommand);
            }
            #endregion

            #region new association
            foreach (FakePSMAssociation addedAssociation in added)
            {
                uint         lower = 1;
                UnlimitedInt upper = 1;
                if (!String.IsNullOrEmpty(addedAssociation.Multiplicity))
                {
                    if (!IHasCardinalityExt.ParseMultiplicityString(addedAssociation.Multiplicity, out lower, out upper))
                    {
                        error = true;
                        return(!error);
                    }
                }

                if (addedAssociation.RepresentedPIMAssociation == null)
                {
                    cmdNewPSMClass createNewPSMClass = new cmdNewPSMClass(controller);
                    createNewPSMClass.SchemaGuid = psmClass.Schema;
                    createNewPSMClass.ClassGuid  = Guid.NewGuid();
                    controller.CreatedMacro.Commands.Add(createNewPSMClass);

                    cmdNewPSMAssociation createNewPSMAssociation = new cmdNewPSMAssociation(controller);
                    addedAssociation.AddedAssociationID     = Guid.NewGuid();
                    createNewPSMAssociation.AssociationGuid = addedAssociation.AddedAssociationID;
                    createNewPSMAssociation.Set(psmClass, createNewPSMClass.ClassGuid, psmClass.Schema);
                    controller.CreatedMacro.Commands.Add(createNewPSMAssociation);

                    cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller);
                    updateCommand.Set(createNewPSMAssociation.AssociationGuid, addedAssociation.Name, lower, upper);
                    controller.CreatedMacro.Commands.Add(updateCommand);
                }
                else
                {
                    //ExolutioMessageBox.Show("Creating new association", addedAssociation.Name, "");
                    cmdCreateNewPSMClassAsIntChild createNewPSMAssociation = new cmdCreateNewPSMClassAsIntChild(controller);
                    addedAssociation.AddedAssociationID = Guid.NewGuid();

                    if (addedAssociation.SourcePIMAssociationEnd == null)
                    {
                        foreach (PIMAssociationEnd otherEnd in addedAssociation.RepresentedPIMAssociation.PIMAssociationEnds)
                        {
                            if (otherEnd.PIMClass == psmClass.Interpretation)
                            {
                                continue;
                            }
                            addedAssociation.SourcePIMAssociationEnd = otherEnd;
                        }
                    }

                    createNewPSMAssociation.Set(psmClass, addedAssociation.SourcePIMAssociationEnd, Guid.Empty, addedAssociation.AddedAssociationID);
                    controller.CreatedMacro.Commands.Add(createNewPSMAssociation);

                    cmdUpdatePSMAssociation updateCommand = new cmdUpdatePSMAssociation(controller);
                    updateCommand.Set(addedAssociation.AddedAssociationID, addedAssociation.Name, lower, upper);
                    controller.CreatedMacro.Commands.Add(updateCommand);
                }
            }
            #endregion

            #region ordering

            {
                List <Guid> ordering = new List <Guid>();
                foreach (FakePSMAssociation association in fakeAssociations)
                {
                    if (association.SourceAssociation != null)
                    {
                        ordering.Add(association.SourceAssociation.ID);
                    }
                    else if (association.AddedAssociationID != Guid.Empty)
                    {
                        ordering.Add(association.AddedAssociationID);
                    }
                }

                cmdReorderComponents <PSMAssociation> reorderCommand = new cmdReorderComponents <PSMAssociation>(controller)
                {
                    ComponentGuids = ordering, OwnerCollection = psmClass.ChildPSMAssociations
                };
                controller.CreatedMacro.Commands.Add(reorderCommand);
            }

            #endregion

            return(!error);
        }