Ejemplo n.º 1
0
        internal override void CommandOperation()
        {
            if (CreatedContainer == null)
            {
                CreatedContainer = new Helpers.ElementHolder <PSMAttributeContainer>();
            }

            PSMAttributeContainer psmAttributeContainer;

            if (PSMSuper != null)
            {
                psmAttributeContainer = (PSMAttributeContainer)PSMSuper.AddComponent(PSMAttributeContainerFactory.Instance);
            }
            else
            {
                psmAttributeContainer = (PSMAttributeContainer)PSMClass.AddComponent(PSMAttributeContainerFactory.Instance);
            }

            foreach (PSMAttribute attribute in psmAttributes)
            {
                //PSMAttribute containerAttribute = psmAttributeContainer.AddAttribute(attribute.RepresentedAttribute);
                //containerAttribute.Alias = attribute.Alias;
                PSMClass.PSMAttributes.Remove(attribute);
                psmAttributeContainer.PSMAttributes.Add(attribute);
            }

            CreatedContainer.Element = psmAttributeContainer;

            Debug.Assert(CreatedContainer.HasValue);

            Diagram.AddModelElement(psmAttributeContainer, ViewHelper);
            AssociatedElements.Add(psmAttributeContainer);
        }
Ejemplo n.º 2
0
        /// <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;
        }
Ejemplo n.º 3
0
 internal override void CommandOperation()
 {
     if (CreatedPackage == null)
     {
         CreatedPackage = new ElementHolder <Package>();
     }
     CreatedPackage.Element = Package.AddNestedPackage();
     if (!String.IsNullOrEmpty(PackageName))
     {
         CreatedPackage.Element.Name = PackageName;
     }
     Debug.Assert(CreatedPackage.HasValue);
 }
Ejemplo n.º 4
0
        internal override void CommandOperation()
        {
            if (CreatedContainer == null)
            {
                CreatedContainer = new Helpers.ElementHolder <PSMContentContainer>();
            }

            PSMSubordinateComponent first = Parent.Components.FirstOrDefault(component => containedComponents.Contains(component));
            PSMContentContainer     psmContainer;

            if (Parent != null)
            {
                if (first == null)
                {
                    psmContainer = (PSMContentContainer)Parent.AddComponent(PSMContentContainerFactory.Instance);
                }
                else
                {
                    psmContainer = (PSMContentContainer)Parent.AddComponent(
                        PSMContentContainerFactory.Instance, Parent.Components.IndexOf(first));
                }
            }
            else //add as root
            {
                PSMDiagram          diagram          = (PSMDiagram)Diagram;
                PSMContentContainer contentContainer = (PSMContentContainer)PSMContentContainerFactory.Instance.Create(null, diagram.Project.Schema);
                contentContainer.Diagram = diagram;
                psmContainer             = contentContainer;
                diagram.Roots.Add(psmContainer);
            }
            psmContainer.Name = Name;

            CreatedContainer.Element = psmContainer;

            AssociatedElements.Add(psmContainer);

            foreach (PSMSubordinateComponent containedComponent in containedComponents)
            {
                oldIndexes[containedComponent] = containedComponent.ComponentIndex();
                Parent.Components.Remove(containedComponent);
                psmContainer.Components.Add(containedComponent);
            }

            Debug.Assert(CreatedContainer.HasValue);
            Diagram.AddModelElement(psmContainer, ViewHelper = new PSMElementViewHelper(Diagram));
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        internal override void CommandOperation()
        {
            if (CreatedChoice == null)
            {
                CreatedChoice = new Helpers.ElementHolder <PSMContentChoice>();
            }

            PSMSubordinateComponent first = Parent.Components.FirstOrDefault(component => containedComponents.Contains(component));
            PSMContentChoice        psmChoice;

            if (first == null)
            {
                psmChoice =
                    (PSMContentChoice)Parent.AddComponent(PSMContentChoiceFactory.Instance);
            }
            else
            {
                psmChoice =
                    (PSMContentChoice)Parent.AddComponent(PSMContentChoiceFactory.Instance, first.ComponentIndex());
            }

            psmChoice.Name = Name;

            CreatedChoice.Element = psmChoice;

            AssociatedElements.Add(psmChoice);

            foreach (PSMSubordinateComponent containedComponent in containedComponents)
            {
                oldIndexes[containedComponent] = containedComponent.ComponentIndex();
                Parent.Components.Remove(containedComponent);
                psmChoice.Components.Add(containedComponent);
            }

            Debug.Assert(CreatedChoice.HasValue);
            Diagram.AddModelElement(psmChoice, ViewHelper = new PSMElementViewHelper(Diagram));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Sets this command for use.
 /// </summary>
 /// <param name="sourceUnion">Reference to the source class union holder</param>
 /// <param name="targetUnion">Reference to the target class union holder</param>
 public void Set(Helpers.ElementHolder <PSMClassUnion> sourceUnion, Helpers.ElementHolder <PSMClassUnion> targetUnion)
 {
     SourceUnion = sourceUnion;
     TargetUnion = targetUnion;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Sets this command for use.
 /// </summary>
 /// <param name="targetAssociationHolder">References the holder of the target association</param>
 /// <param name="sourceAssociations">List of source associations</param>
 public void Set(Helpers.ElementHolder <PSMAssociation> targetAssociationHolder, List <PSMAssociation> sourceAssociations)
 {
     SourceAssociations = sourceAssociations;
     TargetAssociation  = targetAssociationHolder;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Sets this command for use.
 /// </summary>
 /// <param name="targetAssociation">References the target association</param>
 /// <param name="sourceAssociations">List of source associations</param>
 public void Set(PSMAssociation targetAssociation, List <PSMAssociation> sourceAssociations)
 {
     SourceAssociations        = sourceAssociations;
     TargetAssociation         = new Helpers.ElementHolder <PSMAssociation>();
     TargetAssociation.Element = targetAssociation;
 }
        /// <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);
        }
Ejemplo n.º 11
0
 public HolderConvertorCommand(ElementHolder <SourceElementType> sourceHolder, ElementHolder <TargetElementType> targetHolder)
 {
     Description  = CommandDescription.HOLDER_CONVERTOR;
     SourceHolder = sourceHolder;
     TargetHolder = targetHolder;
 }
Ejemplo n.º 12
0
        public void Set(IEnumerable <PSMAssociation> associations, Helpers.ElementHolder <PSMClassUnion> union)
        {
            Union = union;

            Associations = new List <PSMAssociation>(associations);
        }