| 
      
      
      From: <mcu...@us...> - 2009-06-11 02:53:09
      
     | 
| Revision: 1392
          http://orm.svn.sourceforge.net/orm/?rev=1392&view=rev
Author:   mcurland
Date:     2009-06-11 01:31:05 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
 * Fix for phantom shape bug on other diagrams with objectify command. Also, objectifying to an existing entity folds an ObjectType shape into a close FactTypeShape instead of replacing the ObjectTypeShape. Modifications of [1385] refs #321
 * DisplayRelatedTypes property showing on a shape for an unobjectified FactType, and hiding subtype lines connected to more than one constraint or note caused 'subscript out of range' error. refs #392
 * Delete Page/Undo would put the page back in a different position if the 'Diagram Management' extension was turned off.
 * Relational name generator needs to save settings if the default values when the name generator is recreated differ from the current settings (forum issue).
 * SetComparisonConstraint editor modified to always begin a new role sequence on commit if the constraint does not have enough sequences.
Modified Paths:
--------------
    trunk/ORM2CommandLineTest/ORMDocServices.cs
    trunk/ORMModel/Framework/Diagrams/MultiShapeUtility.cs
    trunk/ORMModel/Framework/Shell/MultiDiagramDocView.cs
    trunk/ORMModel/ObjectModel/NameGenerator.cs
    trunk/ORMModel/ShapeModel/Design/FactTypeShapeTypeDescriptor.cs
    trunk/ORMModel/ShapeModel/ExternalConstraintConnectAction.cs
    trunk/ORMModel/ShapeModel/FactTypeShape.cs
    trunk/ORMModel/ShapeModel/ViewFixupRules.cs
    trunk/RelationalModel/OialDcilBridge/NameGeneration.cs
Modified: trunk/ORM2CommandLineTest/ORMDocServices.cs
===================================================================
--- trunk/ORM2CommandLineTest/ORMDocServices.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/ORM2CommandLineTest/ORMDocServices.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -196,11 +196,11 @@
 			}
 			#endregion // IORMFontAndColorService Implementation
 			#region IPropertyProviderService Implementation
-			void IPropertyProviderService.GetProvidedProperties(ModelElement extendableElement, System.ComponentModel.PropertyDescriptorCollection properties)
+			void IPropertyProviderService.GetProvidedProperties(object extendableElement, System.ComponentModel.PropertyDescriptorCollection properties)
 			{
 				// This is implemented on a per-store basis, we don't implement it on the testing document
 			}
-			void IPropertyProviderService.AddOrRemovePropertyProvider<TExtendableElement>(PropertyProvider propertyProvider, bool includeSubtypes, EventHandlerAction action)
+			void IPropertyProviderService.AddOrRemovePropertyProvider(Type extendableElementType, PropertyProvider propertyProvider, bool includeSubtypes, EventHandlerAction action)
 			{
 				// This is implemented on a per-store basis, we don't implement it on the testing document
 			}
Modified: trunk/ORMModel/Framework/Diagrams/MultiShapeUtility.cs
===================================================================
--- trunk/ORMModel/Framework/Diagrams/MultiShapeUtility.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/ORMModel/Framework/Diagrams/MultiShapeUtility.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -271,16 +271,12 @@
 		/// <returns><see cref="IEnumerable{LinkShapeType}"/></returns>
 		public static IEnumerable<LinkShapeType> GetEffectiveAttachedLinkShapes<LinkShapeType>(ShapeElement shape) where LinkShapeType : LinkShape
 		{
-			LinkedElementCollection<LinkShape> links;
-			int linkCount;
 			NodeShape nodeShape = shape as NodeShape;
 			if (nodeShape != null)
 			{
-				links = LinkConnectsToNode.GetLink(nodeShape);
-				linkCount = links.Count;
-				for (int i = 0; i < linkCount; ++i)
+				foreach (LinkShape link in LinkConnectsToNode.GetLink(nodeShape))
 				{
-					LinkShapeType linkShape = links[i] as LinkShapeType;
+					LinkShapeType linkShape = link as LinkShapeType;
 					if (linkShape != null)
 					{
 						yield return linkShape;
@@ -289,21 +285,17 @@
 			}
 			if (shape is IProvideConnectorShape)
 			{
-				LinkedElementCollection<ShapeElement> childShapes = shape.RelativeChildShapes;
-				int childCount = childShapes.Count;
-				for (int j = 0; j < childCount; ++j)
+				foreach (ShapeElement child in shape.RelativeChildShapes)
 				{
-					NodeShape child;
+					NodeShape childShape;
 					IProxyConnectorShape proxy;
-					if (null != (child = childShapes[j] as NodeShape) &&
-						null != (proxy = child as IProxyConnectorShape))
+					if (null != (childShape = child as NodeShape) &&
+						null != (proxy = childShape as IProxyConnectorShape))
 					{
 						Debug.Assert(proxy.ProxyConnectorShapeFor == shape);
-						links = LinkConnectsToNode.GetLink(child);
-						linkCount = links.Count;
-						for (int i = 0; i < linkCount; ++i)
+						foreach (LinkShape link in LinkConnectsToNode.GetLink(childShape))
 						{
-							LinkShapeType linkShape = links[i] as LinkShapeType;
+							LinkShapeType linkShape = link as LinkShapeType;
 							if (linkShape != null)
 							{
 								yield return linkShape;
@@ -314,6 +306,19 @@
 			}
 		}
 		/// <summary>
+		/// Get all link shapes of a given type attached to the specified <paramref name="shape"/>
+		/// or to any relative child shapes that implement <see cref="IProxyConnectorShape"/>.
+		/// </summary>
+		/// <typeparam name="LinkShapeType">A link shape type derived from <see cref="LinkShape"/></typeparam>
+		/// <param name="shape">The shape to retrieve links for</param>
+		/// <param name="snapshot">The caller may change the resulting set, return a snapshot copy of the current data. Default false.</param>
+		/// <returns><see cref="IEnumerable{LinkShapeType}"/></returns>
+		public static IEnumerable<LinkShapeType> GetEffectiveAttachedLinkShapes<LinkShapeType>(ShapeElement shape, bool snapshot) where LinkShapeType : LinkShape
+		{
+			IEnumerable<LinkShapeType> retVal = GetEffectiveAttachedLinkShapes<LinkShapeType>(shape);
+			return snapshot ? new List<LinkShapeType>(retVal) : retVal;
+		}
+		/// <summary>
 		/// Get all <see cref="BinaryLinkShape">binary link shapes</see> of a given type originating from
 		/// the specified <paramref name="shape"/> or to any relative child shapes that implement <see cref="IProxyConnectorShape"/>.
 		/// </summary>
@@ -322,16 +327,12 @@
 		/// <returns><see cref="IEnumerable{LinkShapeType}"/></returns>
 		public static IEnumerable<LinkShapeType> GetEffectiveAttachedLinkShapesFrom<LinkShapeType>(ShapeElement shape) where LinkShapeType : BinaryLinkShape
 		{
-			LinkedElementCollection<LinkShape> links;
-			int linkCount;
 			NodeShape nodeShape = shape as NodeShape;
 			if (nodeShape != null)
 			{
-				links = LinkConnectsToNode.GetLink(nodeShape);
-				linkCount = links.Count;
-				for (int i = 0; i < linkCount; ++i)
+				foreach (LinkShape link in LinkConnectsToNode.GetLink(nodeShape))
 				{
-					LinkShapeType linkShape = links[i] as LinkShapeType;
+					LinkShapeType linkShape = link as LinkShapeType;
 					if (linkShape != null && linkShape.FromShape == shape)
 					{
 						yield return linkShape;
@@ -340,22 +341,18 @@
 			}
 			if (shape is IProvideConnectorShape)
 			{
-				LinkedElementCollection<ShapeElement> childShapes = shape.RelativeChildShapes;
-				int childCount = childShapes.Count;
-				for (int j = 0; j < childCount; ++j)
+				foreach (ShapeElement child in shape.RelativeChildShapes)
 				{
-					NodeShape child;
+					NodeShape childShape;
 					IProxyConnectorShape proxy;
-					if (null != (child = childShapes[j] as NodeShape) &&
-						null != (proxy = child as IProxyConnectorShape))
+					if (null != (childShape = child as NodeShape) &&
+						null != (proxy = childShape as IProxyConnectorShape))
 					{
 						Debug.Assert(proxy.ProxyConnectorShapeFor == shape);
-						links = LinkConnectsToNode.GetLink(child);
-						linkCount = links.Count;
-						for (int i = 0; i < linkCount; ++i)
+						foreach (LinkShape link in LinkConnectsToNode.GetLink(childShape))
 						{
-							LinkShapeType linkShape = links[i] as LinkShapeType;
-							if (linkShape != null && linkShape.FromShape == child)
+							LinkShapeType linkShape = link as LinkShapeType;
+							if (linkShape != null && linkShape.FromShape == childShape)
 							{
 								yield return linkShape;
 							}
@@ -365,6 +362,19 @@
 			}
 		}
 		/// <summary>
+		/// Get all <see cref="BinaryLinkShape">binary link shapes</see> of a given type originating from
+		/// the specified <paramref name="shape"/> or to any relative child shapes that implement <see cref="IProxyConnectorShape"/>.
+		/// </summary>
+		/// <typeparam name="LinkShapeType">A link shape type derived from <see cref="LinkShape"/></typeparam>
+		/// <param name="shape">The shape to retrieve links for</param>
+		/// <param name="snapshot">The caller may change the resulting set, return a snapshot copy of the current data. Default false.</param>
+		/// <returns><see cref="IEnumerable{LinkShapeType}"/></returns>
+		public static IEnumerable<LinkShapeType> GetEffectiveAttachedLinkShapesFrom<LinkShapeType>(ShapeElement shape, bool snapshot) where LinkShapeType : BinaryLinkShape
+		{
+			IEnumerable<LinkShapeType> retVal = GetEffectiveAttachedLinkShapesFrom<LinkShapeType>(shape);
+			return snapshot ? new List<LinkShapeType>(retVal) : retVal;
+		}
+		/// <summary>
 		/// Get all <see cref="BinaryLinkShape">binary link shapes</see> of a given type going to
 		/// the specified <paramref name="shape"/> or to any relative child shapes that implement <see cref="IProxyConnectorShape"/>.
 		/// </summary>
@@ -373,16 +383,12 @@
 		/// <returns><see cref="IEnumerable{LinkShapeType}"/></returns>
 		public static IEnumerable<LinkShapeType> GetEffectiveAttachedLinkShapesTo<LinkShapeType>(ShapeElement shape) where LinkShapeType : BinaryLinkShape
 		{
-			LinkedElementCollection<LinkShape> links;
-			int linkCount;
 			NodeShape nodeShape = shape as NodeShape;
 			if (nodeShape != null)
 			{
-				links = LinkConnectsToNode.GetLink(nodeShape);
-				linkCount = links.Count;
-				for (int i = 0; i < linkCount; ++i)
+				foreach (LinkShape link in LinkConnectsToNode.GetLink(nodeShape))
 				{
-					LinkShapeType linkShape = links[i] as LinkShapeType;
+					LinkShapeType linkShape = link as LinkShapeType;
 					if (linkShape != null && linkShape.ToShape == shape)
 					{
 						yield return linkShape;
@@ -391,22 +397,18 @@
 			}
 			if (shape is IProvideConnectorShape)
 			{
-				LinkedElementCollection<ShapeElement> childShapes = shape.RelativeChildShapes;
-				int childCount = childShapes.Count;
-				for (int j = 0; j < childCount; ++j)
+				foreach (ShapeElement child in shape.RelativeChildShapes)
 				{
-					NodeShape child;
+					NodeShape childShape;
 					IProxyConnectorShape proxy;
-					if (null != (child = childShapes[j] as NodeShape) &&
-						null != (proxy = child as IProxyConnectorShape))
+					if (null != (childShape = child as NodeShape) &&
+						null != (proxy = childShape as IProxyConnectorShape))
 					{
 						Debug.Assert(proxy.ProxyConnectorShapeFor == shape);
-						links = LinkConnectsToNode.GetLink(child);
-						linkCount = links.Count;
-						for (int i = 0; i < linkCount; ++i)
+						foreach (LinkShape link in LinkConnectsToNode.GetLink(childShape))
 						{
-							LinkShapeType linkShape = links[i] as LinkShapeType;
-							if (linkShape != null && linkShape.ToShape == child)
+							LinkShapeType linkShape = link as LinkShapeType;
+							if (linkShape != null && linkShape.ToShape == childShape)
 							{
 								yield return linkShape;
 							}
@@ -415,6 +417,19 @@
 				}
 			}
 		}
+		/// <summary>
+		/// Get all <see cref="BinaryLinkShape">binary link shapes</see> of a given type going to
+		/// the specified <paramref name="shape"/> or to any relative child shapes that implement <see cref="IProxyConnectorShape"/>.
+		/// </summary>
+		/// <typeparam name="LinkShapeType">A link shape type derived from <see cref="BinaryLinkShape"/></typeparam>
+		/// <param name="shape">The shape to retrieve links for</param>
+		/// <param name="snapshot">The caller may change the resulting set, return a snapshot copy of the current data. Default false.</param>
+		/// <returns><see cref="IEnumerable{LinkShapeType}"/></returns>
+		public static IEnumerable<LinkShapeType> GetEffectiveAttachedLinkShapesTo<LinkShapeType>(ShapeElement shape, bool snapshot) where LinkShapeType : BinaryLinkShape
+		{
+			IEnumerable<LinkShapeType> retVal = GetEffectiveAttachedLinkShapesTo<LinkShapeType>(shape);
+			return snapshot ? new List<LinkShapeType>(retVal) : retVal;
+		}
 		#endregion // GetEffectiveAttachedLinkShapes variants
 		#region Link Configuration
 		/// <summary>
@@ -497,11 +512,11 @@
 				foreach (ShapeElement shape in FindAllShapesForElement<ShapeElement>(diagram, originalShape.ModelElement))
 				{
 					bool shapeIsOriginal = (shape == originalShape);
-					foreach (BinaryLinkShape toLinkShape in GetExistingLinks(shape, true, false))
+					foreach (BinaryLinkShape toLinkShape in GetExistingLinks(shape, true, false, null, true))
 					{
 						CheckLink(toLinkShape, shapeIsOriginal, BinaryLinkAnchor.ToShape, discludedShape);
 					}
-					foreach (BinaryLinkShape fromLinkShape in GetExistingLinks(shape, false, true))
+					foreach (BinaryLinkShape fromLinkShape in GetExistingLinks(shape, false, true, null, true))
 					{
 						CheckLink(fromLinkShape, shapeIsOriginal, BinaryLinkAnchor.FromShape, discludedShape);
 					}
@@ -510,7 +525,7 @@
 				Dictionary<ModelElement, IReconfigureableLink> reconfigureableLinks = null;
 				foreach (ShapeElement shape in FindAllShapesForElement<ShapeElement>(diagram, element))
 				{
-					foreach (BinaryLinkShape linkShape in GetExistingLinks(shape, true, true, null))
+					foreach (BinaryLinkShape linkShape in GetExistingLinks(shape, true, true, null, true))
 					{
 						if (linkShape is IProvideConnectorShape)
 						{
@@ -1100,7 +1115,7 @@
 								// A link could be attached to this link. Make sure the
 								// link is moved to a new location or cleanly deleted before
 								// the link itself is deleted.
-								foreach (BinaryLinkShape recursiveLink in GetExistingLinks(pendingDeleteLinkShape, true, true, null))
+								foreach (BinaryLinkShape recursiveLink in GetExistingLinks(pendingDeleteLinkShape, true, true, null, true))
 								{
 									IReconfigureableLink recurseReconfigureLink = recursiveLink as IReconfigureableLink;
 									if (recurseReconfigureLink != null)
@@ -1218,7 +1233,7 @@
 		private static bool AlreadyConnectedTo(ShapeElement currentShape, ModelElement oppositeElement, bool isFromShape, BinaryLinkShape currentLink)
 		{
 			//check each link to see if it connects to the opposite element
-			foreach (BinaryLinkShape linkShape in GetExistingLinks(currentShape, !isFromShape, isFromShape, currentLink.ModelElement))
+			foreach (BinaryLinkShape linkShape in GetExistingLinks(currentShape, !isFromShape, isFromShape, currentLink.ModelElement, false))
 			{
 				//if the link is the one currently being configured, count it as not connected
 				if (linkShape == currentLink)
@@ -1257,17 +1272,18 @@
 		/// <param name="getToLinks">True to collect all to role links</param>
 		/// <param name="getFromLinks">True to collect all from role links</param>
 		/// <param name="linkBackingElement">Only return links that have this element as the <see cref="PresentationElement.ModelElement">ModelElement</see>.</param>
+		/// <param name="snapshot">The caller may change the resulting set, return a snapshot copy of the current data.</param>
 		/// <returns>The attached link shapes</returns>
-		private static IEnumerable<BinaryLinkShape> GetExistingLinks(ShapeElement shape, bool getToLinks, bool getFromLinks, ModelElement linkBackingElement)
+		private static IEnumerable<BinaryLinkShape> GetExistingLinks(ShapeElement shape, bool getToLinks, bool getFromLinks, ModelElement linkBackingElement, bool snapshot)
 		{
 			Debug.Assert(getToLinks || getFromLinks, "Either getToLinks or fromFromLinks needs to be true");
 
 			foreach (BinaryLinkShape linkShape in
 				(getToLinks && getFromLinks) ?
-					MultiShapeUtility.GetEffectiveAttachedLinkShapes<BinaryLinkShape>(shape) :
+					MultiShapeUtility.GetEffectiveAttachedLinkShapes<BinaryLinkShape>(shape, snapshot) :
 					(getToLinks ?
-					MultiShapeUtility.GetEffectiveAttachedLinkShapesTo<BinaryLinkShape>(shape) :
-					MultiShapeUtility.GetEffectiveAttachedLinkShapesFrom<BinaryLinkShape>(shape)))
+					MultiShapeUtility.GetEffectiveAttachedLinkShapesTo<BinaryLinkShape>(shape, snapshot) :
+					MultiShapeUtility.GetEffectiveAttachedLinkShapesFrom<BinaryLinkShape>(shape, snapshot)))
 			{
 				if (linkBackingElement == null || linkShape.ModelElement == linkBackingElement)
 				{
Modified: trunk/ORMModel/Framework/Shell/MultiDiagramDocView.cs
===================================================================
--- trunk/ORMModel/Framework/Shell/MultiDiagramDocView.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/ORMModel/Framework/Shell/MultiDiagramDocView.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -428,6 +428,7 @@
 			{
 				throw new ArgumentNullException("designer");
 			}
+			myVerifyPageOrder = true;
 			MultiDiagramDocViewControl docViewControl = DocViewControl;
 			int tabCount = docViewControl.TabCount;
 			DiagramTabPage tabPage = new DiagramTabPage(docViewControl, designer);
@@ -653,10 +654,14 @@
 							eventManager.AddOrRemoveHandler(classInfo, new EventHandler<ElementDeletedEventArgs>(VerifyPageOrderEvent), action);
 							eventManager.AddOrRemoveHandler(classInfo, new EventHandler<RolePlayerOrderChangedEventArgs>(VerifyPageOrderEvent), action);
 							eventManager.AddOrRemoveHandler(classInfo, new EventHandler<RolePlayerChangedEventArgs>(VerifyPageOrderEvent), action);
-							eventManager.AddOrRemoveHandler(new EventHandler<ElementEventsEndedEventArgs>(ElementEventsEndedEvent), action);
 						}
 					}
 				}
+				else if (0 != (reasons & EventSubscriberReasons.UserInterfaceEvents))
+				{
+					eventManager.AddOrRemoveHandler(new EventHandler<ElementEventsBegunEventArgs>(ElementEventsBegunEvent), action);
+					eventManager.AddOrRemoveHandler(new EventHandler<ElementEventsEndedEventArgs>(ElementEventsEndedEvent), action);
+				}
 			}
 		}
 		void IModelingEventSubscriber.ManageModelingEventHandlers(ModelingEventManager eventManager, EventSubscriberReasons reasons, EventHandlerAction action)
@@ -670,6 +675,10 @@
 		{
 			myVerifyPageOrder = true;
 		}
+		private void ElementEventsBegunEvent(object sender, ElementEventsBegunEventArgs e)
+		{
+			myVerifyPageOrder = false;
+		}
 		/// <summary>
 		/// Verify tab order when events have complete
 		/// </summary>
@@ -680,12 +689,25 @@
 				myVerifyPageOrder = false;
 				MultiDiagramDocViewControl control;
 				Store store;
-				IList<DiagramDisplay> containers;
 				if (null != (control = myDocViewControl) &&
-					null != (store = this.Store) &&
-					0 != (containers = store.ElementDirectory.FindElements<DiagramDisplay>(false)).Count)
+					null != (store = this.Store))
 				{
-					control.VerifyDiagramOrder(containers[0].OrderedDiagramCollection);
+					if (null != store.FindDomainModel(DiagramDisplayDomainModel.DomainModelId))
+					{
+						IList<DiagramDisplay> containers;
+						if (0 != (containers = store.ElementDirectory.FindElements<DiagramDisplay>(false)).Count)
+						{
+							control.VerifyDiagramOrder(containers[0].OrderedDiagramCollection);
+						}
+					}
+					else
+					{
+						IList<Diagram> diagrams;
+						if (0 != (diagrams = store.DefaultPartition.ElementDirectory.FindElements<Diagram>(true)).Count)
+						{
+							control.VerifyDiagramOrder(diagrams);
+						}
+					}
 				}
 			}
 		}
Modified: trunk/ORMModel/ObjectModel/NameGenerator.cs
===================================================================
--- trunk/ORMModel/ObjectModel/NameGenerator.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/ORMModel/ObjectModel/NameGenerator.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -72,20 +72,18 @@
 		/// </summary>
 		protected bool RequiresSerialization()
 		{
-			NameGenerator refinesGenerator = RefinesGenerator;
-			bool retVal = (refinesGenerator != null) ?
-				(refinesGenerator.CasingOption != CasingOption ||
-				refinesGenerator.SpacingFormat != SpacingFormat ||
-				refinesGenerator.SpacingReplacement != SpacingReplacement ||
-				refinesGenerator.AutomaticallyShortenNames != AutomaticallyShortenNames ||
-				refinesGenerator.UserDefinedMaximum != UserDefinedMaximum ||
-				refinesGenerator.UseTargetDefaultMaximum != UseTargetDefaultMaximum) :
-				(CasingOption != NameGeneratorCasingOption.None ||
-				SpacingFormat != NameGeneratorSpacingFormat.Retain ||
-				SpacingReplacement.Length != 0 ||
-				!AutomaticallyShortenNames ||
-				UserDefinedMaximum != 128 ||
-				!UseTargetDefaultMaximum);
+			bool retVal = !HasDefaultAttributeValues(null);
+			NameGenerator refinesGenerator;
+			if (!retVal &&
+				null != (refinesGenerator = RefinesGenerator))
+			{
+				retVal = refinesGenerator.CasingOption != CasingOption ||
+					refinesGenerator.SpacingFormat != SpacingFormat ||
+					refinesGenerator.SpacingReplacement != SpacingReplacement ||
+					refinesGenerator.AutomaticallyShortenNames != AutomaticallyShortenNames ||
+					refinesGenerator.UserDefinedMaximum != UserDefinedMaximum ||
+					refinesGenerator.UseTargetDefaultMaximum != UseTargetDefaultMaximum;
+			}
 			if (!retVal)
 			{
 				foreach (NameGenerator refinement in RefinedByGeneratorCollection)
@@ -99,6 +97,30 @@
 			}
 			return retVal;
 		}
+		/// <summary>
+		/// Verify if this instance has fully default values
+		/// </summary>
+		/// <param name="ignorePropertyIds">Domain property identifiers that should not be checked. Designed
+		/// to be called by a derived class that overrides specific properties.</param>
+		/// <returns><see langword="true"/> if all values are default</returns>
+		protected virtual bool HasDefaultAttributeValues(Guid[] ignorePropertyIds)
+		{
+			if (ignorePropertyIds == null || ignorePropertyIds.Length == 0)
+			{
+				return CasingOption == NameGeneratorCasingOption.None &&
+					SpacingFormat == NameGeneratorSpacingFormat.Retain &&
+					SpacingReplacement.Length == 0 &&
+					AutomaticallyShortenNames &&
+					UserDefinedMaximum == 128 &&
+					UseTargetDefaultMaximum;
+			}
+			return (CasingOption == NameGeneratorCasingOption.None || Array.IndexOf<Guid>(ignorePropertyIds, CasingOptionDomainPropertyId) != -1) &&
+				(SpacingFormat == NameGeneratorSpacingFormat.Retain || Array.IndexOf<Guid>(ignorePropertyIds, SpacingFormatDomainPropertyId) != -1) &&
+				(SpacingReplacement.Length == 0 || Array.IndexOf<Guid>(ignorePropertyIds, SpacingReplacementDomainPropertyId) != -1) &&
+				(AutomaticallyShortenNames || Array.IndexOf<Guid>(ignorePropertyIds, AutomaticallyShortenNamesDomainPropertyId) != -1) &&
+				(UserDefinedMaximum == 128 || Array.IndexOf<Guid>(ignorePropertyIds, UserDefinedMaximumDomainPropertyId) != -1) &&
+				(UseTargetDefaultMaximum || Array.IndexOf<Guid>(ignorePropertyIds, UseTargetDefaultMaximumDomainPropertyId) != -1);
+		}
 		partial class SynchronizedRefinementsPropertyChangedRuleClass
 		{
 			private bool myIsDisabled;
Modified: trunk/ORMModel/ShapeModel/Design/FactTypeShapeTypeDescriptor.cs
===================================================================
--- trunk/ORMModel/ShapeModel/Design/FactTypeShapeTypeDescriptor.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/ORMModel/ShapeModel/Design/FactTypeShapeTypeDescriptor.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -64,6 +64,18 @@
 			return base.IsPropertyDescriptorReadOnly(propertyDescriptor);
 		}
 
+		/// <summary>
+		/// Block display of the DisplayRelatedTypes property on an unobjectified FactType
+		/// </summary>
+		protected override bool ShouldCreatePropertyDescriptor(ModelElement requestor, DomainPropertyInfo domainProperty)
+		{
+			if (domainProperty.Id == FactTypeShape.DisplayRelatedTypesDomainPropertyId)
+			{
+				return false;
+			}
+			return base.ShouldCreatePropertyDescriptor(requestor, domainProperty);
+		}
+
 		private static readonly object LockObject = new object();
 		private static volatile bool myCustomPropertyAttributesInitialized;
 		private static Attribute[] ConstraintDisplayPositionDomainPropertyAttributes;
Modified: trunk/ORMModel/ShapeModel/ExternalConstraintConnectAction.cs
===================================================================
--- trunk/ORMModel/ShapeModel/ExternalConstraintConnectAction.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/ORMModel/ShapeModel/ExternalConstraintConnectAction.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -622,7 +622,8 @@
 			// The ChainMouseAction call can reactivate this connect action,
 			// so make sure we snapshot the state we need and do all requisite
 			// cleanup before a potential reactivation.
-			ExternalConstraintShape chainOnShape = (myPendingOnClickedAction == OnClickedAction.Complete && !(myInitialSelectedRoles != null && myInitialSelectedRoles.Count != 0)) ? mySourceShape : null;
+			ExternalConstraintShape chainOnShape = (myPendingOnClickedAction == OnClickedAction.Complete) ? mySourceShape : null;
+			bool chainOnlyIfIncomplete = chainOnShape != null && myInitialSelectedRoles != null && myInitialSelectedRoles.Count != 0;
 			bool editingSubtypeFact = mySubtypeConnection;
 			Reset();
 			if (chainOnShape != null)
@@ -640,8 +641,11 @@
 							if (!editingSubtypeFact)
 							{
 								IConstraint editConstraint = chainOnShape.AssociatedConstraint;
-								int maximum = ConstraintUtility.RoleSequenceCountMaximum(editConstraint);
-								if (maximum < 0 || ((SetComparisonConstraint)editConstraint).RoleSequenceCollection.Count < maximum)
+								int maximum;
+								SetComparisonConstraint comparisonConstraint = (SetComparisonConstraint)editConstraint;
+								if (chainOnlyIfIncomplete ?
+									comparisonConstraint.TooFewRoleSequencesError != null :
+									(maximum = ConstraintUtility.RoleSequenceCountMaximum(editConstraint)) < 0 || comparisonConstraint.RoleSequenceCollection.Count < maximum)
 								{
 									ChainMouseAction(chainOnShape, e.DiagramClientView);
 								}
Modified: trunk/ORMModel/ShapeModel/FactTypeShape.cs
===================================================================
--- trunk/ORMModel/ShapeModel/FactTypeShape.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/ORMModel/ShapeModel/FactTypeShape.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -5098,33 +5098,57 @@
 				if (objectShape != null)
 				{
 					ORMDiagram currentDiagram = (ORMDiagram)objectShape.Diagram;
-					currentDiagram.PlaceORMElementOnDiagram(
-						null,
-						nestedFactType,
-						objectShape.Location,
-						ORMPlacementOption.AllowMultipleShapes,
-						delegate(ModelElement fixupElement, ShapeElement newShape)
+
+					// Search the current diagram and see if we have a shape for the FactType
+					// in the general vicinity. If we do, then we just delete the object shape
+					// and let role players bind directly to the FactType.
+					bool createNewShape = true;
+					RectangleD objectShapeVicinity = objectShape.AbsoluteBoundingBox;
+					objectShapeVicinity.Inflate(objectShapeVicinity.Height * 1.5, objectShapeVicinity.Width);
+					foreach (FactTypeShape factShape in MultiShapeUtility.FindAllShapesForElement<FactTypeShape>(currentDiagram, nestedFactType, true))
+					{
+						if (factShape.AbsoluteBoundingBox.IntersectsWith(objectShapeVicinity))
 						{
-							FactTypeShape factShape = (FactTypeShape)newShape;
+							createNewShape = false;
+							break;
+						}
+					}
+
+					if (createNewShape)
+					{
+						currentDiagram.PlaceORMElementOnDiagram(
+							null,
+							nestedFactType,
+							objectShape.Location,
+							ORMPlacementOption.AllowMultipleShapes,
+							delegate(ModelElement fixupElement, ShapeElement newShape)
+							{
+								FactTypeShape factShape = (FactTypeShape)newShape;
 #if TRACKNEWSHAPES
-							(newShapes ?? (newShapes = new List<FactTypeShape>())).Add(factShape);
+								(newShapes ?? (newShapes = new List<FactTypeShape>())).Add(factShape);
 #endif // TRACKNEWSHAPES
-							factShape.DisplayRelatedTypes = objectShape.DisplayRelatedTypes;
-						},
-						delegate(ModelElement fixupElement, ShapeElement newShape)
-						{
-							foreach (PresentationElement relativePel in newShape.RelativeChildShapes)
+								factShape.DisplayRelatedTypes = objectShape.DisplayRelatedTypes;
+							},
+							delegate(ModelElement fixupElement, ShapeElement newShape)
 							{
-								ObjectifiedFactTypeNameShape nameShape = relativePel as ObjectifiedFactTypeNameShape;
-								if (nameShape != null)
+								foreach (PresentationElement relativePel in newShape.RelativeChildShapes)
 								{
-									nameShape.ExpandRefMode = objectShape.ExpandRefMode;
-									break;
+									ObjectifiedFactTypeNameShape nameShape = relativePel as ObjectifiedFactTypeNameShape;
+									if (nameShape != null)
+									{
+										nameShape.ExpandRefMode = objectShape.ExpandRefMode;
+										break;
+									}
 								}
-							}
-							MultiShapeUtility.DetachLinks(objectShape);
-							objectShape.Delete();
-						});
+								MultiShapeUtility.DetachLinks(objectShape);
+								objectShape.Delete();
+							});
+					}
+					else
+					{
+						MultiShapeUtility.DetachLinks(objectShape);
+						objectShape.Delete();
+					}
 				}
 			}
 #if TRACKNEWSHAPES
@@ -5255,9 +5279,8 @@
 							// See if any links coming in apply to the ObjectType
 							bool needObjectShape = false;
 							bool needFactShape = false;
-							// The contents of the enumerator change over the course of this function,
-							// cache the list.
-							List<BinaryLinkShape> factShapeAttachedLinkShapes = new List<BinaryLinkShape>(MultiShapeUtility.GetEffectiveAttachedLinkShapes<BinaryLinkShape>(factShape));
+							// The contents of the enumerator change over the course of this function, get a snapshot enumerator
+							IEnumerable<BinaryLinkShape> factShapeAttachedLinkShapes = MultiShapeUtility.GetEffectiveAttachedLinkShapes<BinaryLinkShape>(factShape, true);
 							foreach (BinaryLinkShape linkShape in factShapeAttachedLinkShapes)
 							{
 								RolePlayerLink rolePlayerLink;
Modified: trunk/ORMModel/ShapeModel/ViewFixupRules.cs
===================================================================
--- trunk/ORMModel/ShapeModel/ViewFixupRules.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/ORMModel/ShapeModel/ViewFixupRules.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -594,6 +594,7 @@
 			ORMModel model;
 			if (!link.IsDeleted &&
 				null != (associatedFact = link.PlayedRole.FactType) &&
+				null == associatedFact.ImpliedByObjectification &&
 				null != (model = (rolePlayer = link.RolePlayer).Model))
 			{
 				FactType nestedFact;
Modified: trunk/RelationalModel/OialDcilBridge/NameGeneration.cs
===================================================================
--- trunk/RelationalModel/OialDcilBridge/NameGeneration.cs	2009-06-02 09:04:54 UTC (rev 1391)
+++ trunk/RelationalModel/OialDcilBridge/NameGeneration.cs	2009-06-11 01:31:05 UTC (rev 1392)
@@ -2261,10 +2261,8 @@
 		}
 
 		/// <summary>
-		/// 
+		/// Override default values used to create the initial state of the object.
 		/// </summary>
-		/// <param name="propertyAssignments"></param>
-		/// <returns></returns>
 		private static PropertyAssignment[] GenerateDefaultValues(params PropertyAssignment[] propertyAssignments)
 		{
 			PropertyAssignment[] properties = propertyAssignments;
@@ -2308,6 +2306,62 @@
 			}
 			return properties;
 		}
+		/// <summary>
+		/// Track default property values that differ from the default values on the base.
+		/// </summary>
+		protected override bool HasDefaultAttributeValues(Guid[] ignorePropertyIds)
+		{
+			bool retVal = true;
+			string nameUsage = NameUsage;
+			Guid ignoreNewPropertyId = Guid.Empty;
+			if (string.IsNullOrEmpty(nameUsage))
+			{
+				// The default spacing format is modified
+				if (ignorePropertyIds == null || Array.IndexOf<Guid>(ignorePropertyIds, SpacingFormatDomainPropertyId) == -1)
+				{
+					retVal = SpacingFormat == NameGeneratorSpacingFormat.Remove;
+					ignoreNewPropertyId = SpacingFormatDomainPropertyId;
+				}
+			}
+			else if (nameUsage == "RelationalColumn")
+			{
+				// The default casing option is modified
+				if (ignorePropertyIds == null || Array.IndexOf<Guid>(ignorePropertyIds, CasingOptionDomainPropertyId) == -1)
+				{
+					retVal = CasingOption == NameGeneratorCasingOption.Camel;
+					ignoreNewPropertyId = CasingOptionDomainPropertyId;
+				}
+			}
+			else if (nameUsage == "RelationalTable")
+			{
+				// The default casing option is modified
+				if (ignorePropertyIds == null || Array.IndexOf<Guid>(ignorePropertyIds, CasingOptionDomainPropertyId) == -1)
+				{
+					retVal = CasingOption == NameGeneratorCasingOption.Pascal;
+					ignoreNewPropertyId = CasingOptionDomainPropertyId;
+				}
+			}
+			if (retVal)
+			{
+				Guid[] forwardIgnorePropertyIds;
+				if (ignoreNewPropertyId == Guid.Empty)
+				{
+					forwardIgnorePropertyIds = ignorePropertyIds;
+				}
+				else if (ignorePropertyIds != null)
+				{
+					forwardIgnorePropertyIds = new Guid[ignorePropertyIds.Length + 1];
+					ignorePropertyIds.CopyTo(forwardIgnorePropertyIds, 0);
+					forwardIgnorePropertyIds[forwardIgnorePropertyIds.Length - 1] = ignoreNewPropertyId;
+				}
+				else
+				{
+					forwardIgnorePropertyIds = new Guid[] { ignoreNewPropertyId };
+				}
+				return base.HasDefaultAttributeValues(forwardIgnorePropertyIds);
+			}
+			return false;
+		}
 	}
 	#endregion // ORMAbstractionToConceptualDatabaseBridgeDomainModel.RelationalNameGenerator Class
 }
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |