internal override void GenerateSubCommands() { report.Append("Fixing association interpretations" + newline); foreach (PSMAssociation a in Project.LatestVersion.PSMSchemas.SelectMany(s => s.PSMAssociations).Where(assoc => assoc.Interpretation != null && assoc.InterpretedAssociationEnd == null)) { PIMAssociationEnd e; PIMAssociation pimassoc = a.Interpretation as PIMAssociation; PSMClass child = a.Child as PSMClass; if (child == null) { report.Append("child not class: " + a.ToString() + newline); continue; } PIMClass childInterpretation = child.Interpretation as PIMClass; if (pimassoc.PIMAssociationEnds.Where(ae => ae.PIMClass == childInterpretation).Count() > 1) { report.Append("cannot fix - self reference detected: " + a.ToString() + newline); continue; } else { e = pimassoc.PIMAssociationEnds.Single(ae => ae.PIMClass == childInterpretation); } report.Append("fixed OK: " + a.ToString() + newline); Commands.Add(new acmdSetPSMAssociationInterpretation(Controller, a, e, a.Interpretation) { Propagate = false }); } }
public FakeAttributeCollection(ObservableCollection <FakePSMAttribute> attributesList, PSMClass psmClass, TypeFinder typeFinder) : base(attributesList) { foreach (PSMAttribute psmAttribute in psmClass.PSMAttributes) { attributesList.Add(new FakePSMAttribute(psmAttribute)); } bool classEmpty = psmClass.PSMAttributes.Count == 0; PSMClass nearestInterpretedClass = psmClass.NearestInterpretedClass(); if (nearestInterpretedClass != null) { foreach (PIMAttribute attribute in ((PIMClass)nearestInterpretedClass.Interpretation).PIMAttributes) { if (!attributesList.Any(p => p.SourceAttribute != null && p.SourceAttribute.Interpretation == attribute)) { attributesList.Add(new FakePSMAttribute(attribute, typeFinder) { Checked = classEmpty }); } } } }
public static UnlimitedNatural GetUpperMultiplicityOfContentElement(PSMElement node) { { PSMClass c = node as PSMClass; if (c != null) { if (c.ParentUnion != null) { throw new NotImplementedException("Can't handle class union yet. "); } if (c.ParentAssociation != null) { return(c.ParentAssociation.Upper);//.Value; } else { return(1); // root class } } } if (node is PSMContentContainer) { return(1); } if (node is PSMAttribute) { return(((PSMAttribute)node).Upper.Value); } // should never get here... throw new ArgumentException("Node is not correct significant node."); }
public override bool VerifyConsistency(object superordinateObject, object candidate) { PSMClass PSMClass = (PSMClass)superordinateObject; PSMAttribute PSMAttribute = (PSMAttribute)candidate; return(PSMClass.PSMAttributes.Contains(PSMAttribute)); }
/// <summary> /// Translates the name of the type. The returned type name is unique compared to /// the results of previous calls of <see cref="TranslateTypeName"/>. /// </summary> /// <param name="psmClass">The PSM class for which type name should be returned.</param> /// <returns></returns> public string TranslateTypeName(PSMClass psmClass) { if (string.IsNullOrEmpty(psmClass.Name)) { Log.AddError(LogMessages.XS_CLASS_NAME_EMPTY); return("empty"); } string normalizedTypeName = NormalizeTypeName(psmClass, p => p.Name); if (psmClass.Diagram != this.Diagram) { PSMDiagramReference reference = Diagram.DiagramReferences.FirstOrDefault(r => r.ReferencedDiagram == psmClass.Diagram); if (reference != null && !string.IsNullOrEmpty(reference.NamespacePrefix)) { normalizedTypeName = String.Format("{0}:{1}", reference.NamespacePrefix, normalizedTypeName); } } if (!counters.ContainsKey(normalizedTypeName) || counters[normalizedTypeName] == 0) { counters[normalizedTypeName] = 1; return(String.Format("{0}", normalizedTypeName)); } return(String.Format("{0}{1}", normalizedTypeName, ++counters[normalizedTypeName])); }
public static bool EncompassesAttributesForParentSignificantNode(this PSMElement child) { PSMClass childClass = child as PSMClass; if (childClass != null && !childClass.HasElementLabel) { if (childClass.PSMAttributes.Count > 0) { return(true); } if (childClass.IsStructuralRepresentative && childClass.RepresentedPSMClass.EncompassesAttributesForParentSignificantNode()) { return(true); } return(childClass.Components.Any(EncompassesAttributesForParentSignificantNode)); } if (child is PSMClassUnion) { return(((PSMClassUnion)child).Components.Any(EncompassesAttributesForParentSignificantNode)); } if (child is PSMAssociation) { return(EncompassesAttributesForParentSignificantNode(((PSMAssociation)child).Child)); } return(false); }
public override bool CanExecute() { if (!(deletedClassGuid != Guid.Empty && schemaGuid != Guid.Empty && Project.VerifyComponentType <PSMSchema>(schemaGuid) && Project.VerifyComponentType <PSMClass>(deletedClassGuid))) { ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH; return(false); } PSMClass c = Project.TranslateComponent <PSMClass>(deletedClassGuid); if (c.ChildPSMAssociations.Count > 0) { ErrorDescription = CommandErrors.CMDERR_CLASS_HAS_ASSOCIATIONS; return(false); } if (c.PSMAttributes.Count > 0) { ErrorDescription = CommandErrors.CMDERR_CLASS_HAS_ATTRIBUTES; return(false); } if (c.Representants.Count > 0) { ErrorDescription = CommandErrors.CMDERR_CLASS_IS_REPRESENTED; return(false); } return(true); }
protected override void TranslateAssociationChild(PSMAssociationChild associationChild, DataGeneratorContext context) { int count = 1; if (associationChild.ParentAssociation != null) { count = ChooseMultiplicity(associationChild.ParentAssociation); } for (int i = 0; i < count; i++) { if (associationChild is PSMClass) { PSMClass psmClass = (PSMClass)associationChild; if (!psmClass.HasElementLabel) { if (GenerateComments) { XmlComment xmlComment = context.Document.CreateComment(string.Format("Content group {0} {1}", psmClass.Name, i)); context.CurrentElement.AppendChild(xmlComment); } } TranslateClass(psmClass, context); } else { TranslateClassUnion((PSMClassUnion)associationChild, context); } } }
public void Set(PSMClass sourcePSMClass) { #region Init recursion SourcePSMClass = sourcePSMClass; SelectPIMPathDialog dialog = new SelectPIMPathDialog(); List <Generalization> UsedGeneralizations = new List <Generalization>(); Structure = AddChildren( new TreeClasses() { Association = null, Lower = 1, Upper = 1, UsedGeneralizations = UsedGeneralizations, ParentTC = null, Represented = null, PIMClass = SourcePSMClass.RepresentedClass }, new List <PIMClass>(), SourcePSMClass.RepresentedClass, UsedGeneralizations, 2); dialog.treeView.ItemsSource = Structure.Children; dialog.AddChildren = AddChildren; #endregion if (dialog.ShowDialog() == true) //Show the dialog and let the user choose { Selected = new ObservableCollection <TreeClasses>(); GetSelected(Structure); ResolveRepresentants(); foreach (TreeClasses T in Selected) { GenerateCommands(T); } } }
private static IEnumerable <FollowedPath> FollowPath(PSMElement element, FollowedPath followedPath) { List <FollowedPath> result = new List <FollowedPath>(); PSMTreeIterator it = new PSMTreeIterator(element); followedPath.Add(element); while (it.CanGoToParent()) { it.GoToParent(); PSMClass psmClass = it.CurrentNode as PSMClass; if (psmClass != null && psmClass.IsReferencedFromStructuralRepresentative()) { foreach (PSMClass representative in psmClass.Diagram.DiagramElements.Keys.OfType <PSMClass>().Where(rClass => rClass.RepresentedPSMClass == psmClass)) { result.AddRange(FollowPath(representative, followedPath.Copy())); } } followedPath.Add(it.CurrentNode); } if (followedPath.Last() is PSMClass && ((PSMClass)followedPath.Last()).HasElementLabel) { result.Add(followedPath); } return(result); }
private static List <PSMClass> FindClassAncestors(PSMClass psmClass) { PSMClass level = psmClass; List <PSMClass> ancestors = new List <PSMClass>(); while (level != null) { if (level.Generalizations.Count > 1) { throw new Exception("PSM class can have only one generalization, multiple inheritance is forbidden. "); } else if (level.Generalizations.Count == 1) { PSMClass generalClass = (PSMClass)level.Generalizations[0].General; ancestors.Add(generalClass); level = generalClass; } else { level = null; } } ancestors.Reverse(); return(ancestors); }
public override bool CanExecute() { if (attributeGuid == Guid.Empty) { ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH; return(false); } PSMAttribute attribute = Project.TranslateComponent <PSMAttribute>(attributeGuid); PSMClass oldclass = attribute.PSMClass; PSMClass newclass = oldclass.GeneralizationAsSpecific == null ? null : oldclass.GeneralizationAsSpecific.General; if (newclass == null) { ErrorDescription = CommandErrors.CMDERR_NO_GENERALIZATION; return(false); } if (attribute.Interpretation != null) { PSMClass intclass = attribute.NearestInterpretedClass(); if (intclass != null) { if ((intclass.Interpretation as PIMClass) != (attribute.Interpretation as PIMAttribute).PIMClass && !(intclass.Interpretation as PIMClass).GetGeneralClasses().Contains((attribute.Interpretation as PIMAttribute).PIMClass)) { ErrorDescription = CommandErrors.CMDERR_CANNOT_GENERALIZE_INTERPRET_ERR; return(false); } } } return(true); }
void ContextMenu_ContextMenuOpening(object sender, ContextMenuEventArgs e) { if (ClassController.Class.RepresentedClassRepresentants.Where(psmClass => psmClass != ClassController.Class && psmClass.Diagram == ClassController.DiagramController.Diagram).Count() == 0) { miConvertToRepresentant.IsEnabled = false; } else { miConvertToRepresentant.IsEnabled = true; } if (ClassController.Class.IsStructuralRepresentative) //Structural Representative { miConvertToRepresentant.Visibility = Visibility.Collapsed; miConvertToRegular.Visibility = Visibility.Visible; } else //Regular PSM Class { miConvertToRepresentant.Visibility = Visibility.Visible; miConvertToRegular.Visibility = Visibility.Collapsed; } PSMClass tmp = this.PSMClass; //compiler throws wierd error when this variable is not used... miGroupBy.IsEnabled = tmp.Diagram.Roots.Contains(tmp); }
private void SelectNotRequiredSubtrees() { PSMDiagram psmDiagram = ((PSMDiagram)Diagram); List <PSMClass> startClasses = SelectedItems.OfType <IModelElementRepresentant>().Select( r => ElementRepresentations.GetElementRepresentedBy(r)).OfType <PSMClass>().Where( r => psmDiagram.Roots.Contains(r)).ToList(); List <PSMClass> visitedClasses = new List <PSMClass>(startClasses); Queue <Element> queue = new Queue <Element>(startClasses); while (!queue.IsEmpty()) { Element element = queue.Dequeue(); PSMClass psmClass = element as PSMClass; if (psmClass != null) { visitedClasses.Add(psmClass); // new subtree added when structural representative found. if (psmClass.IsStructuralRepresentative && !psmClass.IsStructuralRepresentativeExternal) { queue.Enqueue(psmClass.RepresentedPSMClass); } } foreach (Element child in PSMTree.GetChildrenOfElement(element)) { queue.Enqueue(child); } } IEnumerable <IModelElementRepresentant> representants = psmDiagram.Roots.Where(r => !visitedClasses.Contains(r)).Select(element => ElementRepresentations[element]); SelectedItems.SetSelection(representants); }
internal override void CommandOperation() { PSMSuperordinateComponent p = AttributeContainerLeftOut.Parent; while (!(p is PSMClass) && p is PSMSubordinateComponent) { p = ((PSMSubordinateComponent)p).Parent; } parentClass = p as PSMClass; if (parentClass != null) { returnedAttributes = new List <PSMAttribute>(); foreach (PSMAttribute attribute in AttributeContainerLeftOut.PSMAttributes) { if (parentClass.PSMAttributes.Any(a => a.RepresentedAttribute == attribute.RepresentedAttribute)) { continue; } PSMAttribute createdAttribute = parentClass.AddAttribute(attribute.RepresentedAttribute); returnedAttributes.Add(createdAttribute); if (!String.IsNullOrEmpty(attribute.Alias)) { createdAttribute.Alias = attribute.Alias; } } AttributeContainerLeftOut.RemoveMeFromModel(); viewHelper = Diagram.DiagramElements[AttributeContainerLeftOut]; Diagram.RemoveModelElement(AttributeContainerLeftOut); } }
internal override CommandBase.OperationResult UndoOperation() { PSMClass psmClass = Project.TranslateComponent <PSMClass>(classGuid); psmClass.Final = oldFinal; return(OperationResult.OK); }
public static List <PSMAttribute> GetAttributesForGroup(this PSMClass groupNode, Version oldVersion) { // take elements in the group that used to be attributes List <PSMAttribute> result = new List <PSMAttribute>(); List <NodeElementWrapper> contentComponents = groupNode.GetSubtreeElements(); foreach (NodeElementWrapper contentComponent in contentComponents) { if (contentComponent is SimpleNodeElement) { SimpleNodeElement simpleNodeElement = ((SimpleNodeElement)contentComponent); if (simpleNodeElement.Element is PSMAttribute) { PSMAttribute attribute = (PSMAttribute)simpleNodeElement.Element; PSMAttribute attributeOldVersion = (PSMAttribute)attribute.GetInVersion(oldVersion); if (attributeOldVersion != null) { PSMElement parent = (attributeOldVersion).Class; if (parent is PSMClass && ((PSMClass)parent).HasElementLabel) { continue; } if (attribute.AttributeContainer != null && attributeOldVersion.AttributeContainer == null) { result.Add(attribute); } } } } } return(result); }
private bool TestNodeDefinesAttributes(PSMAssociationMember node) { if (node is PSMClass) { PSMClass psmClass = (PSMClass)node; if (psmClass.PSMAttributes.Any(a => !a.Element)) { return(true); } if (psmClass.IsStructuralRepresentative) { if (TestNodeDefinesAttributes(psmClass.RepresentedClass)) { return(true); } } } foreach (PSMAssociation childPsmAssociation in node.ChildPSMAssociations) { if (!childPsmAssociation.IsNamed) { if (TestNodeDefinesAttributes(childPsmAssociation.Child)) { return(true); } } } return(false); }
private StackedCommand GetNormalizationCommand(PSMSchema schema) { // (d) Content model association normalization if (!modelVerifier.TestSchemaClassChildrenAreClasses(schema)) { PSMContentModel cm = (PSMContentModel)modelVerifier.LastViolatingComponent; cmdDeletePSMAssociation command = new cmdDeletePSMAssociation(Controller); command.Set(cm.ParentAssociation.ID); return(command); } // (c) Empty name association else if (!modelVerifier.TestSchemaClassChildrenNames(schema)) { PSMAssociation a = (PSMAssociation)modelVerifier.LastViolatingComponent; cmdDeletePSMAssociation command = new cmdDeletePSMAssociation(Controller); command.Set(a.ID); return(command); } // (e) Root content model normalization else if (!modelVerifier.TestRootsAreNotContentModels(schema)) { PSMContentModel cm = (PSMContentModel)modelVerifier.LastViolatingComponent; MacroCommand m = new MacroCommand(Controller); foreach (PSMAssociation childPsmAssociation in cm.ChildPSMAssociations) { cmdDeletePSMAssociation delA = new cmdDeletePSMAssociation(Controller); delA.Set(childPsmAssociation.ID); m.Commands.Add(delA); } cmdDeletePSMContentModel delCM = new cmdDeletePSMContentModel(Controller); delCM.Set(cm.ID); m.Commands.Add(delCM); return(m); } // (f) Root class normalization else if (!modelVerifier.TestRootsAreReferenced(schema)) { PSMClass c = (PSMClass)modelVerifier.LastViolatingComponent; cmdDeleteRootPSMClass command = new cmdDeleteRootPSMClass(Controller); command.Set(c.ID); return(command); } // (a) Cardinality normalization else if (!modelVerifier.TestSchemaClassChildrenCardinality(schema)) { PSMAssociation a = (PSMAssociation)modelVerifier.LastViolatingComponent; cmdUpdatePSMAssociationCardinality command = new cmdUpdatePSMAssociationCardinality(Controller); command.Set(a.ID, 1, 1); return(command); } // (b) Name normalization else if (!modelVerifier.TestContentModelsAssociationNames(schema)) { PSMAssociation a = (PSMAssociation)modelVerifier.LastViolatingComponent; cmdRenameComponent command = new cmdRenameComponent(Controller) { ComponentGuid = a.ID, NewName = String.Empty }; return(command); } else { throw new InvalidOperationException("Schema is already normalized. "); } }
protected override object TranslateClass(PSMClass psmClass, DataGeneratorContext context) { TranslateComments(psmClass, context); if (!context.TranslatingRepresentedClass && !context.TranslatingAncestors) { } else { context.TranslatingRepresentedClass = false; context.TranslatingAncestors = false; } //if (psmClass.Generalizations.Count > 0 && !ignoreAncestors) //{ // TranslateAncestors(psmClass, context); //} if (psmClass.IsStructuralRepresentative) { context.TranslatingRepresentedClass = true; TranslateClass(psmClass.RepresentedClass, context); context.TranslatingRepresentedClass = false; } TranslateAttributes(psmClass.PSMAttributes, context); TranslateContent(psmClass, context); return(null); }
/// <summary> /// Translates the specializations of <paramref name="generalClass"/>. Calls /// <see cref="TranslateSpecialization"/> for each specialization of <paramref name="generalClass"/>. /// </summary> /// <seealso cref="Class.Specifications"/> /// <param name="generalClass">The general class.</param> /// <param name="generalTypeName">Name of the general type.</param> protected void TranslateSpecializations(PSMClass generalClass, TypeIdentifier generalTypeName) { foreach (Generalization specialization in generalClass.Specifications) { TranslateSpecialization(specialization, generalTypeName); } }
public override bool CanExecute() { if (AssociationGuid == Guid.Empty || PSMClassGuid == Guid.Empty) { ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH; return(false); } PSMAssociation association = Project.TranslateComponent <PSMAssociation>(AssociationGuid); PSMClass oldclass = association.Parent as PSMClass; if (oldclass == null) { ErrorDescription = CommandErrors.CMDERR_PARENT_NOT_PSMCLASS; return(false); } PSMClass newclass = Project.TranslateComponent <PSMClass>(PSMClassGuid); if (!oldclass.GetGeneralClasses().Contains(newclass)) { ErrorDescription = CommandErrors.CMDERR_CLASS_NOT_GENERAL; return(false); } return(true); }
internal override void GenerateSubCommands() { PSMClass psmClass = Project.TranslateComponent <PSMClass>(ClassGuid); foreach (PSMAttribute a in psmClass.PSMAttributes) { cmdDeletePSMAttribute da = new cmdDeletePSMAttribute(Controller); da.Set(a); Commands.Add(da); } foreach (PSMAssociation a in psmClass.ChildPSMAssociations) { cmdDeletePSMAssociation da = new cmdDeletePSMAssociation(Controller); da.Set(a); Commands.Add(da); } foreach (PSMGeneralization g in psmClass.GeneralizationsAsGeneral) { acmdDeletePSMGeneralization dg = new acmdDeletePSMGeneralization(Controller, g); Commands.Add(dg); } if (psmClass.GeneralizationAsSpecific != null) { Commands.Add(new acmdDeletePSMGeneralization(Controller, psmClass.GeneralizationAsSpecific)); } Commands.Add(new acmdRenameComponent(Controller, ClassGuid, "")); foreach (PSMClass representant in psmClass.Representants) { Commands.Add(new acmdSetRepresentedClass(Controller, representant, Guid.Empty)); } Commands.Add(new acmdSetRepresentedClass(Controller, ClassGuid, Guid.Empty)); Commands.Add(new acmdSetPSMClassInterpretation(Controller, ClassGuid, Guid.Empty)); Commands.Add(new acmdDeletePSMClass(Controller, ClassGuid)); }
public override bool CanExecute() { if (!(PSMComponentGuid != Guid.Empty && PIMComponentGuid == Guid.Empty || (Project.VerifyComponentType <PSMAttribute>(PSMComponentGuid) && Project.VerifyComponentType <PIMAttribute>(PIMComponentGuid)) )) { ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH; return(false); } if (PIMComponentGuid == Guid.Empty) { return(true); } PIMClass pimClass1 = Project.TranslateComponent <PIMAttribute>(PIMComponentGuid).PIMClass; PSMClass niClass = Project.TranslateComponent <PSMAttribute>(PSMComponentGuid).NearestInterpretedClass(); if (niClass == null) { ErrorDescription = CommandErrors.CMDERR_CANNOT_SET_INTERPRETATION_NO_INTCLASS; return(false); } PIMClass pimClass2 = niClass.Interpretation as PIMClass; if (pimClass1 != pimClass2 && !pimClass2.GetGeneralClasses().Contains(pimClass1)) { ErrorDescription = CommandErrors.CMDERR_CANNOT_SET_INTERPRETATION_CLASSES_DONT_MATCH; return(false); } return(true); }
private void IdentifyGroupNodes() { groupNodes = new List <PSMElement>(); foreach (PSMElement element in Diagram.DiagramElements.Keys.OfType <PSMElement>()) { PSMClass psmClass = element as PSMClass; if (psmClass == null) { continue; } if (!psmClass.EncompassesContentForParentSignificantNode() && !psmClass.EncompassesAttributesForParentSignificantNodeOrSelf()) { continue; } if (!psmClass.HasElementLabel) { groupNodes.Add(element); continue; } if (changesByTarget.ContainsKey(psmClass)) { ClassElementNameChange elc = (ClassElementNameChange) changesByTarget[psmClass].FirstOrDefault( change => change is ClassElementNameChange && change.Element == psmClass); if (elc != null && elc.ElementLabelAdded) { groupNodes.Add(element); continue; } } } }
private void ConvertPSMAssociation(PSMAssociation psmAssociation, PSMAssociationViewHelper psmAssociationViewHelper) { EvoX.Model.PSM.PSMAssociation evoxPSMAssociation; if (!TranslatedAlready(psmAssociation, out evoxPSMAssociation)) { PSMAssociationMember parent = (PSMAssociationMember)ElementRef(psmAssociation.Parent); PSMAssociationMember child = (PSMAssociationMember)ElementRef(psmAssociation.Child); evoxPSMAssociation = new EvoX.Model.PSM.PSMAssociation(evoxProject, parent, child, psmSchema); associationOrder[evoxPSMAssociation] = psmAssociation.ComponentIndex(); translatedElements[psmAssociation] = evoxPSMAssociation; } PSMClass childPSMClass = psmAssociation.Child as PSMClass; if (childPSMClass != null && childPSMClass.HasElementLabel) { evoxPSMAssociation.Name = childPSMClass.ElementName; } else { evoxPSMAssociation.Name = null; } PSMClassUnion psmClassUnion = psmAssociation.Child as PSMClassUnion; if (psmClassUnion != null) { evoxPSMAssociation.Name = null; } evoxPSMAssociation.Lower = ConvertToUint(psmAssociation.Lower); evoxPSMAssociation.Upper = ConvertToUnlimitedInt(psmAssociation.Upper); }
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); }
private void DisplayAttributes(PSMClass psmClass) { if (psmClass != null) { lvPSMAttributes.ItemsSource = psmClass.PSMAttributes; lvPSMAttributesInherited.ItemsSource = psmClass.GetActualPSMAttributesIncludingInherited(); spPSMAttributes.Visibility = System.Windows.Visibility.Visible; /*if (psmClass.IsStructuralRepresentative) * { * lPSMAttributesSRInherited.Visibility = System.Windows.Visibility.Visible; * lvPSMAttributesSRInhereted.Visibility = System.Windows.Visibility.Visible; * lvPSMAttributesSRInhereted.ItemsSource = psmClass.GetPSMAttributesOfRepresentedClasses(); * } * else * { * lPSMAttributesSRInherited.Visibility = System.Windows.Visibility.Collapsed; * lvPSMAttributesSRInhereted.Visibility = System.Windows.Visibility.Collapsed; * }*/ } else { lvPSMAttributes.ItemsSource = null; lvPSMAttributesInherited.ItemsSource = null; spPSMAttributes.Visibility = System.Windows.Visibility.Collapsed; } }
public new static bool TestCandidate(PSMComponent candidate, Version oldVersion, Version newVersion) { PSMClass psmClass = (PSMClass)candidate; PSMClass psmClassO = (PSMClass)candidate.GetInVersion(oldVersion); return(ExistingTest(candidate, oldVersion, newVersion) && psmClassO.IsStructuralRepresentative && !psmClass.IsStructuralRepresentative); }
public override bool CanExecute() { if (!(newClassGuid != Guid.Empty && Project.VerifyComponentType <PSMClass>(newClassGuid) && attributeGuid != Guid.Empty && Project.VerifyComponentType <PSMAttribute>(attributeGuid))) { ErrorDescription = CommandErrors.CMDERR_INPUT_TYPE_MISMATCH; return(false); } PSMClass newClass = Project.TranslateComponent <PSMClass>(newClassGuid); PSMClass oldClass = Project.TranslateComponent <PSMAttribute>(attributeGuid).PSMClass; //the two classes connected by an association path across containers (atomic operation) if (newClass.NearestParentClass() == oldClass) { return(true); } if (oldClass.NearestParentClass() == newClass) { return(true); } if (newClass.RepresentedClass == oldClass || oldClass.RepresentedClass == newClass) { return(true); } ErrorDescription = CommandErrors.CMDERR_NO_COMMON_ASSOCIATION_OR_REPR; return(false); }