From: <mcu...@us...> - 2009-03-31 19:25:21
|
Revision: 1375 http://orm.svn.sourceforge.net/orm/?rev=1375&view=rev Author: mcurland Date: 2009-03-31 19:25:05 +0000 (Tue, 31 Mar 2009) Log Message: ----------- Name alias resolution choosing a less-refined name, depending on the alias entry order. refs #338 Also moved the 'Reverse Role Order' command to the top of the Orientation submenu, and gave the MoveRoleLeft/MoveRoleRight commands that display with a role selection the same dynamic 'Reverse Role Order' name instead of 'Swap Role Order' for a binary FactType. Modified Paths: -------------- trunk/ORMModel/ObjectModel/NameGenerator.cs trunk/ORMModel/ShapeModel/ORMDiagram.resx trunk/ORMModel/Shell/PackageResources/PkgCmd.vsct Modified: trunk/ORMModel/ObjectModel/NameGenerator.cs =================================================================== --- trunk/ORMModel/ObjectModel/NameGenerator.cs 2009-03-28 17:45:34 UTC (rev 1374) +++ trunk/ORMModel/ObjectModel/NameGenerator.cs 2009-03-31 19:25:05 UTC (rev 1375) @@ -398,32 +398,35 @@ /// <summary> /// Retrieve the best matching alias for the provided set of aliases /// </summary> + /// <remarks>If an exact type/usage match is not available, then this will + /// return the closest usage match over the closest type match. The closest + /// matches are determined by walking up the parent hierarchy of name generators.</remarks> /// <param name="aliases">A set of alias elements. The best match is returned.</param> /// <returns>A <see cref="NameAlias"/>, or <see langword="null"/> if none is available.</returns> public NameAlias FindMatchingAlias(IEnumerable<NameAlias> aliases) { - NameAlias bestMatch = null; + NameAlias bestUsageMatch = null; + NameAlias bestTypeMatch = null; Type usageType = NameUsageType; DomainClassInfo thisClassInfo = GetDomainClass(); - DomainClassInfo matchedClassInfo = null; - bool matchedUsageType = false; - int closestDistance = int.MaxValue; + int closestTypeDistance = int.MaxValue; + int closestUsageDistance = int.MaxValue; foreach (NameAlias alias in aliases) { DomainClassInfo testClassInfo = alias.NameConsumerDomainClass; Type testUsageType = alias.NameUsageType; if (testClassInfo == thisClassInfo) { - if (usageType == testUsageType) + if (usageType == testUsageType) // intentionally handles two null values { - bestMatch = alias; + bestUsageMatch = alias; break; } else if (usageType != null && testUsageType == null) { - matchedClassInfo = testClassInfo; - bestMatch = alias; - // Keep going to see if we get an exact usage match + closestTypeDistance = 0; // Matched self, can't get any closer + bestTypeMatch = alias; + // Keep going to see if we get a higher priority usage match } } else @@ -435,30 +438,21 @@ ++testDistance; if (iterateClassInfo == testClassInfo) { - if (testDistance <= closestDistance) + if (usageType == testUsageType) // intentionally handles two null values { - if (testClassInfo == matchedClassInfo) + if (testDistance < closestUsageDistance) { - if (!matchedUsageType) - { - bestMatch = alias; - matchedUsageType = usageType == testUsageType; - } + closestUsageDistance = testDistance; + bestUsageMatch = alias; } - else if (usageType == testUsageType) + } + else if (usageType != null && testUsageType == null) + { + if (testDistance < closestTypeDistance) { - closestDistance = testDistance; - matchedClassInfo = testClassInfo; - matchedUsageType = true; - bestMatch = alias; + closestTypeDistance = testDistance; + bestTypeMatch = alias; } - else if (usageType != null && testUsageType == null) - { - closestDistance = testDistance; - matchedClassInfo = testClassInfo; - matchedUsageType = false; - bestMatch = alias; - } } break; } @@ -466,7 +460,7 @@ } while (iterateClassInfo != null); } } - return bestMatch; + return bestUsageMatch ?? bestTypeMatch; } #endregion // GetGeneratorSettings } Modified: trunk/ORMModel/ShapeModel/ORMDiagram.resx =================================================================== --- trunk/ORMModel/ShapeModel/ORMDiagram.resx 2009-03-28 17:45:34 UTC (rev 1374) +++ trunk/ORMModel/ShapeModel/ORMDiagram.resx 2009-03-31 19:25:05 UTC (rev 1375) @@ -212,7 +212,7 @@ <comment xml:space="preserve">This text appears on the 'Select on Diagram' menu if there is more than one shape for the selected element on the current diagram.</comment> </data> <data name="Command.SwapRoleOrder.Text"> - <value xml:space="preserve">S&wap Role Order</value> + <value xml:space="preserve">Re&verse Role Order</value> <comment xml:space="preserve">This text appears on the move role left/right when the fact type is binary.</comment> </data> <data name="ConstraintDisplayPosition.Bottom" xml:space="preserve"> Modified: trunk/ORMModel/Shell/PackageResources/PkgCmd.vsct =================================================================== --- trunk/ORMModel/Shell/PackageResources/PkgCmd.vsct 2009-03-28 17:45:34 UTC (rev 1374) +++ trunk/ORMModel/Shell/PackageResources/PkgCmd.vsct 2009-03-31 19:25:05 UTC (rev 1375) @@ -207,13 +207,13 @@ <Parent guid="guidORMDesignerCommandSet" id="menuIdReportGeneratorList"/> </Group> - <Group guid="guidORMDesignerCommandSet" id="groupIdDisplayOrientation" priority="0x0010"> + <Group guid="guidORMDesignerCommandSet" id="groupIdDisplayReverseRoleOrder" priority="0x0010"> <Parent guid="guidORMDesignerCommandSet" id="menuIdDisplayOrientation"/> </Group> - <Group guid="guidORMDesignerCommandSet" id="groupIdDisplayConstraintPosition" priority="0x0020"> + <Group guid="guidORMDesignerCommandSet" id="groupIdDisplayOrientation" priority="0x0020"> <Parent guid="guidORMDesignerCommandSet" id="menuIdDisplayOrientation"/> </Group> - <Group guid="guidORMDesignerCommandSet" id="groupIdDisplayReverseRoleOrder" priority="0x0030"> + <Group guid="guidORMDesignerCommandSet" id="groupIdDisplayConstraintPosition" priority="0x0030"> <Parent guid="guidORMDesignerCommandSet" id="menuIdDisplayOrientation"/> </Group> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |