From: <mcu...@us...> - 2008-08-14 21:36:15
|
Revision: 1320 http://orm.svn.sourceforge.net/orm/?rev=1320&view=rev Author: mcurland Date: 2008-08-14 21:36:23 +0000 (Thu, 14 Aug 2008) Log Message: ----------- Fixed miscellaneous usability and display issues: * Track before/after roles in adjusting ReadingOrder collections when new roles are inserted. fixes #226 * Added 'forError' parameter to IProxyDisplayProvider.ElementDisplayedAs to selectively activate shapes depending on the error. Do not activate entity shapes for duplicate name errors on collapsed value types. #153 * Allow dragging with ModelNoteConnector action to make behavior consistent with SubtypeConnectorAction. #359 * Internal constraint boxes and vertical role boxes were reporting incorrect bounds to accessibility readers. refs #185 Also: * Added support for most FactType commands to a ReadingShape selection, including activating the ReadingEditor window. Alignment and layout commits intentionally omitted. * ReadingShape was not updating display RolePlayer names when the role player was changed or the name modified * ValueTypes acting as reference mode values could not be added to a diagram, even if the corresponding entity has no shape. Modified Paths: -------------- trunk/ORMModel/ObjectModel/FactType.cs trunk/ORMModel/ObjectModel/ModelError.cs trunk/ORMModel/ObjectModel/ReadingOrder.cs trunk/ORMModel/ShapeModel/FactTypeShape.cs trunk/ORMModel/ShapeModel/ModelNoteConnectAction.cs trunk/ORMModel/ShapeModel/ORMDiagram.cs trunk/ORMModel/ShapeModel/ORMShape.AttachRules.cs trunk/ORMModel/ShapeModel/ORMShape.AttachRules.xml trunk/ORMModel/ShapeModel/ReadingShape.cs trunk/ORMModel/ShapeModel/ViewFixupRules.cs trunk/ORMModel/Shell/FactEditor/FactEditorSaver.cs trunk/ORMModel/Shell/ORMDocDataServices.cs trunk/ORMModel/Shell/ORMDocView.cs Modified: trunk/ORMModel/ObjectModel/FactType.cs =================================================================== --- trunk/ORMModel/ObjectModel/FactType.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ObjectModel/FactType.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -61,6 +61,18 @@ #endregion // IFactConstraint interface public partial class FactType : INamedElementDictionaryChild, INamedElementDictionaryRemoteParent, IModelErrorOwner, IVerbalizeCustomChildren, IHierarchyContextEnabled { + #region Public token values + /// <summary> + /// A key to set in the top-level transaction context to indicate the role that + /// a newly added role should be added after. + /// </summary> + public static readonly object InsertAfterRoleKey = new object(); + /// <summary> + /// A key to set in the top-level transaction context to indicate the role that + /// a newly added role should be added before. + /// </summary> + public static readonly object InsertBeforeRoleKey = new object(); + #endregion // Public token values #region ReadingOrder acquisition /// <summary> /// Gets a reading order, first by trying to find it, if one doesn't exist Modified: trunk/ORMModel/ObjectModel/ModelError.cs =================================================================== --- trunk/ORMModel/ObjectModel/ModelError.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ObjectModel/ModelError.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -300,9 +300,12 @@ /// passed in element. /// </summary> /// <param name="element">The element to find a proxy for</param> + /// <param name="forError">The <see cref="ModelError"/> that is being displayed. + /// If the displayed as element does not display this error, then it should not + /// be identified as a proxy display.</param> /// <returns>The proxy display element. Return the element itself or null /// if there is no proxy.</returns> - ModelElement ElementDisplayedAs(ModelElement element); + ModelElement ElementDisplayedAs(ModelElement element, ModelError forError); } #endregion // IProxyDisplayProvider #region AssociatedErrorElementCallback delegate Modified: trunk/ORMModel/ObjectModel/ReadingOrder.cs =================================================================== --- trunk/ORMModel/ObjectModel/ReadingOrder.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ObjectModel/ReadingOrder.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -272,32 +272,92 @@ /// This allows it to be used by both the rule and to be called /// during post load model fixup. /// </summary> - private static void ValidateReadingOrdersRoleCollection(FactType theFact, RoleBase addedRole) + private static void ValidateReadingOrdersRoleCollection(FactType factType, RoleBase addedRole) { - Debug.Assert(theFact.Store.TransactionManager.InTransaction); + Debug.Assert(factType.Store.TransactionManager.InTransaction); - LinkedElementCollection<ReadingOrder> readingOrders = theFact.ReadingOrderCollection; - int orderCount = readingOrders.Count; - if (orderCount != 0) + LinkedElementCollection<ReadingOrder> readingOrders; + int orderCount; + if (null == factType.UnaryRole && + 0 != (orderCount = (readingOrders = factType.ReadingOrderCollection).Count)) { - bool isUnaryFactType = theFact.UnaryRole != null; + bool checkedContext = false; + bool insertAfter = false; + RoleBase insertBeside = null; + IFormatProvider formatProvider = CultureInfo.InvariantCulture; for (int i = 0; i < orderCount; ++i) { ReadingOrder ord = readingOrders[i]; LinkedElementCollection<RoleBase> roles = ord.RoleCollection; - if (!roles.Contains(addedRole) && !isUnaryFactType) + if (!roles.Contains(addedRole)) { - ord.RoleCollection.Add(addedRole); + if (!checkedContext) + { + checkedContext = true; + Dictionary<object, object> contextInfo = factType.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo; + object contextRole; + if (contextInfo.TryGetValue(FactType.InsertAfterRoleKey, out contextRole)) + { + insertBeside = contextRole as RoleBase; + insertAfter = true; + } + else if (contextInfo.TryGetValue(FactType.InsertBeforeRoleKey, out contextRole)) + { + insertBeside = contextRole as RoleBase; + } + } + int insertIndex = -1; + if (insertBeside != null) + { + insertIndex = roles.IndexOf(insertBeside); + } + + if (insertIndex != -1) + { + roles.Insert(insertIndex + (insertAfter ? 1 : 0), addedRole); + } + else + { + roles.Add(addedRole); + } LinkedElementCollection<Reading> readings = ord.ReadingCollection; int readingCount = readings.Count; if (readingCount != 0) { - string appendText = String.Concat(" {", (roles.Count - 1).ToString(CultureInfo.InvariantCulture), "}"); - for (int j = 0; j < readingCount; ++j) + if (insertIndex == -1) { - Reading reading = readings[j]; - reading.SetAutoText(reading.Text + appendText); + string appendText = string.Concat(" {", (roles.Count - 1).ToString(CultureInfo.InvariantCulture), "}"); + for (int j = 0; j < readingCount; ++j) + { + Reading reading = readings[j]; + reading.SetAutoText(reading.Text + appendText); + } } + else + { + for (int j = 0; j < readingCount; ++j) + { + Reading reading = readings[j]; + reading.SetAutoText(Reading.ReplaceFields( + reading.Text, + delegate(int replaceIndex) + { + // UNDONE: Respect leading/trailing hyphen binding and keep them associated + // with the corresponding role. Will require work well beyond the scope of this + // routine. + if (replaceIndex == insertIndex) + { + return string.Concat("{", insertIndex.ToString(formatProvider), "} {", (insertIndex + 1).ToString(formatProvider), "}"); + } + else if (replaceIndex > insertIndex) + { + return string.Concat("{", (replaceIndex + 1).ToString(formatProvider), "}"); + } + return null; // Leave as is + } + )); + } + } } } } Modified: trunk/ORMModel/ShapeModel/FactTypeShape.cs =================================================================== --- trunk/ORMModel/ShapeModel/FactTypeShape.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ShapeModel/FactTypeShape.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -43,18 +43,6 @@ #region FactTypeShape class public partial class FactTypeShape : ICustomShapeFolding, IModelErrorActivation, IProvideConnectorShape { - #region Public token values - /// <summary> - /// A key to set in the top-level transaction context to indicate the role that - /// a newly added role should be added after. - /// </summary> - public static readonly object InsertAfterRoleKey = new object(); - /// <summary> - /// A key to set in the top-level transaction context to indicate the role that - /// a newly added role should be added before. - /// </summary> - public static readonly object InsertBeforeRoleKey = new object(); - #endregion // Public token values #region ConstraintBoxRoleActivity enum /// <summary> /// The activity of a role in a ConstraintBox @@ -2198,7 +2186,28 @@ /// <returns>The vertical slice for this role</returns> public sealed override RectangleD GetBounds(ShapeElement parentShape, ShapeField parentField) { - return parentField.GetBounds(parentShape); + RectangleD retVal = RectangleD.Empty; + IConstraint testConstraint = myAssociatedConstraint; + if (testConstraint != null) + { + ((FactTypeShape)parentShape).WalkConstraintBoxes( + parentField, + ((ConstraintShapeField)parentField).AttachPosition, + delegate(ref ConstraintBox constraintBox) + { + if (constraintBox.FactConstraint.Constraint == testConstraint) + { + retVal = constraintBox.Bounds; + return false; // Don't continue, we got our item + } + return true; + }); + } + if (retVal.IsEmpty) + { + retVal = parentField.GetBounds(parentShape); + } + return retVal; } #endregion // Required ShapeSubField #region Accessor functions @@ -2747,11 +2756,30 @@ RectangleD retVal = parentField.GetBounds(parentShape); FactTypeShape parentFactShape = parentShape as FactTypeShape; LinkedElementCollection<RoleBase> roles = parentFactShape.DisplayedRoleOrder; - retVal.Width /= roles.Count; + int roleCount = roles.Count; int roleIndex = roles.IndexOf(myAssociatedRole); - if (roleIndex > 0) + DisplayOrientation orientation = parentFactShape.DisplayOrientation; + switch (orientation) { - retVal.Offset(roleIndex * retVal.Width, 0); + case DisplayOrientation.Horizontal: + retVal.Width /= roleCount; + if (roleIndex > 0) + { + retVal.Offset(roleIndex * retVal.Width, 0); + } + break; + case DisplayOrientation.VerticalRotatedLeft: + case DisplayOrientation.VerticalRotatedRight: + retVal.Height /= roleCount; + if (orientation == DisplayOrientation.VerticalRotatedLeft) + { + roleIndex = roleCount - roleIndex - 1; + } + if (roleIndex > 0) + { + retVal.Offset(0, roleIndex * retVal.Height); + } + break; } return retVal; } Modified: trunk/ORMModel/ShapeModel/ModelNoteConnectAction.cs =================================================================== --- trunk/ORMModel/ShapeModel/ModelNoteConnectAction.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ShapeModel/ModelNoteConnectAction.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -250,6 +250,16 @@ } } /// <summary> + /// Allow dragging the source element onto the target + /// </summary> + protected override void OnDraggingBegun(MouseActionEventArgs e) + { + if (mySourceElement == null) + { + mySourceElement = ElementFromShape<ORMModelElement>(MouseDownHitShape); + } + base.OnDraggingBegun(e); + } /// <summary> /// If we're emulating a drag (occurs when we're chained from RoleDragPendingAction), /// then complete the action on mouse up /// </summary> Modified: trunk/ORMModel/ShapeModel/ORMDiagram.cs =================================================================== --- trunk/ORMModel/ShapeModel/ORMDiagram.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ShapeModel/ORMDiagram.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -930,7 +930,7 @@ return !objectifiedShape.ExpandRefMode; } } - return objectType.HasReferenceMode; + return false; // If a shape can't be found, then do not collapse, regardless of objectType.HasReferenceMode } #if SHOW_FACTSHAPE_FOR_SUBTYPE /// <summary>See <see cref="ORMDiagramBase.CreateChildShape"/>.</summary> @@ -1698,14 +1698,15 @@ /// <summary> /// Implements IProxyDisplayProvider.ElementDisplayedAs /// </summary> - protected ModelElement ElementDisplayedAs(ModelElement element) + protected ModelElement ElementDisplayedAs(ModelElement element, ModelError forError) { ObjectType objectElement; ExclusionConstraint exclusionConstraint; SetConstraint setConstraint; if (null != (objectElement = element as ObjectType)) { - if (!ShouldDisplayObjectType(objectElement)) + if (!ShouldDisplayObjectType(objectElement) && + !(forError is ObjectTypeDuplicateNameError)) { FactType nestedFact = objectElement.NestedFactType; if (nestedFact != null) @@ -1749,9 +1750,9 @@ } return null; } - ModelElement IProxyDisplayProvider.ElementDisplayedAs(ModelElement element) + ModelElement IProxyDisplayProvider.ElementDisplayedAs(ModelElement element, ModelError forError) { - return ElementDisplayedAs(element); + return ElementDisplayedAs(element, forError); } #endregion // IProxyDisplayProvider Implementation #region IMergeElements implementation Modified: trunk/ORMModel/ShapeModel/ORMShape.AttachRules.cs =================================================================== --- trunk/ORMModel/ShapeModel/ORMShape.AttachRules.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ShapeModel/ORMShape.AttachRules.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -105,6 +105,10 @@ typeof(ReadingShape).GetNestedType("ReadingTextChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ReadingShape).GetNestedType("RoleDisplayOrderAddedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ReadingShape).GetNestedType("RoleDisplayOrderPositionChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), + typeof(ReadingShape).GetNestedType("RolePlayerAddedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), + typeof(ReadingShape).GetNestedType("RolePlayerChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), + typeof(ReadingShape).GetNestedType("RolePlayerDeletedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), + typeof(ReadingShape).GetNestedType("RolePlayerRolePlayerChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(RingConstraintShape).GetNestedType("RingConstraintPropertyChangeRuleClass", BindingFlags.Public | BindingFlags.NonPublic), typeof(ValueConstraintShape).GetNestedType("ValueConstraintTextChangedRuleClass", BindingFlags.Public | BindingFlags.NonPublic)}; ORMShapeDomainModel.myCustomDomainModelTypes = retVal; @@ -140,7 +144,7 @@ { Microsoft.VisualStudio.Modeling.RuleManager ruleManager = store.RuleManager; Type[] disabledRuleTypes = ORMShapeDomainModel.CustomDomainModelTypes; - for (int i = 0; i < 73; ++i) + for (int i = 0; i < 77; ++i) { ruleManager.EnableRule(disabledRuleTypes[i]); } @@ -2051,6 +2055,110 @@ Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleEnd(e.SourceElement.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RoleDisplayOrderPositionChangedRule"); } } + [Microsoft.VisualStudio.Modeling.RuleOn(typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=Microsoft.VisualStudio.Modeling.TimeToFire.TopLevelCommit, Priority=Microsoft.VisualStudio.Modeling.Diagrams.DiagramFixupConstants.ResizeParentRulePriority)] + private sealed class RolePlayerAddedRuleClass : Microsoft.VisualStudio.Modeling.AddRule + { + [System.Diagnostics.DebuggerStepThrough()] + public RolePlayerAddedRuleClass() + { + base.IsEnabled = false; + } + /// <summary> + /// Provide the following method in class: + /// Neumont.Tools.ORM.ShapeModel.ReadingShape + /// /// <summary> + /// /// AddRule: typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; + /// /// </summary> + /// private static void RolePlayerAddedRule(ElementAddedEventArgs e) + /// { + /// } + /// </summary> + [System.Diagnostics.DebuggerStepThrough()] + public override void ElementAdded(Microsoft.VisualStudio.Modeling.ElementAddedEventArgs e) + { + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleStart(e.ModelElement.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RolePlayerAddedRule"); + ReadingShape.RolePlayerAddedRule(e); + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleEnd(e.ModelElement.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RolePlayerAddedRule"); + } + } + [Microsoft.VisualStudio.Modeling.RuleOn(typeof(Neumont.Tools.ORM.ObjectModel.ObjectType), FireTime=Microsoft.VisualStudio.Modeling.TimeToFire.TopLevelCommit, Priority=Microsoft.VisualStudio.Modeling.Diagrams.DiagramFixupConstants.ResizeParentRulePriority)] + private sealed class RolePlayerChangedRuleClass : Microsoft.VisualStudio.Modeling.ChangeRule + { + [System.Diagnostics.DebuggerStepThrough()] + public RolePlayerChangedRuleClass() + { + base.IsEnabled = false; + } + /// <summary> + /// Provide the following method in class: + /// Neumont.Tools.ORM.ShapeModel.ReadingShape + /// /// <summary> + /// /// ChangeRule: typeof(Neumont.Tools.ORM.ObjectModel.ObjectType), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; + /// /// </summary> + /// private static void RolePlayerChangedRule(ElementPropertyChangedEventArgs e) + /// { + /// } + /// </summary> + [System.Diagnostics.DebuggerStepThrough()] + public override void ElementPropertyChanged(Microsoft.VisualStudio.Modeling.ElementPropertyChangedEventArgs e) + { + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleStart(e.ModelElement.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RolePlayerChangedRule"); + ReadingShape.RolePlayerChangedRule(e); + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleEnd(e.ModelElement.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RolePlayerChangedRule"); + } + } + [Microsoft.VisualStudio.Modeling.RuleOn(typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=Microsoft.VisualStudio.Modeling.TimeToFire.TopLevelCommit, Priority=Microsoft.VisualStudio.Modeling.Diagrams.DiagramFixupConstants.ResizeParentRulePriority)] + private sealed class RolePlayerDeletedRuleClass : Microsoft.VisualStudio.Modeling.DeleteRule + { + [System.Diagnostics.DebuggerStepThrough()] + public RolePlayerDeletedRuleClass() + { + base.IsEnabled = false; + } + /// <summary> + /// Provide the following method in class: + /// Neumont.Tools.ORM.ShapeModel.ReadingShape + /// /// <summary> + /// /// DeleteRule: typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; + /// /// </summary> + /// private static void RolePlayerDeletedRule(ElementDeletedEventArgs e) + /// { + /// } + /// </summary> + [System.Diagnostics.DebuggerStepThrough()] + public override void ElementDeleted(Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs e) + { + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleStart(e.ModelElement.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RolePlayerDeletedRule"); + ReadingShape.RolePlayerDeletedRule(e); + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleEnd(e.ModelElement.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RolePlayerDeletedRule"); + } + } + [Microsoft.VisualStudio.Modeling.RuleOn(typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=Microsoft.VisualStudio.Modeling.TimeToFire.TopLevelCommit, Priority=Microsoft.VisualStudio.Modeling.Diagrams.DiagramFixupConstants.ResizeParentRulePriority)] + private sealed class RolePlayerRolePlayerChangedRuleClass : Microsoft.VisualStudio.Modeling.RolePlayerChangeRule + { + [System.Diagnostics.DebuggerStepThrough()] + public RolePlayerRolePlayerChangedRuleClass() + { + base.IsEnabled = false; + } + /// <summary> + /// Provide the following method in class: + /// Neumont.Tools.ORM.ShapeModel.ReadingShape + /// /// <summary> + /// /// RolePlayerChangeRule: typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; + /// /// </summary> + /// private static void RolePlayerRolePlayerChangedRule(RolePlayerChangedEventArgs e) + /// { + /// } + /// </summary> + [System.Diagnostics.DebuggerStepThrough()] + public override void RolePlayerChanged(Microsoft.VisualStudio.Modeling.RolePlayerChangedEventArgs e) + { + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleStart(e.ElementLink.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RolePlayerRolePlayerChangedRule"); + ReadingShape.RolePlayerRolePlayerChangedRule(e); + Neumont.Tools.Modeling.Diagnostics.TraceUtility.TraceRuleEnd(e.ElementLink.Store, "Neumont.Tools.ORM.ShapeModel.ReadingShape.RolePlayerRolePlayerChangedRule"); + } + } } #endregion // Rule classes for ReadingShape #region Rule classes for RingConstraintShape Modified: trunk/ORMModel/ShapeModel/ORMShape.AttachRules.xml =================================================================== --- trunk/ORMModel/ShapeModel/ORMShape.AttachRules.xml 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ShapeModel/ORMShape.AttachRules.xml 2008-08-14 21:36:23 UTC (rev 1320) @@ -257,6 +257,18 @@ <arg:RolePlayerPositionChangeRule methodName="RoleDisplayOrderPositionChangedRule"> <arg:RuleOn targetType="FactTypeShapeHasRoleDisplayOrder" fireTime="TopLevelCommit" priority="DiagramFixupConstants.ResizeParentRulePriority"/> </arg:RolePlayerPositionChangeRule> + <arg:AddRule methodName="RolePlayerAddedRule"> + <arg:RuleOn targetType="ObjectTypePlaysRole" targetTypeQualifier="Neumont.Tools.ORM.ObjectModel" fireTime="TopLevelCommit" priority="DiagramFixupConstants.ResizeParentRulePriority"/> + </arg:AddRule> + <arg:ChangeRule methodName="RolePlayerChangedRule"> + <arg:RuleOn targetType="ObjectType" targetTypeQualifier="Neumont.Tools.ORM.ObjectModel" fireTime="TopLevelCommit" priority="DiagramFixupConstants.ResizeParentRulePriority"/> + </arg:ChangeRule> + <arg:DeleteRule methodName="RolePlayerDeletedRule"> + <arg:RuleOn targetType="ObjectTypePlaysRole" targetTypeQualifier="Neumont.Tools.ORM.ObjectModel" fireTime="TopLevelCommit" priority="DiagramFixupConstants.ResizeParentRulePriority"/> + </arg:DeleteRule> + <arg:RolePlayerChangeRule methodName="RolePlayerRolePlayerChangedRule"> + <arg:RuleOn targetType="ObjectTypePlaysRole" targetTypeQualifier="Neumont.Tools.ORM.ObjectModel" fireTime="TopLevelCommit" priority="DiagramFixupConstants.ResizeParentRulePriority"/> + </arg:RolePlayerChangeRule> </arg:RuleContainer> <arg:RuleContainer class="RingConstraintShape"> <arg:ChangeRule methodName="RingConstraintPropertyChangeRule"> Modified: trunk/ORMModel/ShapeModel/ReadingShape.cs =================================================================== --- trunk/ORMModel/ShapeModel/ReadingShape.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ShapeModel/ReadingShape.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -440,25 +440,37 @@ } return retVal; } - /// <summary> + /// Cause the reading shape for a role to invalidate + /// </summary> + private static void InvalidateReadingShape(Role role) + { + FactType factType; + if (null != role && + null != (factType = role.FactType)) + { + InvalidateReadingShape(factType); + } + } + /// <summary> /// Causes the ReadingShape on a FactTypeShape to invalidate /// </summary> public static void InvalidateReadingShape(FactType factType) { - foreach (ShapeElement se in PresentationViewsSubject.GetPresentation(factType)) + if (factType != null) { - FactTypeShape factShape = se as FactTypeShape; - if (factShape != null) + foreach (ShapeElement se in PresentationViewsSubject.GetPresentation(factType)) { - foreach (ShapeElement se2 in se.RelativeChildShapes) + FactTypeShape factShape = se as FactTypeShape; + if (factShape != null) { - ReadingShape readShape = se2 as ReadingShape; - if (readShape != null) + foreach (ShapeElement se2 in se.RelativeChildShapes) { - readShape.myDisplayText = null; - readShape.InvalidateRequired(true); - readShape.AutoResize(); + ReadingShape readShape = se2 as ReadingShape; + if (readShape != null) + { + readShape.InvalidateDisplayText(); + } } } } @@ -1009,6 +1021,69 @@ } } /// <summary> + /// AddRule: typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; + /// Update readings when the set of role player names is modified + /// </summary> + private static void RolePlayerAddedRule(ElementAddedEventArgs e) + { + ObjectTypePlaysRole link = (ObjectTypePlaysRole)e.ModelElement; + if (!link.IsDeleted) + { + InvalidateReadingShape(link.PlayedRole); + } + } + /// <summary> + /// DeleteRule: typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; + /// Update readings when the set of role player names is modified + /// </summary> + private static void RolePlayerDeletedRule(ElementDeletedEventArgs e) + { + ObjectTypePlaysRole link = (ObjectTypePlaysRole)e.ModelElement; + Role role = link.PlayedRole; + if (!role.IsDeleted) + { + InvalidateReadingShape(role); + } + } + /// <summary> + /// RolePlayerChangeRule: typeof(Neumont.Tools.ORM.ObjectModel.ObjectTypePlaysRole), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; + /// Update readings when the set of role player names is modified + /// </summary> + private static void RolePlayerRolePlayerChangedRule(RolePlayerChangedEventArgs e) + { + ObjectTypePlaysRole link = (ObjectTypePlaysRole)e.ElementLink; + if (!link.IsDeleted) + { + if (e.DomainRole.Id == ObjectTypePlaysRole.RolePlayerDomainRoleId) + { + InvalidateReadingShape(link.PlayedRole); + } + else + { + InvalidateReadingShape((Role)e.OldRolePlayer); + InvalidateReadingShape((Role)e.NewRolePlayer); + } + } + } + /// <summary> + /// ChangeRule: typeof(Neumont.Tools.ORM.ObjectModel.ObjectType), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.ResizeParentRulePriority; + /// Update readings when the set of role player names is modified + /// </summary> + private static void RolePlayerChangedRule(ElementPropertyChangedEventArgs e) + { + if (e.DomainProperty.Id == ObjectType.NameDomainPropertyId) + { + ObjectType objectType = (ObjectType)e.ModelElement; + if (!objectType.IsDeleted) + { + foreach (Role role in ObjectTypePlaysRole.GetPlayedRoleCollection(objectType)) + { + InvalidateReadingShape(role); + } + } + } + } + /// <summary> /// ChangeRule: typeof(Neumont.Tools.ORM.ObjectModel.Reading), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddShapeRulePriority; /// Rule to notice changes to Reading.Text properties so that the /// reading shapes can have their display text invalidated. Modified: trunk/ORMModel/ShapeModel/ViewFixupRules.cs =================================================================== --- trunk/ORMModel/ShapeModel/ViewFixupRules.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/ShapeModel/ViewFixupRules.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -452,20 +452,19 @@ { Store store = shape.Store; Dictionary<object, object> contextInfo = store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo; + object contextRole; int insertIndex = -1; - if (contextInfo.ContainsKey(FactTypeShape.InsertAfterRoleKey)) + if (contextInfo.TryGetValue(FactType.InsertAfterRoleKey, out contextRole)) { - RoleBase insertAfter = (RoleBase)contextInfo[FactTypeShape.InsertAfterRoleKey]; - insertIndex = roles.IndexOf(insertAfter); + insertIndex = roles.IndexOf(contextRole as RoleBase); if (insertIndex != -1) { ++insertIndex; } } - else if (contextInfo.ContainsKey(FactTypeShape.InsertBeforeRoleKey)) + else if (contextInfo.TryGetValue(FactType.InsertBeforeRoleKey, out contextRole)) { - RoleBase insertBefore = (RoleBase)contextInfo[FactTypeShape.InsertBeforeRoleKey]; - insertIndex = roles.IndexOf(insertBefore); + insertIndex = roles.IndexOf(contextRole as RoleBase); } if (insertIndex != -1) { Modified: trunk/ORMModel/Shell/FactEditor/FactEditorSaver.cs =================================================================== --- trunk/ORMModel/Shell/FactEditor/FactEditorSaver.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/Shell/FactEditor/FactEditorSaver.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -440,8 +440,8 @@ { if (matchedRoles[i] == null) { - // UNDONE: Consider using the FactTypeShape.InsertAfterRoleKey - // and FactTypeShape.InsertBeforeRoleKey context information + // UNDONE: Consider using the FactType.InsertAfterRoleKey + // and FactType.InsertBeforeRoleKey context information // to modify display of inserted roles. // Use an existing role if we have it Modified: trunk/ORMModel/Shell/ORMDocDataServices.cs =================================================================== --- trunk/ORMModel/Shell/ORMDocDataServices.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/Shell/ORMDocDataServices.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -1681,6 +1681,7 @@ } } ModelElement startElement = element; + ModelError modelError = locator as ModelError; IProxyDisplayProvider proxyProvider = null; bool useProxy = false; bool haveCurrentDesigner = false; @@ -1707,7 +1708,7 @@ if (useProxy) { // Second pass, we were unable to find a suitable shape for the first - selectElement = proxyProvider.ElementDisplayedAs(element); + selectElement = proxyProvider.ElementDisplayedAs(element, modelError); if (selectElement != null && selectElement == element) { selectElement = null; @@ -1791,12 +1792,11 @@ if (targetDocData.ActivateShapeHelper(shape, ref currentDocView, ref currentDesigner, ref haveCurrentDesigner)) { - ModelError error; IModelErrorActivation activator; - if (null != (error = locator as ModelError) & + if (null != modelError && null != (activator = shape as IModelErrorActivation)) { - activator.ActivateModelError(error); + activator.ActivateModelError(modelError); } return true; } Modified: trunk/ORMModel/Shell/ORMDocView.cs =================================================================== --- trunk/ORMModel/Shell/ORMDocView.cs 2008-08-13 00:58:40 UTC (rev 1319) +++ trunk/ORMModel/Shell/ORMDocView.cs 2008-08-14 21:36:23 UTC (rev 1320) @@ -854,13 +854,15 @@ checkedCommands = ORMDesignerCommands.None; toleratedCommands = ORMDesignerCommands.None; FactType factType; + ReadingOrder readingOrder = null; Role role; ObjectType objectType; NodeShape nodeShape; SetConstraint setConstraint; SetComparisonConstraint setComparisonConstraint = null; bool otherShape = false; - if (null != (factType = element as FactType)) + if (null != (factType = element as FactType) || + (null != (readingOrder = element as ReadingOrder) && null != (factType = readingOrder.FactType))) { visibleCommands = enabledCommands = ORMDesignerCommands.DeleteFactType | ORMDesignerCommands.DeleteAny | ORMDesignerCommands.DisplayReadingsWindow; Objectification objectification = factType.Objectification; @@ -874,11 +876,16 @@ visibleCommands |= ORMDesignerCommands.UnobjectifyFactType; enabledCommands |= ORMDesignerCommands.UnobjectifyFactType; } - FactTypeShape factShape; - if (null != (factShape = presentationElement as FactTypeShape)) + if (presentationElement is FactTypeShape || + (readingOrder != null && presentationElement is ReadingShape)) { - visibleCommands |= ORMDesignerCommands.DeleteFactShape | ORMDesignerCommands.DeleteAnyShape | ORMDesignerCommands.AutoLayout | ORMDesignerCommands.AlignShapes | ORMDesignerCommands.DisplayOrientation | ORMDesignerCommands.DisplayConstraintsPosition; - enabledCommands |= ORMDesignerCommands.DeleteFactShape | ORMDesignerCommands.DeleteAnyShape | ORMDesignerCommands.AutoLayout | ORMDesignerCommands.AlignShapes | ORMDesignerCommands.DisplayOrientation | ORMDesignerCommands.DisplayConstraintsPosition; + visibleCommands |= ORMDesignerCommands.DeleteFactShape | ORMDesignerCommands.DeleteAnyShape | ORMDesignerCommands.DisplayOrientation | ORMDesignerCommands.DisplayConstraintsPosition; + enabledCommands |= ORMDesignerCommands.DeleteFactShape | ORMDesignerCommands.DeleteAnyShape | ORMDesignerCommands.DisplayOrientation | ORMDesignerCommands.DisplayConstraintsPosition; + if (readingOrder == null) + { + visibleCommands |= ORMDesignerCommands.AutoLayout | ORMDesignerCommands.AlignShapes; + enabledCommands |= ORMDesignerCommands.AutoLayout | ORMDesignerCommands.AlignShapes; + } // Don't flag the DisplayOrientation or DisplayConstraintsPosition commands as checkable, multiselect check state mismatches handled dynamically in OnStatusCommand if (factType.RoleCollection.Count > 1) { @@ -1287,11 +1294,14 @@ bool isChecked = true; foreach (ModelElement mel in docView.SelectedElements) { - FactTypeShape shape = mel as FactTypeShape; - if (shape != null) + FactTypeShape factTypeShape; + ReadingShape readingShape; + if (null != (factTypeShape = mel as FactTypeShape) || + (null != (readingShape = mel as ReadingShape) && + null != (factTypeShape = readingShape.ParentShape as FactTypeShape))) { // The command is checked when all selected values match the expected orientation - if (shape.DisplayOrientation != expectedOrientation) + if (factTypeShape.DisplayOrientation != expectedOrientation) { isChecked = false; break; @@ -1316,11 +1326,14 @@ bool isChecked = true; foreach (ModelElement mel in docView.SelectedElements) { - FactTypeShape shape = mel as FactTypeShape; - if (shape != null) + FactTypeShape factTypeShape; + ReadingShape readingShape; + if (null != (factTypeShape = mel as FactTypeShape) || + (null != (readingShape = mel as ReadingShape) && + null != (factTypeShape = readingShape.ParentShape as FactTypeShape))) { // The command is checked when all selected values match the expected orientation - if (shape.ConstraintDisplayPosition != expectedPosition) + if (factTypeShape.ConstraintDisplayPosition != expectedPosition) { isChecked = false; break; @@ -1796,19 +1809,20 @@ mel = pel.ModelElement; // Remove the actual object in the model - if (mel != null && !mel.IsDeleted && !(mel is ReadingOrder)) + if (mel != null && !mel.IsDeleted) { Role role; if (null != (role = mel as Role) && pel is RoleNameShape) { role.Name = ""; } - else if (mel is ReadingOrder) - { - // Reading orders tolerate the delete command, but are not deleted directly - } else { + ReadingOrder readingOrder = mel as ReadingOrder; + if (readingOrder != null) + { + mel = readingOrder.FactType; + } // Check if the object shape was in expanded mode bool testRefModeCollapse = complexSelection || 0 != (enabledCommands & ORMDesignerCommands.DeleteObjectType); ObjectTypeShape objectShape; @@ -1890,15 +1904,24 @@ ModelElement mel = selectedElements[i] as ModelElement; PresentationElement pel = mel as ShapeElement; ObjectType backingObjectifiedType = null; - // ReadingShape and ValueConstraintShape tolerate deletion, but the - // shapes cannot be deleted individually if (pel != null && !pel.IsDeleted) { ObjectifiedFactTypeNameShape objectifiedObjectShape; - if (pel is ReadingShape || pel is ValueConstraintShape) + ReadingShape readingShape; + if (pel is ValueConstraintShape) { + // ValueConstraintShape tolerates deletion, but the + // shapes cannot be deleted individually continue; } + else if (null != (readingShape = pel as ReadingShape)) + { + pel = readingShape.ParentShape; + if (pel == null) + { + continue; + } + } else if (null != (objectifiedObjectShape = pel as ObjectifiedFactTypeNameShape)) { // The two parts of an objectification should always appear together, @@ -2279,11 +2302,11 @@ if (insertAfter) { ++insertIndex; - contextInfo[FactTypeShape.InsertAfterRoleKey] = role; + contextInfo[FactType.InsertAfterRoleKey] = role; } else { - contextInfo[FactTypeShape.InsertBeforeRoleKey] = role; + contextInfo[FactType.InsertBeforeRoleKey] = role; } //bool aggressivelyKillValueType = store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo.ContainsKey(DeleteReferenceModeValueType); @@ -3254,8 +3277,12 @@ IList selectedElements = SelectedElements; for (int i = selectedElements.Count - 1; i >= 0; i--) { - FactTypeShape factTypeShape = selectedElements[i] as FactTypeShape; - if (factTypeShape != null) + ModelElement element = selectedElements[i] as ModelElement; + FactTypeShape factTypeShape; + ReadingShape readingShape; + if (null != (factTypeShape = element as FactTypeShape) || + (null != (readingShape = element as ReadingShape) && + null != (factTypeShape = readingShape.ParentShape as FactTypeShape))) { factTypeShape.DisplayOrientation = orientation; } @@ -3287,8 +3314,12 @@ IList selectedElements = SelectedElements; for (int i = selectedElements.Count - 1; i >= 0; i--) { - FactTypeShape factTypeShape = selectedElements[i] as FactTypeShape; - if (factTypeShape != null) + ModelElement element = selectedElements[i] as ModelElement; + FactTypeShape factTypeShape; + ReadingShape readingShape; + if (null != (factTypeShape = element as FactTypeShape) || + (null != (readingShape = element as ReadingShape) && + null != (factTypeShape = readingShape.ParentShape as FactTypeShape))) { factTypeShape.ConstraintDisplayPosition = position; } @@ -3307,8 +3338,12 @@ IList selectedElements = SelectedElements; for (int i = selectedElements.Count - 1; i >= 0; i--) { - FactTypeShape factTypeShape = selectedElements[i] as FactTypeShape; - if (factTypeShape != null) + ModelElement element = selectedElements[i] as ModelElement; + FactTypeShape factTypeShape; + ReadingShape readingShape; + if (null != (factTypeShape = element as FactTypeShape) || + (null != (readingShape = element as ReadingShape) && + null != (factTypeShape = readingShape.ParentShape as FactTypeShape))) { factTypeShape.ReverseDisplayedRoleOrder(); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |