From: <mcu...@us...> - 2012-10-04 01:30:35
|
Revision: 1493 http://orm.svn.sourceforge.net/orm/?rev=1493&view=rev Author: mcurland Date: 2012-10-04 01:30:28 +0000 (Thu, 04 Oct 2012) Log Message: ----------- Bug fixes for shape creation scenarios * ORMDiagram.AutoPopulateShapes (set during import scenarios) was no longer effective after changes in [1482] to reduce phantom shape creation. Add an additional fixup listener to automatically add object type and fact type shapes for all elements to a diagram when this property is set. * Duplicating a fact type shape with a connected role value constraint on the same diagram or in a different model did not recreate the rang link shape (the dotted line) for the new shape. * Cross-model dragging of value constraint shapes on both value type and fact type shapes reverted copied shape position to the default location. Modified Paths: -------------- trunk/ORMModel/Framework/DeserializationManager.cs trunk/ORMModel/Framework/Diagrams/MultiShapeUtility.cs trunk/ORMModel/ObjectModel/ORMModel.cs trunk/ORMModel/ShapeModel/ORMShape.DeserializationFixupListeners.cs trunk/ORMModel/ShapeModel/ReadingShape.cs trunk/ORMModel/ShapeModel/RoleNameShape.cs trunk/ORMModel/ShapeModel/ValueRangeShape.cs trunk/ORMModel/ShapeModel/ViewFixupRules.cs Modified: trunk/ORMModel/Framework/DeserializationManager.cs =================================================================== --- trunk/ORMModel/Framework/DeserializationManager.cs 2012-10-04 01:16:54 UTC (rev 1492) +++ trunk/ORMModel/Framework/DeserializationManager.cs 2012-10-04 01:30:28 UTC (rev 1493) @@ -326,21 +326,26 @@ /// <summary> /// The first standard fixup phase for loading presentation elements. /// </summary> - FirstPresentationElementPhase = ValidateStoredPresentationElements, + FirstPresentationElementPhase = AutoCreateStoredPresentationElements, + /// <summary> + /// Initialized automatically created stored presentation elements that + /// will be serialized with the model. + /// </summary> + AutoCreateStoredPresentationElements = 5100, /// <summary> /// Fixup stored presentation elements /// </summary> - ValidateStoredPresentationElements = 5100, + ValidateStoredPresentationElements = 5200, /// <summary> /// Validate presentation elements that are implicitly recreated /// if they are not serialized. /// </summary> - ValidateImplicitStoredPresentationElements = 5200, + ValidateImplicitStoredPresentationElements = 5300, /// <summary> /// Add any presentation elements that are implicit and not /// serialized with the model. /// </summary> - AddImplicitPresentationElements = 5300, + AddImplicitPresentationElements = 5400, /// <summary> /// The last standard fixup phase for loading presentation elements. /// </summary> Modified: trunk/ORMModel/Framework/Diagrams/MultiShapeUtility.cs =================================================================== --- trunk/ORMModel/Framework/Diagrams/MultiShapeUtility.cs 2012-10-04 01:16:54 UTC (rev 1492) +++ trunk/ORMModel/Framework/Diagrams/MultiShapeUtility.cs 2012-10-04 01:30:28 UTC (rev 1493) @@ -149,7 +149,8 @@ } } - if (allowMultipleShapesForChildren) + if (allowMultipleShapesForChildren && + (existingChildShape == null || existingChildShape is LinkShape || existingChildShape.ParentShape != existingParentShape)) { if (unparentedChildShape == null) { @@ -188,10 +189,10 @@ existingChildShape.OnBoundsFixup(BoundsFixupState.ViewFixup, 0, false); //fix up grand child shapes - ICollection GrandChildShapes = existingChildShape.GetChildElements(childElement); - foreach (ModelElement GrandChildShape in GrandChildShapes) + ICollection grandChildShapes = existingChildShape.GetChildElements(childElement); + foreach (ModelElement grandChildShape in grandChildShapes) { - existingChildShape.FixUpChildShapes(GrandChildShape); + existingChildShape.FixUpChildShapes(grandChildShape); } return existingChildShape; Modified: trunk/ORMModel/ObjectModel/ORMModel.cs =================================================================== --- trunk/ORMModel/ObjectModel/ORMModel.cs 2012-10-04 01:16:54 UTC (rev 1492) +++ trunk/ORMModel/ObjectModel/ORMModel.cs 2012-10-04 01:30:28 UTC (rev 1493) @@ -70,11 +70,15 @@ /// explicit, intrinsic, and implicit elements are in place. /// </summary> ValidateErrors = StandardFixupPhase.LastModelElementPhase + 200, - /// <summary> + /// <summary> + /// Create implicitly stored presentation elements + /// </summary> + AutoCreateStoredPresentationElements = StandardFixupPhase.AutoCreateStoredPresentationElements, + /// <summary> /// Fixup stored presentation elements /// </summary> ValidateStoredPresentationElements = StandardFixupPhase.ValidateStoredPresentationElements, - /// <summary> + /// <summary> /// Add any presentation elements that are implicit and not /// serialized with the model. /// </summary> Modified: trunk/ORMModel/ShapeModel/ORMShape.DeserializationFixupListeners.cs =================================================================== --- trunk/ORMModel/ShapeModel/ORMShape.DeserializationFixupListeners.cs 2012-10-04 01:16:54 UTC (rev 1492) +++ trunk/ORMModel/ShapeModel/ORMShape.DeserializationFixupListeners.cs 2012-10-04 01:30:28 UTC (rev 1493) @@ -38,7 +38,8 @@ yield return new DisplayValueTypeValueConstraintFixupListener(); yield return new DisplayRoleNameFixupListener(); yield return new DisplayModelNoteLinksFixupListener(); - yield return FactTypeShape.FixupListener; + yield return new DisplayAutoPopulatedShapesFixupListener(); + yield return FactTypeShape.FixupListener; yield return ReadingShape.FixupListener; yield return ObjectTypeShape.FixupListener; yield return ObjectifiedFactTypeNameShape.FixupListener; Modified: trunk/ORMModel/ShapeModel/ReadingShape.cs =================================================================== --- trunk/ORMModel/ShapeModel/ReadingShape.cs 2012-10-04 01:16:54 UTC (rev 1492) +++ trunk/ORMModel/ShapeModel/ReadingShape.cs 2012-10-04 01:30:28 UTC (rev 1493) @@ -331,24 +331,27 @@ /// <param name="createdDuringViewFixup">Whether this shape was created as part of a view fixup</param> public override void PlaceAsChildOf(NodeShape parent, bool createdDuringViewFixup) { - FactTypeShape factTypeShape = (FactTypeShape)parent; - FactType factType; - Objectification objectification; AutoResize(); - SizeD size = Size; - double yOffset; - if (factTypeShape.ConstraintDisplayPosition == ConstraintDisplayPosition.Bottom && - (null == (factType = factTypeShape.AssociatedFactType) || - null == (objectification = factType.Objectification) || - objectification.IsImplied)) + if (createdDuringViewFixup) { - yOffset = -1.5 * size.Height; + FactTypeShape factTypeShape = (FactTypeShape)parent; + FactType factType; + Objectification objectification; + SizeD size = Size; + double yOffset; + if (factTypeShape.ConstraintDisplayPosition == ConstraintDisplayPosition.Bottom && + (null == (factType = factTypeShape.AssociatedFactType) || + null == (objectification = factType.Objectification) || + objectification.IsImplied)) + { + yOffset = -1.5 * size.Height; + } + else + { + yOffset = factTypeShape.Size.Height + .5 * size.Height; + } + Location = new PointD(0, yOffset); } - else - { - yOffset = factTypeShape.Size.Height + .5 * size.Height; - } - Location = new PointD(0, yOffset); } /// <summary> /// Overrides default implemenation to instantiate an Reading specific one. Modified: trunk/ORMModel/ShapeModel/RoleNameShape.cs =================================================================== --- trunk/ORMModel/ShapeModel/RoleNameShape.cs 2012-10-04 01:16:54 UTC (rev 1492) +++ trunk/ORMModel/ShapeModel/RoleNameShape.cs 2012-10-04 01:30:28 UTC (rev 1493) @@ -96,19 +96,22 @@ /// <param name="createdDuringViewFixup">Whether this shape was created as part of a view fixup</param> public override void PlaceAsChildOf(NodeShape parent, bool createdDuringViewFixup) { - FactTypeShape factShape = (FactTypeShape)parent; - double x = -0.2; - double y = -0.2; - FactType factType = factShape.AssociatedFactType; - // Cascades RoleNameShapes for facts that contain more than one role - LinkedElementCollection<RoleBase> roles = factShape.DisplayedRoleOrder; - int roleIndex = roles.IndexOf((RoleBase)ModelElement); - if (roleIndex != -1) + if (createdDuringViewFixup) { - x += roleIndex * 0.15; - y -= roleIndex * 0.15; + FactTypeShape factShape = (FactTypeShape)parent; + double x = -0.2; + double y = -0.2; + FactType factType = factShape.AssociatedFactType; + // Cascades RoleNameShapes for facts that contain more than one role + LinkedElementCollection<RoleBase> roles = factShape.DisplayedRoleOrder; + int roleIndex = roles.IndexOf((RoleBase)ModelElement); + if (roleIndex != -1) + { + x += roleIndex * 0.15; + y -= roleIndex * 0.15; + } + Location = new PointD(x, y); } - Location = new PointD(x, y); } /// <summary> /// Highlight both the name shape and the corresponding role box. Modified: trunk/ORMModel/ShapeModel/ValueRangeShape.cs =================================================================== --- trunk/ORMModel/ShapeModel/ValueRangeShape.cs 2012-10-04 01:16:54 UTC (rev 1492) +++ trunk/ORMModel/ShapeModel/ValueRangeShape.cs 2012-10-04 01:30:28 UTC (rev 1493) @@ -180,12 +180,15 @@ public override void PlaceAsChildOf(NodeShape parent, bool createdDuringViewFixup) { AutoResize(); - SizeD size = Size; - RectangleD parentBounds = ParentShape.AbsoluteBoundingBox; - // Place slightly to the right. This will cause the label to - // track in this position due to a horizontal resize of the - // shape because of rename, etc - Location = new PointD(parentBounds.Width + .06, -1 * size.Height); + if (createdDuringViewFixup) + { + SizeD size = Size; + RectangleD parentBounds = ParentShape.AbsoluteBoundingBox; + // Place slightly to the right. This will cause the label to + // track in this position due to a horizontal resize of the + // shape because of rename, etc + Location = new PointD(parentBounds.Width + .06, -1 * size.Height); + } } /// <summary> /// Overrides default implemenation to instantiate an value constraint specific one. Modified: trunk/ORMModel/ShapeModel/ViewFixupRules.cs =================================================================== --- trunk/ORMModel/ShapeModel/ViewFixupRules.cs 2012-10-04 01:16:54 UTC (rev 1492) +++ trunk/ORMModel/ShapeModel/ViewFixupRules.cs 2012-10-04 01:30:28 UTC (rev 1493) @@ -794,8 +794,6 @@ ORMModel model = factType.Model; if (model != null) { - Diagram.FixUpDiagram(factType, roleValueConstraint); - object AllowMultipleShapes; Dictionary<object, object> topLevelContextInfo; bool containedAllowMultipleShapes; @@ -804,6 +802,8 @@ topLevelContextInfo.Add(AllowMultipleShapes, null); } + Diagram.FixUpDiagram(factType, roleValueConstraint); + foreach (PresentationViewsSubject presentationViewsSubject in DomainRoleInfo.GetElementLinks<PresentationViewsSubject>(model, PresentationViewsSubject.SubjectDomainRoleId)) { ORMDiagram diagram; @@ -813,7 +813,6 @@ foreach (ValueConstraintShape shapeElement in MultiShapeUtility.FindAllShapesForElement<ValueConstraintShape>(diagram, roleValueConstraint)) { diagram.FixUpLocalDiagram(link); - break; } } } @@ -880,7 +879,20 @@ if (null != (objectType = valueConstraint.ValueType) && null != (model = objectType.Model)) { + object AllowMultipleShapes; + Dictionary<object, object> topLevelContextInfo; + bool containedAllowMultipleShapes; + if (!(containedAllowMultipleShapes = (topLevelContextInfo = link.Store.TransactionManager.CurrentTransaction.TopLevelTransaction.Context.ContextInfo).ContainsKey(AllowMultipleShapes = MultiShapeUtility.AllowMultipleShapes))) + { + topLevelContextInfo.Add(AllowMultipleShapes, null); + } + Diagram.FixUpDiagram(objectType, valueConstraint); + + if (!containedAllowMultipleShapes) + { + topLevelContextInfo.Remove(AllowMultipleShapes); + } } } /// <summary> @@ -901,8 +913,6 @@ null != (objectType = uniquenessConstraint.PreferredIdentifierFor) && null != (model = objectType.Model)) { - Diagram.FixUpDiagram(objectType, roleValueConstraint); - object AllowMultipleShapes; Dictionary<object, object> topLevelContextInfo; bool containedAllowMultipleShapes; @@ -911,6 +921,7 @@ topLevelContextInfo.Add(AllowMultipleShapes, null); } + Diagram.FixUpDiagram(objectType, roleValueConstraint); Diagram.FixUpDiagram(model, link); if (!containedAllowMultipleShapes) @@ -1231,9 +1242,66 @@ } } #endregion // ModelNote fixup - #region ForceClearViewFixupDataListRuleClass - partial class ForceClearViewFixupDataListRuleClass + #region Auto populated diagram fixup + #region DisplayAutoPopulatedShapesFixupListener class + /// <summary> + /// A fixup class to create top-level shapes for auotmatically populated ORM diagrams. + /// </summary> + /// <remarks>This used to happen automatically when fixup listeners for implicit + /// links verified the existence of the shapes they were attaching too. However, this + /// had too many side effects, so we now check this condition explicitly on load.</remarks> + private sealed class DisplayAutoPopulatedShapesFixupListener : DeserializationFixupListener<ORMDiagram> { + /// <summary> + /// Create a new DisplayAutoPopulatedShapesFixupListener + /// </summary> + public DisplayAutoPopulatedShapesFixupListener() + : base((int)ORMDeserializationFixupPhase.AutoCreateStoredPresentationElements) + { + } + /// <summary> + /// Add top-level auto populated shapes to a diagram + /// </summary> + /// <param name="element">An ORMDiagram instance</param> + /// <param name="store">The context store</param> + /// <param name="notifyAdded">The listener to notify if elements are added during fixup</param> + protected sealed override void ProcessElement(ORMDiagram element, Store store, INotifyElementAdded notifyAdded) + { + if (element.AutoPopulateShapes) + { + IElementDirectory elementDir = store.ElementDirectory; + ShapeElement shape; + foreach (ObjectType objectType in elementDir.FindElements<ObjectType>(false)) + { + Objectification objectification; + if (!objectType.IsImplicitBooleanValue && + (null == (objectification = objectType.Objectification) || !objectification.IsImplied)) + { + if (null != (shape = element.FixUpLocalDiagram(element, objectType))) + { + notifyAdded.ElementAdded(shape, true); + } + } + } + foreach (FactType factType in elementDir.FindElements<FactType>(false)) + { + if (null == factType.ImpliedByObjectification) + { + if (null != (shape = element.FixUpLocalDiagram(element, factType))) + { + notifyAdded.ElementAdded(shape, true); + } + } + + } + } + } + } + #endregion // DisplayModelNoteLinksFixupListener class + #endregion // Auto populated diagram fixup + #region ForceClearViewFixupDataListRuleClass + partial class ForceClearViewFixupDataListRuleClass + { #region Dynamic Microsoft.VisualStudio.Modeling.Diagrams.Diagram.GetViewFixupDataListCount implementation private delegate int GetViewFixupDataListCountDelegate(Diagram @this); private static readonly GetViewFixupDataListCountDelegate GetViewFixupDataListCount = CreateGetViewFixupDataListCount(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |