Ejemplo n.º 1
0
        public void InitializeCommand(PSMAttributeContainer attributeContainer, IEnumerable <PSMAttribute> attributes)
        {
            MoveAttributesFromAttributeContainerBackToClassCommand command = (MoveAttributesFromAttributeContainerBackToClassCommand)MoveAttributesFromAttributeContainerBackToClassCommandFactory.Factory().Create(Controller);

            command.AttributeContainer = attributeContainer;
            command.Attributes.AddRange(attributes);
            Commands.Add(command);

            if (attributeContainer.PSMAttributes.All(attribute => attributes.Contains(attribute)))
            {
                OkCancelDialog dialog = new OkCancelDialog();
                dialog.PrimaryContent      = "Attribute container is empty.";
                dialog.Title               = "Attribute container is empty";
                dialog.SecondaryContent    = "Attribute container is now empty. Do you wish to remove the container now? ";
                dialog.OkButtonContent     = "Delete";
                dialog.CancelButtonContent = "Leave";

                if (dialog.ShowDialog() == true)
                {
                    DeleteFromPSMDiagramCommand leavecommand = (DeleteFromPSMDiagramCommand)DeleteFromPSMDiagramCommandFactory.Factory().Create(Controller);
                    leavecommand.DeletedElements = new[] { attributeContainer };
                    Commands.Add(leavecommand);
                }
            }
        }
Ejemplo n.º 2
0
        public override Element Clone(Model targetModel, ElementCopiesMap createdCopies)
        {
            PSMSuperordinateComponent copyParent = (PSMSuperordinateComponent)createdCopies[Parent];
            PSMAttributeContainer     clone      = (PSMAttributeContainer)PSMAttributeContainerFactory.Instance.Create(copyParent, targetModel.Schema);

            return(clone);
        }
Ejemplo n.º 3
0
 protected override void TranslateAttributeContainer(PSMAttributeContainer attributeContainer, DataGeneratorContext context)
 {
     foreach (PSMAttribute attribute in attributeContainer.PSMAttributes)
     {
         TranslateComments(attributeContainer, context);
         TranslateAttributeAsElement(attribute, context);
     }
 }
Ejemplo n.º 4
0
        /// <summary>Moves attributes from class to an attribute container</summary>
        /// <param name="attributes">attributes to move</param>
        /// <param name="attributeContainer">target attribute container; if left to <c>null</c>, the attribute container is selected in a dialog</param>
        public void MoveAttributesToAttributeContainer(PSMAttributeContainer attributeContainer, params PSMAttribute[] attributes)
        {
            MoveAttributesFromClassToAttributeContainerMacroCommand c = (MoveAttributesFromClassToAttributeContainerMacroCommand)MoveAttributesFromClassToAttributeContainerMacroCommandFactory.Factory().Create(DiagramController);

            c.InitializeCommand(attributes, Class, null);
            if (c.Commands.Count > 0)
            {
                c.Execute();
            }
        }
Ejemplo n.º 5
0
        protected override void TranslateAttributeContainer(PSMAttributeContainer attributeContainer, ChangesDetectorContext context)
        {
            context.ScopeStack.Push(EChangeScope.AttributeContainer);
            context.CurrentPSMElement = attributeContainer;

            ChangesLookupManager.DetectLocalChanges(context);
            TranslateAttributes(attributeContainer, context);

            EChangeScope pop = context.ScopeStack.Pop();

            Debug.Assert(pop == EChangeScope.AttributeContainer);
        }
Ejemplo n.º 6
0
        public override void FillCopy(Element copyElement, Model targetModel, ElementCopiesMap createdCopies)
        {
            base.FillCopy(copyElement, targetModel, createdCopies);
            PSMAttributeContainer copyPSMAttributeContainer = (PSMAttributeContainer)copyElement;

            SubElementCopiesMap subElementCopiesMap = createdCopies.GetSubElementsList(this);

            foreach (PSMAttribute psmAttribute in PSMAttributes)
            {
                PSMAttribute copyAttribute = copyPSMAttributeContainer.AddAttribute();
                psmAttribute.FillCopy(copyAttribute, targetModel, createdCopies);
                subElementCopiesMap[psmAttribute] = copyAttribute;
            }

            if (Parent != null && createdCopies.ContainsKey(Parent))
            {
                PSMSuperordinateComponent copyParent = (PSMSuperordinateComponent)createdCopies[Parent];
                ((_ImplPSMSubordinateComponent)copyPSMAttributeContainer).Parent = copyParent;
                copyParent.Components.Add(copyPSMAttributeContainer);
            }
        }
Ejemplo n.º 7
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]);
        }
