From: <mcu...@us...> - 2008-11-14 03:28:41
|
Revision: 1329 http://orm.svn.sourceforge.net/orm/?rev=1329&view=rev Author: mcurland Date: 2008-11-14 03:28:31 +0000 (Fri, 14 Nov 2008) Log Message: ----------- Fix a couple of bugs from [1327]. Simple subtype fields activating a text editor, and initial new objectified FactType instances with a supertype identifier were not getting an identifier required error. refs #374 Modified Paths: -------------- trunk/ORMModel/ObjectModel/SamplePopulation.cs trunk/ORMModel/ShapeModel/ObjectTypeShape.cs trunk/ORMModel/Shell/SamplePopulationEditor.cs Modified: trunk/ORMModel/ObjectModel/SamplePopulation.cs =================================================================== --- trunk/ORMModel/ObjectModel/SamplePopulation.cs 2008-11-08 21:43:45 UTC (rev 1328) +++ trunk/ORMModel/ObjectModel/SamplePopulation.cs 2008-11-14 03:28:31 UTC (rev 1329) @@ -1074,13 +1074,14 @@ ObjectType entityType; UniquenessConstraint pid; if (null != (entityType = factType.NestingType) && - null != (pid = entityType.PreferredIdentifier)) + null != (pid = entityType.ResolvedPreferredIdentifier)) { LinkedElementCollection<FactType> pidFactTypes; FactType identifierFactType; Role unaryRole = null; ObjectifiedUnaryRole objectifiedUnaryRole = null; - if (pid.IsInternal && + if (pid.PreferredIdentifierFor == entityType && + pid.IsInternal && 1 == (pidFactTypes = pid.FactTypeCollection).Count && ((identifierFactType = pidFactTypes[0]) == factType || (null != (unaryRole = factType.UnaryRole) && Modified: trunk/ORMModel/ShapeModel/ObjectTypeShape.cs =================================================================== --- trunk/ORMModel/ShapeModel/ObjectTypeShape.cs 2008-11-08 21:43:45 UTC (rev 1328) +++ trunk/ORMModel/ShapeModel/ObjectTypeShape.cs 2008-11-14 03:28:31 UTC (rev 1329) @@ -470,7 +470,7 @@ /// <param name="objectType">The associated model element</param> private static void ResizeAssociatedShapes(ObjectType objectType) { - if (!objectType.IsDeleted && objectType != null) + if (objectType != null && !objectType.IsDeleted) { LinkedElementCollection<PresentationElement> pels = PresentationViewsSubject.GetPresentation(objectType); int pelCount = pels.Count; Modified: trunk/ORMModel/Shell/SamplePopulationEditor.cs =================================================================== --- trunk/ORMModel/Shell/SamplePopulationEditor.cs 2008-11-08 21:43:45 UTC (rev 1328) +++ trunk/ORMModel/Shell/SamplePopulationEditor.cs 2008-11-14 03:28:31 UTC (rev 1329) @@ -2361,6 +2361,14 @@ { EntityTypeSubtypeInstance subtypeInstance = objectInstance as EntityTypeSubtypeInstance; EntityTypeInstance entityInstance = (subtypeInstance != null) ? subtypeInstance.SupertypeInstance : (EntityTypeInstance)objectInstance; + ObjectType entityTypeSubtype; + if (subtypeInstance == null && + null != (entityTypeSubtype = myEntityTypeSubtype)) + { + // Doing this simple sanity check means that we can call this + // update function for all subtype cases. + subtypeInstance = EntityTypeSubtypeInstance.GetSubtypeInstance(entityInstance, entityTypeSubtype, true, false); + } UpdateInstanceFields(entityInstance, subtypeInstance); } /// <summary> @@ -2476,7 +2484,7 @@ get { Role role = myRole; - return (role != null) ? role.RolePlayer : myIsEntityTypeEditor ? myEntityType : (myEntityTypeSubtype ?? myEntityType); + return (role != null && (!(role is SubtypeMetaRole) || myEntityType == null)) ? role.RolePlayer : myIsEntityTypeEditor ? myEntityType : (myEntityTypeSubtype ?? myEntityType); } } #endregion // Accessor Properties @@ -2488,8 +2496,9 @@ public IVirtualTreeInPlaceControl CreateInPlaceEditControl() { ObjectType rolePlayer; + Role role = myRole; bool blockEdits = - (null == (rolePlayer = ContextTargetObjectType)) || + (null == (rolePlayer = (role is SubtypeMetaRole) ? ContextTargetObjectType : ContextObjectType)) || (myRole != null && rolePlayer.NestedFactType != null) || HasComplexIdentifier(rolePlayer); TypeEditorHost host = EditContextTypeEditorHost.Create( @@ -2524,10 +2533,10 @@ Role role = instance.myRole; if (columnInstance == null) { - ObjectType objectifyingType = (role != null) ? role.RolePlayer : (instance.myEntityTypeSubtype ?? instance.myEntityType); + ObjectType objectifyingType = (role != null) ? ((role is SubtypeMetaRole) ? instance.myEntityType : role.RolePlayer) : (instance.myEntityTypeSubtype ?? instance.myEntityType); if (objectifyingType != null) { - return ObjectTypeInstance.GetDisplayString(null, instance.myEntityTypeSubtype ?? objectifyingType, role == null); + return ObjectTypeInstance.GetDisplayString(null, (role is SubtypeMetaRole) ? objectifyingType : (instance.myEntityTypeSubtype ?? objectifyingType), role == null); } } else if (role == null) @@ -5915,7 +5924,7 @@ editContext = new CellEditContext( (supertypeIdentifyingRole != null) ? supertypeIdentifyingRole.RolePlayer : rowType, (supertypeIdentifyingRole != null) ? rowType : null, - supertypeIdentifyingRole, + GetPreferredSubtypeRole(rowType), myEditInstance, myEditSubtypeInstance, this); break; @@ -7477,7 +7486,7 @@ EntityTypeInstance editInstance = myEditInstance; ObjectTypeInstance recurseConnectInstance = null; - if (identifierRole is SupertypeMetaRole && (factInstance == null || !(factInstance.FactType is SubtypeFact))) + if ((identifierRole is SupertypeMetaRole || identifierRole is SubtypeMetaRole) && (factInstance == null || !(factInstance.FactType is SubtypeFact))) { ObjectType subtype = ContextObjectType; EntityTypeInstance entityInstance = (EntityTypeInstance)instance; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |