/// <summary> /// Update our reading to reflect the current selection /// </summary> protected override void OnORMSelectionContainerChanged() { if (myEditor == null) { return; } ICollection selectedObjects; if (CurrentORMSelectionContainer != null && (null != (selectedObjects = base.GetSelectedComponents())) && selectedObjects.Count == 1) { foreach (object selectedObject in selectedObjects) { ObjectType testObjectType; FactType testFactType; if (null != (testObjectType = EditorUtility.ResolveContextInstance(selectedObject, false) as ObjectType)) { if (testObjectType.IsValueType) { SelectedValueType = testObjectType; } else { SelectedEntityType = testObjectType; } } else if (null != (testFactType = ORMEditorUtility.ResolveContextFactType(selectedObject) as FactType)) { // For a role selection on non-link fact type with an implied population, // show the proxy object type instead of the readonly proxied fact type view. // This allows us to directly edit the implied population, including repair // of population mandatory errors that display on the role of a fact type // with an implied population. FactTypeInstanceImplication implication; if (selectedObject is Role && (implication = new FactTypeInstanceImplication(testFactType)).IsImplied && implication.ImpliedProxyRole == null && implication.IdentifyingSupertype != null) { SelectedEntityType = implication.ImpliedByEntityType; } else { SelectedFactType = testFactType; } } else { NullSelection(); } } } else { NullSelection(); } }
/// <summary> /// Update our reading to reflect the current selection /// </summary> protected override void OnORMSelectionContainerChanged() { if (CurrentORMSelectionContainer != null) { ICollection selectedObjects = base.GetSelectedComponents(); FactType theFact = null; FactType secondaryFact = null; if (selectedObjects != null) { foreach (object element in selectedObjects) { FactType testFact = ORMEditorUtility.ResolveContextFactType(element); // Handle selection of multiple elements as long as // they all resolve to the same fact if (theFact == null) { theFact = testFact; Role testImpliedRole; RoleProxy proxy; ObjectifiedUnaryRole objectifiedUnaryRole; if (null != (testImpliedRole = element as Role)) { if (null != (proxy = testImpliedRole.Proxy)) { secondaryFact = proxy.FactType; } else if (null != (objectifiedUnaryRole = testImpliedRole.ObjectifiedUnaryRole)) { secondaryFact = objectifiedUnaryRole.FactType; } } } else if (testFact != theFact) { theFact = null; break; } else { secondaryFact = null; } } } if (theFact != null && theFact.HasImplicitReadings) { theFact = null; secondaryFact = null; } ActiveFactType activeFact = EditingFactType; FactType currentFact = activeFact.FactType; FactType currentImpliedFact = activeFact.ImpliedFactType; if (theFact == null && currentFact != null) { EditingFactType = ActiveFactType.Empty; } //selection could change between the shapes that are related to the fact else if (theFact != currentFact || secondaryFact != currentImpliedFact) { ReadOnlyCollection <RoleBase> displayOrder = null; IORMDesignerView designerView; DiagramView designer; if (null != (designerView = CurrentORMSelectionContainer as IORMDesignerView) && null != (designer = designerView.CurrentDesigner)) { SelectedShapesCollection shapes = designer.DiagramClientView.Selection; if (shapes.Count == 1) { DiagramItem item = null; foreach (DiagramItem iter in shapes) { item = iter; break; } ShapeElement shape = item.Shape; FactTypeShape factShape = shape as FactTypeShape; while (factShape == null) { shape = shape.ParentShape; if (shape == null) { break; } factShape = shape as FactTypeShape; } if (factShape != null) { FactType shapeFactType = factShape.AssociatedFactType; Objectification objectification; if (shapeFactType == theFact) { displayOrder = new ReadOnlyCollection <RoleBase>(factShape.DisplayedRoleOrder); } else if (secondaryFact == null && null != (objectification = shapeFactType.ImpliedByObjectification) && objectification.NestedFactType == theFact) { secondaryFact = shapeFactType; } } } } EditingFactType = new ActiveFactType(theFact, secondaryFact, displayOrder); } } else { EditingFactType = ActiveFactType.Empty; } }