Revision: 1166
http://orm.svn.sourceforge.net/orm/?rev=1166&view=rev
Author: mcurland
Date: 2007-10-23 11:12:22 -0700 (Tue, 23 Oct 2007)
Log Message:
-----------
Fixed modality issues with Entity Relationship Learning Mode display. refs #344
Modified Paths:
--------------
trunk/ORMModel/ShapeModel/RolePlayerLink.cs
Modified: trunk/ORMModel/ShapeModel/RolePlayerLink.cs
===================================================================
--- trunk/ORMModel/ShapeModel/RolePlayerLink.cs 2007-10-23 18:11:14 UTC (rev 1165)
+++ trunk/ORMModel/ShapeModel/RolePlayerLink.cs 2007-10-23 18:12:22 UTC (rev 1166)
@@ -721,7 +721,8 @@
{
if (displaySetting == EntityRelationshipBinaryMultiplicityDisplay.Barker)
{
- bool mandatory = role.IsMandatory;
+ MandatoryConstraint constraint = role.SimpleMandatoryConstraint;
+ bool mandatory = constraint != null && constraint.Modality == ConstraintModality.Alethic;
switch (multiplicity)
{
case RoleMultiplicity.ZeroToMany:
@@ -848,6 +849,22 @@
/// </summary>
private static void UpdateDotDisplayOnMandatoryConstraintChange(Role role)
{
+ InvalidateRolePlayerLinks(role);
+ if (OptionsPage.CurrentEntityRelationshipBinaryMultiplicityDisplay == EntityRelationshipBinaryMultiplicityDisplay.InformationEngineering)
+ {
+ // The opposite links also need updating
+ RoleBase oppositeRole = role.OppositeRole;
+ if (oppositeRole != null)
+ {
+ InvalidateRolePlayerLinks(oppositeRole.Role);
+ }
+ }
+ }
+ /// <summary>
+ /// Helper function to invalidate roles
+ /// </summary>
+ private static void InvalidateRolePlayerLinks(Role role)
+ {
foreach (ObjectTypePlaysRole objectTypePlaysRole in DomainRoleInfo.GetElementLinks<ObjectTypePlaysRole>(role, ObjectTypePlaysRole.PlayedRoleDomainRoleId))
{
foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(objectTypePlaysRole))
@@ -870,22 +887,43 @@
{
DomainDataDirectory dataDirectory = store.DomainDataDirectory;
- eventManager.AddOrRemoveHandler(dataDirectory.FindDomainProperty(MandatoryConstraint.ModalityDomainPropertyId), new EventHandler<ElementPropertyChangedEventArgs>(InternalConstraintChangedEvent), action);
+ eventManager.AddOrRemoveHandler(dataDirectory.FindDomainProperty(MandatoryConstraint.ModalityDomainPropertyId), new EventHandler<ElementPropertyChangedEventArgs>(InternalConstraintModalityChangedEvent), action);
eventManager.AddOrRemoveHandler(dataDirectory.FindDomainRelationship(FactSetConstraint.DomainClassId), new EventHandler<ElementAddedEventArgs>(InternalConstraintRoleSequenceAddedEvent), action);
eventManager.AddOrRemoveHandler(dataDirectory.FindDomainRelationship(ConstraintRoleSequenceHasRole.DomainClassId), new EventHandler<ElementDeletedEventArgs>(InternalConstraintRoleSequenceRoleRemovedEvent), action);
}
/// <summary>
/// Update the link displays when the modality of a simple mandatory constraint changes
/// </summary>
- private static void InternalConstraintChangedEvent(object sender, ElementPropertyChangedEventArgs e)
+ private static void InternalConstraintModalityChangedEvent(object sender, ElementPropertyChangedEventArgs e)
{
- MandatoryConstraint smc = e.ModelElement as MandatoryConstraint;
- if (smc != null && !smc.IsDeleted && smc.IsSimple)
+ ModelElement mel = e.ModelElement;
+ if (!mel.IsDeleted)
{
- LinkedElementCollection<Role> roles = smc.RoleCollection;
- if (roles.Count != 0)
+ switch (((IConstraint)mel).ConstraintType)
{
- UpdateDotDisplayOnMandatoryConstraintChange(roles[0]);
+ case ConstraintType.SimpleMandatory:
+ LinkedElementCollection<Role> roles = ((SetConstraint)mel).RoleCollection;
+ if (roles.Count != 0)
+ {
+ UpdateDotDisplayOnMandatoryConstraintChange(roles[0]);
+ }
+ break;
+ case ConstraintType.InternalUniqueness:
+ if (OptionsPage.CurrentEntityRelationshipBinaryMultiplicityDisplay != EntityRelationshipBinaryMultiplicityDisplay.Off)
+ {
+ foreach (FactType factType in ((SetConstraint)mel).FactTypeCollection)
+ {
+ LinkedElementCollection<RoleBase> roleBases = factType.RoleCollection;
+ if (roleBases.Count == 2)
+ {
+ foreach (RoleBase roleBase in roleBases)
+ {
+ InvalidateRolePlayerLinks(roleBase.Role);
+ }
+ }
+ }
+ }
+ break;
}
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|