示例#1
0
 internal override OperationResult UndoOperation()
 {
     /*
      * forbid undo in those cases where elements couldn't be ordered
      * in an ordering that would allow to put them back in the diagram
      * safely
      */
     if (CheckOrdering && !safeOrdering)
     {
         return(OperationResult.Failed);
     }
     foreach (Element element in DeletedElements)
     {
         if (IsInDiagram(element))
         {
             ErrorDescription = CommandError.CMDERR_REMOVED_ELEMENT_BEING_USED;
             return(OperationResult.Failed);
         }
     }
     foreach (Element element in _deletionOrder.Reverse())
     {
         if (DeletedElements.Contains(element))
         {
             element.PutMeBackToModel();
             Diagram.AddModelElement(element, DeletedElementsViewHelpers[element]);
         }
     }
     return(OperationResult.OK);
 }
 internal override OperationResult UndoOperation()
 {
     (Diagram as PSMDiagram).Roots.Remove(PSMAssociation.Child as PSMClass);
     PSMAssociation.PutMeBackToModel();
     Diagram.AddModelElement(PSMAssociation, associationViewHelper);
     return(OperationResult.OK);
 }
示例#3
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);
        }
示例#4
0
        /// <summary>
        /// Executive function of a command
        /// </summary>
        /// <seealso cref="UndoOperation"/>
        internal override void CommandOperation()
        {
            oldValue = AssociationViewHelper.UseDiamond;
            Diagram.RemoveModelElement(Association);

            oldPoints = new Dictionary <int, List <rPoint> >();

            int i = 0;

            foreach (AssociationEndViewHelper endViewHelper in AssociationViewHelper.AssociationEndsViewHelpers)
            {
                oldPoints[i++] = new List <rPoint>(endViewHelper.Points);
                endViewHelper.Points.Clear();
            }

            if (!AssociationViewHelper.UseDiamond)
            {
                AssociationViewHelper.X = 0;
                AssociationViewHelper.Y = 0;
            }

            AssociationViewHelper.UseDiamond = !AssociationViewHelper.UseDiamond;
            Diagram.AddModelElement(Association, AssociationViewHelper);

            AssociatedElements.Add(Association);
        }
 public override void CommandOperation(object parameter)
 {
     ViewHelper = new AssociationClassViewHelper(Diagram, IncludedAssociationClass.Element)
     {
         X = X, Y = Y
     };
     Diagram.AddModelElement(IncludedAssociationClass.Element, ViewHelper);
 }
示例#6
0
 public override void CommandOperation(object parameter)
 {
     ViewHelper = new ClassViewHelper(Diagram)
     {
         X = X, Y = Y, Height = Height, Width = Width
     };
     Diagram.AddModelElement(IncludedClass.Element, ViewHelper);
 }
示例#7
0
 internal override void CommandOperation()
 {
     foreach (KeyValuePair <Element, ViewHelper> pair in IncludedElements)
     {
         Diagram.AddModelElement(pair.Key, pair.Value);
         AssociatedElements.Add(pair.Key);
     }
 }
示例#8
0
        internal override void CommandOperation()
        {
            Diagram.AddModelElement(IncludedElement.Element, ViewHelper);
            AssociatedElements.Add(IncludedElement.Element);

            if (IncludedElement.Element is PSMElement && Diagram is PSMDiagram)
            {
                (IncludedElement.Element as PSMElement).Diagram = Diagram as PSMDiagram;
            }
        }
        internal override void RedoOperation()
        {
            CreatedContainer.Element.PutMeBackToModel();
            Diagram.AddModelElement(CreatedContainer.Element, ViewHelper);

            foreach (PSMSubordinateComponent containedComponent in containedComponents)
            {
                Parent.Components.Remove(containedComponent);
                CreatedContainer.Element.Components.Add(containedComponent);
            }
        }
示例#10
0
 internal override OperationResult UndoOperation()
 {
     ComponentLeftOut.PutMeBackToModel();
     foreach (PSMSubordinateComponent component in movedComponents)
     {
         parent.Components.Remove(component);
         ComponentLeftOut.Components.Add(component);
     }
     Diagram.AddModelElement(ComponentLeftOut, viewHelper);
     return(OperationResult.OK);
 }
示例#11
0
        void AssociationEnds_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            Diagram    currentDiagram = Controller.DiagramController.Diagram;
            ViewHelper vh             = currentDiagram.DiagramElements[Controller.Association];

            currentDiagram.RemoveModelElement(Controller.Association);
            if (e.OldItems != null && e.OldItems.Count >= 0 && ViewHelper.UseDiamond)
            {
                ViewHelper.ForceUseDiamond = true;
            }
            currentDiagram.AddModelElement(Controller.Association, vh);
        }
示例#12
0
        internal override void RedoOperation()
        {
            CreatedContainer.Element.PutMeBackToModel();
            Diagram.AddModelElement(CreatedContainer.Element, ViewHelper);

            foreach (PSMAttribute attribute in psmAttributes)
            {
                //PSMAttribute containerAttribute = psmAttributeContainer.AddAttribute(attribute.RepresentedAttribute);
                //containerAttribute.Alias = attribute.Alias;
                PSMClass.PSMAttributes.Remove(attribute);
                //CreatedContainer.Element.PSMAttributes.Add(attribute);
            }
        }
示例#13
0
 internal override OperationResult UndoOperation()
 {
     if (parentClass != null)
     {
         foreach (PSMAttribute attribute in returnedAttributes)
         {
             parentClass.Attributes.Remove(attribute);
         }
     }
     AttributeContainerLeftOut.PutMeBackToModel();
     Diagram.AddModelElement(AttributeContainerLeftOut, viewHelper);
     return(OperationResult.OK);
 }
示例#14
0
 internal override OperationResult UndoOperation()
 {
     foreach (Element element in DeletedElements)
     {
         if (IsInDiagram(element))
         {
             ErrorDescription = CommandError.CMDERR_REMOVED_ELEMENT_BEING_USED;
             return(OperationResult.Failed);
         }
     }
     foreach (Element element in DeletedElements)
     {
         Diagram.AddModelElement(element, DeletedElementsViewHelpers[element]);
     }
     return(OperationResult.OK);
 }
        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));
        }
示例#16
0
        /// <summary>
        /// Undo executive function of a command. Should revert the <see cref="CommandOperation"/> executive
        /// function and return the state to the state before CommandOperation was execute.
        /// <returns>returns <see cref="CommandBase.OperationResult.OK"/> if operation succeeded, <see cref="CommandBase.OperationResult.Failed"/> otherwise</returns>
        /// </summary>
        /// <remarks>
        /// <para>If  <see cref="CommandBase.OperationResult.Failed"/> is returned, whole undo stack is invalidated</para>
        /// </remarks>
        internal override OperationResult UndoOperation()
        {
            Diagram.RemoveModelElement(Association);

            int i = 0;

            foreach (AssociationEndViewHelper endViewHelper in AssociationViewHelper.AssociationEndsViewHelpers)
            {
                endViewHelper.Points.Clear();
                endViewHelper.Points.AppendRange(oldPoints[i++]);
            }

            AssociationViewHelper.UseDiamond = oldValue;
            Diagram.AddModelElement(Association, AssociationViewHelper);

            return(OperationResult.OK);
        }
示例#17
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);
        }
示例#18
0
        internal override void CommandOperation()
        {
            if (CreatedDiagramReference == null)
            {
                CreatedDiagramReference = new ElementHolder <PSMDiagramReference>();
            }

            PSMDiagramReference reference = new PSMDiagramReference()
            {
                ReferencedDiagram  = ReferencedDiagram,
                ReferencingDiagram = (PSMDiagram)this.Diagram,
                Name           = ReferencedDiagram.Caption,
                Local          = true,
                SchemaLocation = ReferencedDiagram.Caption + ".xsd"
            };

            CreatedDiagramReference.Element = reference;

            Debug.Assert(CreatedDiagramReference.HasValue);
            Diagram.AddModelElement(reference, ViewHelper);
            AssociatedElements.Add(reference);
        }
示例#19
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));
        }
示例#20
0
 internal override void RedoOperation()
 {
     CreatedDiagramReference.Element.PutMeBackToModel();
     Diagram.AddModelElement(CreatedDiagramReference.Element, ViewHelper);
 }
示例#21
0
 public override void CommandOperation(object parameter)
 {
     ViewHelper = new GeneralizationViewHelper(Diagram, IncludedGeneralization.Element);
     Diagram.AddModelElement(IncludedGeneralization.Element, ViewHelper);
 }