public override void CommandsExecuted() { base.CommandsExecuted(); CreatedGeneralization = c.CreatedGeneralization.Element; ViewHelper = d.ViewHelper; }
protected void updateChildGeneralizations(CoreClassifier owner, Generalization newGeneralization) { List <Generalization> generalizations = owner.getGeneralization(); generalizations.Add(newGeneralization); owner.setGeneralization(generalizations); }
protected void updateParentSpecializations(CoreClassifier owner, Generalization newSpecialization) { List <Generalization> specializations = owner.getSpecialization(); specializations.Add(newSpecialization); owner.setSpecialization(specializations); }
StObjProperty?GetStObjProperty(string propertyName, PropertyResolutionSource source = PropertyResolutionSource.FromContainerAndThenGeneralization) { if (_stObjProperties != null) { int idx = _stObjProperties.FindIndex(p => p.Name == propertyName); if (idx >= 0) { return(_stObjProperties[idx]); } } StObjProperty?result = null; if (source == PropertyResolutionSource.FromContainerAndThenGeneralization) { result = IsOwnContainer ? _dContainer !.GetStObjProperty(propertyName) : null; if (result == null && Generalization != null) { result = Generalization.GetStObjProperty(propertyName); } } else { result = Generalization != null?Generalization.GetStObjProperty(propertyName, PropertyResolutionSource.FromGeneralizationAndThenContainer) : null; if (result == null && IsOwnContainer) { result = _dContainer !.GetStObjProperty(propertyName, PropertyResolutionSource.FromGeneralizationAndThenContainer); } } return(result); }
internal override void CommandOperation() { Generalization generalization = Controller.Model.Schema.SetGeneralization(GeneralPSMClass.Element, SpecificPSMClass.Element); if (CreatedGeneralization == null) { CreatedGeneralization = new ElementHolder <Generalization>(); } CreatedGeneralization.Element = generalization; }
internal void OnPluginStopped(bool direct) { if (Generalization != null) { Generalization.OnPluginStopped(false); } Debug.Assert(_dynamicTotalAvailablePluginsCount > 0); --_dynamicTotalAvailablePluginsCount; if (direct) { --_dynamicAvailablePluginsCount; } }
public virtual void Process(Generalization generalization, TPrinter printer) { LinePattern pattern = LinePattern.Solid; if (generalization.General.IsInterface && generalization.Specific.IsClass) { pattern = LinePattern.Dotted; } printer.PrintGeneralization( PlantUmlUtils.GetSimpleName(generalization.General), PlantUmlUtils.GetSimpleName(generalization.Specific), generalization.Name, 2, pattern); }
/// <summary> /// </summary> /// <param name="e">Provides data for the RolePlayerChanged event.</param> public override void RolePlayerChanged(RolePlayerChangedEventArgs e) { // Modification de la superClass if (e.DomainRole.Id == Generalization.SuperClassDomainRoleId) { Generalization link = e.ElementLink as Generalization; if (link.SuperClass.SubClasses.Count > 0) { link.SuperClass.SubClasses.RemoveAt(0); } link.SuperClass.SubClasses.Add(link.SubClass); } }
public static Element GetRightSiblingOfElement(Element element) { PSMSubordinateComponent subordinateComponent = element as PSMSubordinateComponent; if (subordinateComponent != null) { PSMSuperordinateComponent parent = subordinateComponent.Parent; if (parent != null) { ObservableCollection <PSMSubordinateComponent> components = parent.Components; if (components.IndexOf(subordinateComponent) < components.Count - 1) { return(components[components.IndexOf(subordinateComponent) + 1]); } else if (parent is PSMClass) { PSMClass parentClass = parent as PSMClass; if (parentClass.Specifications.Count > 0) { return(parentClass.Specifications.First()); } } } } Generalization generalization = element as Generalization; if (generalization != null) { IList <Generalization> specifications = generalization.General.Specifications; if (specifications.IndexOf(generalization) != specifications.Count - 1) { return(specifications[specifications.IndexOf(generalization) + 1]); } } PSMClass psmClass = element as PSMClass; if (psmClass != null && psmClass.ParentUnion != null) { ObservableCollection <PSMAssociationChild> components = psmClass.ParentUnion.Components; if (components.IndexOf(psmClass) < components.Count - 1) { return(components[components.IndexOf(psmClass) + 1]); } } return(null); }
public override void FillCopy(Element copyElement, Model targetModel, ElementCopiesMap createdCopies) { if (this.general is PIMClass) { if (targetModel.Schema == this.Schema) { throw new InvalidOperationException("Cannot create copy of pim generalization in the same model."); } } base.FillCopy(copyElement, targetModel, createdCopies); Generalization copyGeneralization = (Generalization)copyElement; copyGeneralization.General = (Class)createdCopies[General]; copyGeneralization.Specific = (Class)createdCopies[Specific]; copyGeneralization.IsSubstituable = IsSubstituable; }
private void fillGeneralizationMode1(XElement xgeneralization, Generalization generalization, XAttribute xattributechild) { string xchildidref = xattributechild.Value; CoreModelElement child; lookup.TryGetValue(xchildidref, out child); generalization.setChild((CoreClassifier)child); XAttribute xattributeparent = xgeneralization.Attribute("parent"); if (xattributeparent != null) { string xparentidref = xattributeparent.Value; CoreModelElement parent; lookup.TryGetValue(xparentidref, out parent); generalization.setParent((CoreClassifier)parent); } }
public void ToolMouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && canvas != null) { canvas.DeselectAll(); if (objectSource != null) { objectDestination = canvas.SelectObject(e.X, e.Y); Generalization connector = new Generalization(objectSource, objectDestination); objectSource.Attach(connector); objectDestination.Attach(connector); canvas.AddDrawingObject(connector); connector.ChangeState(StaticState.GetInstance()); } } }
internal void OnPostPluginStopped() { if (_dynamicTotalAvailablePluginsCount == 0) { Debug.Assert(_dynamicStatus == null || _dynamicStatus.Value <= RunningStatus.Stopped); if (_dynamicStatus == null) { DynamicStopBy(ServiceRunningStatusReason.StoppedByPluginStopped); } } else if (_dynamicStatus != null && _dynamicStatus.Value >= RunningStatus.Running) { DynPropagateStart(); } if (Generalization != null) { Generalization.OnPostPluginStopped(); } }
public static Element GetParentOfElement(Element element) { if (element is PSMSubordinateComponent) { return(((PSMSubordinateComponent)element).Parent); } PSMAssociationChild associationChild = element as PSMAssociationChild; if (associationChild != null && associationChild.ParentAssociation != null) { return(associationChild.ParentAssociation); } if (associationChild != null && associationChild.ParentUnion != null) { return(associationChild.ParentUnion); } PSMClass psmClass = element as PSMClass; if (psmClass != null) { if (psmClass.ParentUnion != null) { return(psmClass.ParentUnion); } if (psmClass.Generalizations.Count() > 0) { return(psmClass.Generalizations.First()); } } Generalization generalization = element as Generalization; if (generalization != null) { return(generalization.General); } return(null); }
public static Element GetLeftSiblingOfElement(Element element) { PSMSubordinateComponent subordinateComponent = element as PSMSubordinateComponent; if (subordinateComponent != null) { PSMSuperordinateComponent parent = subordinateComponent.Parent; if (parent != null && parent.Components.IndexOf(subordinateComponent) >= 1) { return(parent.Components[parent.Components.IndexOf(subordinateComponent) - 1]); } } PSMClass psmClass = element as PSMClass; if (psmClass != null && psmClass.ParentUnion != null) { if (psmClass.ParentUnion.Components.IndexOf(psmClass) > 0) { return(psmClass.ParentUnion.Components[psmClass.ParentUnion.Components.IndexOf(psmClass) - 1]); } } Generalization generalization = element as Generalization; if (generalization != null) { IList <Generalization> specifications = generalization.General.Specifications; if (specifications.IndexOf(generalization) == 0) { return(((PSMClass)generalization.General).Components.LastOrDefault()); } if (specifications.IndexOf(generalization) > 0) { return(specifications[specifications.IndexOf(generalization) - 1]); } } return(null); }
/// <summary> /// Creates context menu items for the junction (if junction is a part /// of association or generalization, association or generalization context /// menu items are included) /// </summary> private void InitializeContextMenu() { ContextMenu menu = new ContextMenu(); if (Association != null) { foreach (ContextMenuItem item in Association.AssociationMenuItems()) { menu.Items.Add(item); } } if (Generalization != null) { foreach (ContextMenuItem item in Generalization.GeneralizationMenuItems()) { menu.Items.Add(item); } } if (PSM_Association != null) { foreach (ContextMenuItem item in PSM_Association.PSM_AssociationMenuItems()) { menu.Items.Add(item); } } bool sep = true; foreach (ContextMenuItem item in JunctionMenuItems()) { if (sep) { menu.Items.Add(new Separator()); sep = false; } menu.Items.Add(item); } this.ContextMenu = menu; }
public static Element GetFirstChildOfElement(Element element) { PSMSuperordinateComponent superordinateComponent = element as PSMSuperordinateComponent; if (superordinateComponent != null && superordinateComponent.Components.Count > 0) { return(superordinateComponent.Components[0]); } PSMClassUnion union = element as PSMClassUnion; if (union != null && union.Components.Count > 0) { return(union.Components[0]); } PSMAssociation association = element as PSMAssociation; if (association != null) { return(association.Child); } PSMClass psmClass = element as PSMClass; if (psmClass != null) { if (psmClass.Specifications.Count > 0) { return(psmClass.Specifications.First()); } } Generalization generalization = element as Generalization; if (generalization != null) { return(generalization.Specific); } return(null); }
public static IEnumerable <Element> GetChildrenOfElement(Element element) { PSMSuperordinateComponent superordinateComponent = element as PSMSuperordinateComponent; if (superordinateComponent != null && superordinateComponent.Components.Count > 0) { return(superordinateComponent.Components); } PSMClassUnion union = element as PSMClassUnion; if (union != null && union.Components.Count > 0) { return(union.Components); } PSMAssociation association = element as PSMAssociation; if (association != null) { return(new Element[] { association.Child }); } PSMClass psmClass = element as PSMClass; if (psmClass != null) { if (psmClass.Specifications.Count > 0) { return(psmClass.Specifications); } } Generalization generalization = element as Generalization; if (generalization != null) { return(new Element[] { generalization.Specific }); } return(new Element[0]); }
private void AddGeneralizationDependencies(Element root, Generalization generalization) { AddDependency(root, generalization.Specific); elementsToDo.Enqueue(new KeyValuePair <Element, Element>(root, generalization.Specific)); }
/// <summary> /// Translates the <paramref name="specialization"/>. /// </summary> /// <remarks> /// Could call <see cref="TranslateClass"/> for <paramref name="specialization"/>'s /// <see cref="Generalization.Specific"/> class to translate the specializing class the /// same way general classes are translated. If this is not the desired behaviour, /// all components of the specializing clases should be translated via /// <see cref="TranslateSubordinateComponent"/> call. /// </remarks> /// <param name="specialization">The translated specialization.</param> /// <param name="generalTypeName">Identifier of the general type.</param> protected virtual void TranslateSpecialization(Generalization specialization, TypeIdentifier generalTypeName) { }
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 GeneralizationController(Generalization generalization, DiagramController diagramController) : base(generalization, diagramController) { }
private void fillGeneralizationMode2(XNamespace xnamespace, XElement xgeneralization, Generalization generalization, XElement xchild) { var xclass = xchild.Element(xnamespace + "Class"); if (xclass != null) { string xchildidref = xclass.Attribute("xmi.idref").Value; CoreModelElement child; lookup.TryGetValue(xchildidref, out child); generalization.setChild((CoreClassifier)child); XElement xparent = xgeneralization.Element(xnamespace + "Generalization.parent"); if (xparent != null) { var xpclass = xparent.Element(xnamespace + "Class"); if (xpclass != null) { string xparentidref = xpclass.Attribute("xmi.idref").Value; CoreModelElement parent; lookup.TryGetValue(xparentidref, out parent); generalization.setParent((CoreClassifier)parent); } } } }
private void ConvertPIMGeneralization(Generalization generalization, GeneralizationViewHelper generalizationViewHelper) { // do nothing }
/// <summary> /// Returns the elements of subtrees of roots in an order in which they can be /// added to a PSM diagram. /// </summary> /// <param name="roots">The roots.</param> /// <param name="ordered">The ordered.</param> /// <param name="addMetElements">if set to <c>true</c> method adds any elements met /// during the execution (subelements of the elements in <paramref name="roots"/>).</param> /// <returns></returns> public static bool ReturnElementsInPSMOrder(IEnumerable <Element> roots, out IList <Element> ordered, bool addMetElements) { /* PSM diagram elements must be loaded from root to leaves, * following code is BFS implementation */ Queue <Element> elementsToDo = new Queue <Element>(); List <Element> alreadyProcessed = new List <Element>(); List <Element> delayedElements = new List <Element>(); List <Element> _roots = roots.ToList(); _roots.Sort(CompareByRootPositionsDesc); foreach (Element root in _roots) { elementsToDo.Enqueue(root); } List <Element> needed = new List <Element>(); while (elementsToDo.Count > 0) { Element node = elementsToDo.Dequeue(); if (!alreadyProcessed.Contains(node)) { if (node is PSMSuperordinateComponent) { foreach (PSMSubordinateComponent component in ((PSMSuperordinateComponent)node).Components.Where(i => !alreadyProcessed.Contains(i) && !elementsToDo.Contains(i))) { elementsToDo.Enqueue(component); } } if (node is PSMClassUnion) { foreach (PSMAssociationChild component in ((PSMClassUnion)node).Components.Where(i => !alreadyProcessed.Contains(i) && !elementsToDo.Contains(i))) { elementsToDo.Enqueue(component); } } PSMClass psmClass = node as PSMClass; if (psmClass != null) { foreach (Generalization specification in psmClass.Specifications.Where(i => !alreadyProcessed.Contains(i) && !elementsToDo.Contains(i))) { elementsToDo.Enqueue(specification); } } PSMAssociation a = node as PSMAssociation; Generalization g = node as Generalization; PSMSubordinateComponent sub = node as PSMSubordinateComponent; PSMAssociationChild child = node as PSMAssociationChild; /* * association can be loaded only after the child is already loaded too. * otherwise it is postponed, * * generalizations can be loaded after both * general and specific class are loaded * * component can be loaded after parent is loaded */ needed.Clear(); if (a != null) { if (elementsToDo.Contains(a.Parent)) { needed.Add(a.Parent); } needed.Add(a.Child); } if (g != null) { if (elementsToDo.Contains(g.General)) { needed.Add(g.General); } needed.Add(g.Specific); } if (sub != null) { if (elementsToDo.Contains(sub.Parent)) { needed.Add(sub.Parent); } //IList<PSMSubordinateComponent> components = sub.Parent.Components; //int index = components.IndexOf(sub); //needed.AddRange(components.Where(component => components.IndexOf(component) < index).Cast<Element>()); } if (child != null && child.ParentUnion != null) { if (elementsToDo.Contains(child.ParentUnion)) { needed.Add(child.ParentUnion); } //IList<PSMAssociationChild> components = child.ParentUnion.Components; //int index = components.IndexOf(child); //needed.AddRange(components.Where(component => components.IndexOf(component) < index).Cast<Element>()); } //if (child != null && child.ParentAssociation != null) //{ // if (elementsToDo.Contains(child.ParentAssociation)) // needed.Add(child.ParentAssociation); // //IList<PSMAssociationChild> components = child.ParentAssociation.Components; // //int index = components.IndexOf(child); // //needed.AddRange(components.Where(component => components.IndexOf(component) < index).Cast<Element>()); //} if (needed.All(alreadyProcessed.Contains)) { if (!alreadyProcessed.Contains(node)) { alreadyProcessed.Add(node); } } else { if (delayedElements.Contains(node)) { /* * association/generalization was already delayed once, * now it is clear that it will never be loaded correctly, * algortithm is stopped to avoid infinite cycle. */ ordered = null; return(false); } else { /* wait untill the association child is loaded */ foreach (Element element in needed.Where(i => !alreadyProcessed.Contains(i) && !elementsToDo.Contains(i))) { elementsToDo.Enqueue(element); } elementsToDo.Enqueue(node); delayedElements.Add(node); } } } } if (!addMetElements) { alreadyProcessed.RemoveAll(element => !roots.Contains(element)); } ordered = alreadyProcessed; return(true); }