Ejemplo n.º 8
0
        private void ConvertPSMAttributeContainer(PSMAttributeContainer psmAttributeContainer, PSMElementViewHelper psmElementViewHelper)
        {
            if (psmAttributeContainer.PSMAttributes.Count > 0)
            {
                EvoX.Model.PSM.PSMClass evoxPSMClass;
                if (!TranslatedAlready(psmAttributeContainer, out evoxPSMClass))
                {
                    evoxPSMClass = new EvoX.Model.PSM.PSMClass(evoxProject, psmSchema, false);
                    translatedElements[psmAttributeContainer] = evoxPSMClass;
                }

                evoxPSMClass.Name = psmAttributeContainer.PSMClass.Name;

                if (psmAttributeContainer.PSMClass.RepresentedClass != null)
                {
                    evoxPSMClass.Interpretation = (EvoX.Model.PIM.PIMClass)translatedElements[psmAttributeContainer.PSMClass.RepresentedClass];
                }

                foreach (PSMAttribute attribute in psmAttributeContainer.PSMAttributes)
                {
                    ConvertPSMAttribute(evoxPSMClass, attribute, true);
                }
            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Translates the attribute container.
 /// </summary>
 /// <param name="attributeContainer">The attribute container.</param>
 /// <param name="context">The translation context.</param>
 protected virtual void TranslateAttributeContainer(PSMAttributeContainer attributeContainer, Context context)
 {
 }
Ejemplo n.º 10
0
        public void InitializeCommand(IEnumerable <PSMAttribute> attributes, PSMClass parentClass, PSMAttributeContainer attributeContainer)
        {
            if (attributes.Count() == 0)
            {
                return;
            }

            if (attributeContainer == null)
            {
                List <PSMAttributeContainer> candidates = new List <PSMAttributeContainer>();
                FindACRecursive(parentClass, candidates);

                bool createNew = false;
                if (candidates.Count() == 0)
                {
                    createNew = true;
                }
                else
                {
                    SelectItemsDialog d = new SelectItemsDialog();
                    d.Title           = "Select attribute container";
                    d.ShortMessage    = "Select attribute container";
                    d.LongMessage     = String.Empty;
                    d.UseRadioButtons = true;
                    ArrayList    _c     = new ArrayList(candidates.ToList());
                    const string _newAC = "<< new attribute container >>";
                    _c.Add(_newAC);
                    d.SetItems(_c);

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

                if (createNew)
                {
                    NewPSMAttributeContainerCommand createACcommand = (NewPSMAttributeContainerCommand)NewPSMAttributeContainerCommandFactory.Factory().Create(Controller);
                    createACcommand.PSMClass = parentClass;
                    createACcommand.PSMAttributes.AddRange(attributes);
                    Commands.Add(createACcommand);
                    return;
                }
            }
            else
            {
                AttributeContainer = attributeContainer;
            }

            if (AttributeContainer != null)
            {
                MoveAttributesFromClassToAttributeContainerCommand moveCommand =
                    (MoveAttributesFromClassToAttributeContainerCommand)
                    MoveAttributesFromClassToAttributeContainerCommandFactory.Factory().Create(Controller);
                moveCommand.AttributeContainer = AttributeContainer;
                moveCommand.Attributes.AddRange(attributes);
                Commands.Add(moveCommand);
            }
        }
Ejemplo n.º 11
0
        void GeneratePSM2(I_PSMHasChildren current)
        {
            foreach (I_PSMHasParent child in current.Children)
            {
                if (child is P_PSMClass)
                {
                    //UPDATE GUI: This is wrong, but better than crash due to detected deadlock:
                    X.l.Content = (++currentClassCount).ToString() + "/" + X.ClassesCount.ToString() + " PSM Classes";
                    X.p.Value   = currentClassCount;
                    if (currentClassCount % (Math.Min(25, X.ClassesCount / 10) + 1) == 0)
                    {
                        Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new ThreadStart(delegate { }));
                    }

                    P_PSMClass C        = child as P_PSMClass;
                    PSMClass   psmClass = tempPIMClass.DerivePSMClass();
                    C.Super              = psmClass;
                    psmClass.Name        = C.Name.Name;
                    psmClass.ElementName = C.ElementLabel;

                    ViewHelper v = new PSMElementViewHelper(DiagramController.Diagram)
                    {
                        X = 0, Y = 0, Height = double.NaN, Width = double.NaN
                    };
                    DiagramController.Diagram.AddModelElement(psmClass, v);
                    psmClass.Diagram = DiagramController.Diagram as PSMDiagram;

                    //Attributes
                    foreach (P_PSMAttribute A in C.Attributes)
                    {
                        Property At = (C.Super as PSMClass).AddAttribute();
                        At.Name  = A.Alias;
                        At.Lower = A.Lower;

                        /*if (Type != null && Type.Element != null)
                         *  createdAttribute.Type = Type.Element;*/
                        At.Upper   = A.Upper;
                        At.Default = A.DefaultValue;
                        (At as PSMAttribute).Alias = A.Alias;
                    }

                    if (current is P_PSMDiagram)
                    {
                        (DiagramController.Diagram as PSMDiagram).Roots.Add(psmClass);
                    }
                    else
                    {
                        if (C.ExtensionOf != null)
                        {
                            Generalization generalization = DiagramController.ModelController.Model.Schema.SetGeneralization((current as P_PSMClass).Super as PSMClass, C.Super as PSMClass);

                            DiagramController.Diagram.AddModelElement(generalization, new GeneralizationViewHelper(DiagramController.Diagram));
                        }
                        else
                        {
                            PSMAssociation PSMAssoc = (PSMAssociation)(current as P_PSMBase).Super.AddComponent(PSMAssociationFactory.Instance);
                            PSMAssoc.Child = psmClass;
                            PSMAssoc.Upper = C.MaxOccurs;
                            PSMAssoc.Lower = C.MinOccurs;

                            DiagramController.Diagram.AddModelElement(PSMAssoc, new PSMAssociationViewHelper(DiagramController.Diagram));
                            PSMAssoc.Diagram = DiagramController.Diagram as PSMDiagram;
                        }
                    }
                    GeneratePSM2(C);
                }
                else if (!(current is P_PSMDiagram) && child is P_PSMContentChoice)
                {
                    PSMContentChoice psmChoice = (PSMContentChoice)(current as P_PSMBase).Super.AddComponent(PSMContentChoiceFactory.Instance);
                    DiagramController.Diagram.AddModelElement(psmChoice, new PSMElementViewHelper(DiagramController.Diagram));
                    (child as P_PSMContentChoice).Super = psmChoice;

                    GeneratePSM2(child as P_PSMContentChoice);
                }
                else if (!(current is P_PSMDiagram) && child is P_PSMAttributeContainer)
                {
                    PSMClass owner = null;
                    PSMSuperordinateComponent PSMSuper = null;
                    PSMAttributeContainer     psmAttributeContainer = null;
                    if (current is P_PSMClass)
                    {
                        owner = (current as P_PSMClass).Super as PSMClass;
                    }
                    else if (current is P_PSMContentChoice)
                    {
                        PSMSuper = (current as P_PSMContentChoice).Super as PSMSuperordinateComponent;
                        owner    = (current as P_PSMContentChoice).P_PSMClass.Super as PSMClass;
                    }
                    else if (current is P_PSMContentContainer)
                    {
                        PSMSuper = (current as P_PSMContentContainer).Super as PSMSuperordinateComponent;
                        owner    = (current as P_PSMContentContainer).P_PSMClass.Super as PSMClass;
                    }
                    List <PSMAttribute> PSMAttributes = new List <PSMAttribute>();
                    foreach (P_PSMAttribute A in (child as P_PSMAttributeContainer).Attributes)
                    {
                        Property At = owner.AddAttribute();
                        At.Name  = A.Alias;
                        At.Lower = A.Lower;

                        /*if (Type != null && Type.Element != null)
                         *  createdAttribute.Type = Type.Element;*/
                        At.Upper   = A.Upper;
                        At.Default = A.DefaultValue;
                        (At as PSMAttribute).Alias = A.Alias;
                        PSMAttributes.Add(At as PSMAttribute);
                        owner.PSMAttributes.Remove(At as PSMAttribute);
                    }

                    if (PSMSuper != null)
                    {
                        psmAttributeContainer = (PSMAttributeContainer)PSMSuper.AddComponent(PSMAttributeContainerFactory.Instance);
                    }
                    else
                    {
                        psmAttributeContainer = (PSMAttributeContainer)owner.AddComponent(PSMAttributeContainerFactory.Instance);
                    }
                    foreach (PSMAttribute attribute in PSMAttributes)
                    {
                        psmAttributeContainer.PSMAttributes.Add(attribute);
                    }
                    DiagramController.Diagram.AddModelElement(psmAttributeContainer, new PSMElementViewHelper(DiagramController.Diagram));
                }
                else if ((current is P_PSMClass) && child is P_PSMComment)
                {
                    Comment C = (current as P_PSMClass).Super.AddComment(NameSuggestor <Comment> .SuggestUniqueName((current as P_PSMClass).Super.Comments, "Comment", comment => comment.Body));
                    C.Body = (child as P_PSMComment).text;
                    DiagramController.Diagram.AddModelElement(C, new CommentViewHelper(DiagramController.Diagram));
                }
                else if (!(current is P_PSMDiagram) && child is P_PSMContentContainer)
                {
                    P_PSMContentContainer CC = child as P_PSMContentContainer;

                    PSMContentContainer psmContainer = (PSMContentContainer)(current as P_PSMBase).Super.AddComponent(PSMContentContainerFactory.Instance);
                    psmContainer.Name = CC.ElementLabel;
                    CC.Super          = psmContainer;
                    DiagramController.Diagram.AddModelElement(psmContainer, new PSMElementViewHelper(DiagramController.Diagram));

                    GeneratePSM2(CC);
                }
            }
        }
Ejemplo n.º 12
0
 static void GetSubElements(List <PSMElement> OC, PSMAttributeContainer E)
 {
     OC.Add(E);
 }
Ejemplo n.º 13
0
 public PSM_AttributeContainerController(PSMAttributeContainer attributeContainer, DiagramController diagramController) :
     base(attributeContainer, diagramController)
 {
     controlsPSMAttributes = new ControlsPSMAttributes(AttributeContainer, DiagramController);
 }