public void MoveToContentContainer(PSMContentContainer contentContainer) { MoveSubordinateToSuperordinateMacroCommand <PSMContentContainer> c = (MoveSubordinateToSuperordinateMacroCommand <PSMContentContainer>) MoveSubordinateToSuperordinateMacroCommandFactory <PSMContentContainer> .Factory().Create(DiagramController); c.InitializeCommand(new [] { PSMAssociation }, contentContainer); if (c.Commands.Count > 0) { c.Execute(); } }
protected override void TranslateContentContainer(PSMContentContainer contentContainer, ChangesDetectorContext context) { context.ScopeStack.Push(EChangeScope.ContentContainer); context.CurrentPSMElement = contentContainer; ChangesLookupManager.DetectLocalChanges(context); TranslateComponents(contentContainer, context); EChangeScope pop = context.ScopeStack.Pop(); Debug.Assert(pop == EChangeScope.ContentContainer); }
private void ConvertPSMContentContainer(PSMContentContainer psmContentContainer, PSMElementViewHelper psmElementViewHelper) { PSMContentModel contentModel; if (!TranslatedAlready(psmContentContainer, out contentModel)) { contentModel = new PSMContentModel(evoxProject, psmSchema, false); translatedElements[psmContentContainer] = contentModel; } contentModel.Type = PSMContentModelType.Sequence; }
public override void FillCopy(Element copyElement, Model targetModel, ElementCopiesMap createdCopies) { base.FillCopy(copyElement, targetModel, createdCopies); PSMContentContainer copyPSMContentContainer = (PSMContentContainer)copyElement; copyPSMContentContainer.ElementLabel = ElementLabel; if (Parent != null && createdCopies.ContainsKey(Parent)) { PSMSuperordinateComponent copyParent = (PSMSuperordinateComponent)createdCopies[Parent]; ((_ImplPSMSubordinateComponent)copyPSMContentContainer).Parent = (PSMSuperordinateComponent)createdCopies[Parent]; copyParent.Components.Add(copyPSMContentContainer); } }
protected override void TranslateContentContainer(PSMContentContainer contentContainer, DataGeneratorContext context) { XmlElement prevCurrentElement = context.CurrentElement; TranslateComments(contentContainer, context); string elementName = namingSupport.NormalizeTypeName(contentContainer, c => contentContainer.Name); XmlElement xmlElement = context.Document.CreateElement(elementName, ProjectNamespace); context.CurrentElement.AppendChild(xmlElement); // set new current element context.CurrentElement = xmlElement; TranslateComponents(contentContainer, context); // return current element to previous value context.CurrentElement = prevCurrentElement; }
public static IList <EvolutionChange> Detect(Version v1, Version v2, PSMContentContainer contentContainer) { List <EvolutionChange> result = new List <EvolutionChange>(); if (((PSMContentContainer)contentContainer.GetInVersion(v1)).Name != ((PSMContentContainer)contentContainer.GetInVersion(v2)).Name) { ContentContainerRenamedChange c = new ContentContainerRenamedChange(contentContainer) { OldVersion = v1, NewVersion = v2 }; result.Add(c); } return(result); }
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)); }
/// <summary> /// Translates the content container. /// </summary> /// <param name="contentContainer">The content container.</param> /// <param name="context">The translation context.</param> protected virtual void TranslateContentContainer(PSMContentContainer contentContainer, Context context) { }
public PSM_ContentContainerController(PSMContentContainer contentContainer, DiagramController diagramController) : base(contentContainer, diagramController) { }
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); } } }
public ContentContainerRenamedChange(PSMContentContainer contentContainer) : base(contentContainer) { }
protected ContentContainerChange(PSMContentContainer contentContainer) { Element = contentContainer; }