/// <summary> /// RolePlayerPositionChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.FactTypeHasReadingOrder) /// </summary> private static void ReadingOrderReorderedRule(RolePlayerOrderChangedEventArgs e) { if (e.SourceDomainRole.Id == FactTypeHasReadingOrder.FactTypeDomainRoleId) { FrameworkDomainModel.DelayValidateElement(e.SourceElement, UpdateChildNamesForFactTypeDelayed); } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args">Arguments.</param> /// <param name="collection">Collection to reorder.</param> protected virtual void HandleRolePlayerMoved <T>(RolePlayerOrderChangedEventArgs args, System.Collections.ObjectModel.ObservableCollection <T> collection) where T : BaseModelElementViewModel { /* * if (args.SourceElement == this.Element) * { * for (int y = 0; y < collection.Count; y++) * { * if (collection[y].Element == args.CounterpartRolePlayer) * { * if (args.NewOrdinal == y) * return; * * // reorder elements * System.Collections.ObjectModel.ReadOnlyCollection<ElementLink> lllinks = DomainRoleInfo.GetElementLinks<ElementLink>(this.Element, DomainModelElement.GetSourceDomainRole(args.DomainRelationship).Id); * for (int ii = 0; ii < lllinks.Count; ii++) * for (int iy = 0; iy < collection.Count; iy++) * { * if (collection[iy].Element == DomainRoleInfo.GetTargetRolePlayer(lllinks[ii])) * { * // need to move? * if (iy != ii) * collection.Move(iy, ii); * * break; * } * } * } * } * * }*/ }
/// <summary> /// RolePlayerPositionChangeRule: typeof(ORMSolutions.ORMArchitect.ORMAbstraction.UniquenessIncludesConceptTypeChild) /// Reorder the columns in a uniqueness constraint when the order changes /// </summary> private static void UniquenessConstraintRoleOrderChanged(RolePlayerOrderChangedEventArgs e) { Uniqueness uniqueness; LinkedElementCollection <UniquenessConstraint> constraints; int constraintCount; if (null != (uniqueness = e.SourceElement as Uniqueness) && e.SourceDomainRole.Id == UniquenessIncludesConceptTypeChild.UniquenessDomainRoleId && 0 != (constraintCount = (constraints = UniquenessConstraintIsForUniqueness.GetUniquenessConstraint(uniqueness)).Count)) { LinkedElementCollection <ConceptTypeChild> conceptTypeChildren = uniqueness.ConceptTypeChildCollection; int conceptTypeChildCount = conceptTypeChildren.Count; for (int i = 0; i < constraintCount; ++i) { LinkedElementCollection <Column> constraintColumns = constraints[i].ColumnCollection; int constraintColumnCount = constraintColumns.Count; if (constraintColumnCount == conceptTypeChildCount) { constraintColumns.Move(e.OldOrdinal, e.NewOrdinal); } else { // UNDONE: The question of exactly how many columns are associated with a reference to // a conceptTypeChild is highly non-trivial. Punt on the issue for now by regenerating // the model. ConceptType conceptType = uniqueness.ConceptType; if (conceptType != null) { RebuildAbstractionModel(conceptType.Model); } } } } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnAttributeMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.SerializationElement) { this.attributesVMs.Move(args.OldOrdinal, args.NewOrdinal); } }
private static void ColumnOrderChanged(object sender, RolePlayerOrderChangedEventArgs e) { // If a row is selected in the changed table, then adjust its row ModelElement element = e.SourceElement; if (!element.IsDeleted) { Table table = (Table)element; foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(element)) { TableShape shape; if (null != (shape = pel as TableShape)) { foreach (ShapeElement childShape in shape.NestedChildShapes) { ColumnElementListCompartment compartment; if (null != (compartment = childShape as ColumnElementListCompartment)) { MoveSubFieldSelectionOnOrderChange(shape, compartment, e.OldOrdinal, e.NewOrdinal); } } } } } }
/// <summary> /// Called whenever a model element is moved. /// </summary> /// <param name="sender">ViewModelStore</param> /// <param name="args">Event Arguments for notification of the movement of a model element.</param> private void OnRolePlayerMoved(object sender, RolePlayerOrderChangedEventArgs args) { if (!ModelData.DoSendModelEvents) { return; } EventManager.GetEvent <ModelRolePlayerMovedEvent>().Publish(args); }
/// <summary> /// RolePlayerPositionChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ReadingOrderHasReading) /// </summary> private static void ReadingReorderedRule(RolePlayerOrderChangedEventArgs e) { FactType factType; if (e.SourceDomainRole.Id == ReadingOrderHasReading.ReadingOrderDomainRoleId && null != (factType = ((ReadingOrder)e.SourceElement).FactType)) { FrameworkDomainModel.DelayValidateElement(factType, UpdateChildNamesForFactTypeDelayed); } }
/// <summary> /// RolePlayerPositionChangeRule: typeof(SetComparisonConstraintHasRoleSequence) /// Validate subtype subset constraint patterns when role sequences are reordered. /// </summary> private static void LimitSubtypeSetComparisonConstraintSequenceReorderRule(RolePlayerOrderChangedEventArgs e) { SubsetConstraint constraint; if (e.SourceDomainRole.Id == SetComparisonConstraintHasRoleSequence.ExternalConstraintDomainRoleId && null != (constraint = e.SourceElement as SubsetConstraint)) { FrameworkDomainModel.DelayValidateElement(constraint, DelayValidateSupertypeSubsetPattern); } }
/// <summary> /// RolePlayerPositionChangeRule: typeof(ORMSolutions.ORMArchitect.RelationalModels.ConceptualDatabase.TableContainsColumn) /// </summary> private static void ColumnOrderChangedRule(RolePlayerOrderChangedEventArgs e) { if (e.SourceDomainRole.Id == TableContainsColumn.TableDomainRoleId) { Table table = (Table)e.SourceElement; if (table.ColumnOrder == ColumnOrdering.Custom) { FrameworkDomainModel.DelayValidateElement(table, DelayValidateCustomizeColumnPositions); } } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnEmbeddingDiagramNodeMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.EmbeddingDiagramNode) { this.embeddingNodeVMs.Move(args.OldOrdinal, args.NewOrdinal); } foreach (EmbeddingDiagramNodeViewModel vm in this.embeddingNodeVMs) { vm.UpdateNodePosition(); } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnChildMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.SerializationElement) { if (!this.HasLoadedChildren) { return; } this.childrenVMs.Move(args.OldOrdinal, args.NewOrdinal); } }
/// <summary> /// RolePlayerPositionChangeRule: typeof(ConstraintRoleSequenceHasRole) /// Propagate order changes in a uniqueness constraint to an absorbed uniqueness /// </summary> private static void UniquenessConstraintRoleOrderChanged(RolePlayerOrderChangedEventArgs e) { UniquenessConstraint constraint; Uniqueness uniqueness; if (null != (constraint = e.SourceElement as UniquenessConstraint) && e.SourceDomainRole.Id == ConstraintRoleSequenceHasRole.ConstraintRoleSequenceDomainRoleId && null != (uniqueness = UniquenessIsForUniquenessConstraint.GetUniqueness(constraint))) { uniqueness.ConceptTypeChildCollection.Move(e.OldOrdinal, e.NewOrdinal); } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnRootDiagramNodeMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.DiagramClassView) { this.rootNodeVMs.Move(args.OldOrdinal, args.NewOrdinal); } foreach (RootDiagramNodeViewModel vm in this.rootNodeVMs) { vm.UpdateNodePosition(); } }
private static void ColumnOrderChanged(object sender, RolePlayerOrderChangedEventArgs e) { ModelElement element = e.SourceElement; if (!element.IsDeleted) { Table table = (Table)element; Schema schema; SchemaCustomization customization; if (table.ColumnOrder == ColumnOrdering.Custom && null != (schema = table.Schema) && null != (customization = SchemaCustomization.GetCustomization(schema))) { // UNDONE: Consider batching this into an 'element events ended' customization.CustomizeColumnPositions(table, true); } } }
private static void RolePlayerOrderChangedEvent(object sender, RolePlayerOrderChangedEventArgs e) { SetComparisonConstraint constraint; ExternalConstraintShape constraintShape; ORMDiagram ormDiagram; if (null != (constraint = e.SourceElement as SetComparisonConstraint)) { foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(constraint)) { if (null != (constraintShape = pel as ExternalConstraintShape)) { // If the constraint being changed is also the current stick object, // then refresh the linked facts as well constraintShape.RedrawAssociatedPels(null != (ormDiagram = constraintShape.Diagram as ORMDiagram) && constraintShape == ormDiagram.StickyObject); } } } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnChildMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.SerializationElement) { if (!this.HasLoadedChildren) return; this.childrenVMs.Move(args.OldOrdinal, args.NewOrdinal); } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnAttributeMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.SerializationElement) this.attributesVMs.Move(args.OldOrdinal, args.NewOrdinal); }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args">Arguments.</param> protected virtual void OnRolePlayerMoved(RolePlayerOrderChangedEventArgs args) { if (this.SortingProvider != null) if (this.SortingProvider.ModelTreeSortingState != Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.ModelTree.ModelTreeSortingState.Sorted) if (args.SourceElement == this.Element) { // find index of domain class of the required type first for (int i = 0; i < this.ChildrenStorage.Count; i++) if (this.ChildrenStorage[i].ElementLinkDomainClassId == args.DomainRelationship.Id) { this.ChildrenStorage.Move(i + args.OldOrdinal, i + args.NewOrdinal); break; } } /* if (this.SortingProvider != null) if (this.SortingProvider.ModelTreeSortingState != ModelTreeSortingState.Sorted) { if (args.SourceElement == this.Element) { // find index of domain class of the required type first for (int i = 0; i < this.ChildrenStorage.Count; i++) if (this.ChildrenStorage[i].ElementLinkDomainClassId == args.DomainRelationship.Id) { for (int y = i; y < this.ChildrenStorage.Count; y++) { if (this.ChildrenStorage[y].Element == args.CounterpartRolePlayer) { if (args.NewOrdinal == (y - i)) return; // reorder elements System.Collections.ObjectModel.ReadOnlyCollection<ElementLink> lllinks = DomainRoleInfo.GetElementLinks<ElementLink>(this.Element, DomainModelElement.GetSourceDomainRole(args.DomainRelationship).Id); for (int ii = 0; ii < lllinks.Count; ii++) for (int iy = i; iy < this.ChildrenStorage.Count; iy++) { if (this.ChildrenStorage[iy].ElementLink == lllinks[ii]) { // need to move? if (iy - i != ii) this.ChildrenStorage.Move(iy, ii); break; } } } } //this.ChildrenStorage.Move(i + args.OldOrdinal, i + args.NewOrdinal); break; } } }*/ /* if (args.SourceElement == this.Element) { // find index of domain class of the required type first for (int i = 0; i < this.ChildrenStorage.Count; i++) if (this.ChildrenStorage[i].ElementLinkDomainClassId == args.DomainRelationship.Id) { this.ChildrenStorage.Move(i + args.OldOrdinal, i + args.NewOrdinal); break; } }*/ }
/// <summary> /// RolePlayerPositionChangeRule: typeof(ConstraintRoleSequenceHasRole) /// Propagate order changes in a uniqueness constraint to an absorbed uniqueness /// </summary> private static void UniquenessConstraintRoleOrderChanged(RolePlayerOrderChangedEventArgs e) { UniquenessConstraint constraint; Uniqueness uniqueness; if (null != (constraint = e.SourceElement as UniquenessConstraint) && e.SourceDomainRole.Id == ConstraintRoleSequenceHasRole.ConstraintRoleSequenceDomainRoleId && null != (uniqueness = UniquenessIsForUniquenessConstraint.GetUniqueness(constraint))) { uniqueness.ConceptTypeChildCollection.Move(e.OldOrdinal, e.NewOrdinal); } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnChildRootNodeMoved(RolePlayerOrderChangedEventArgs args) { if( args.SourceElement == this.modelTreeView ) this.rootNodeVMs.Move(args.OldOrdinal, args.NewOrdinal); }
/// <summary> /// Called whenever a model element is moved. /// </summary> /// <param name="sender">ViewModelStore</param> /// <param name="args">Event Arguments for notification of the movement of a model element.</param> private void OnRolePlayerMoved(object sender, RolePlayerOrderChangedEventArgs args) { if (!ModelData.DoSendModelEvents) return; EventManager.GetEvent<ModelRolePlayerMovedEvent>().Publish(args); }
/// <summary> /// Called whenever a model element is moved. /// </summary> /// <param name="sender">ViewModelStore</param> /// <param name="args">Event Arguments for notification of the movement of a model element.</param> protected virtual void OnRolePlayerMoved(object sender, RolePlayerOrderChangedEventArgs args) { EventManager.GetEvent<ModelRolePlayerMovedEvent>().Publish(args); }
/// <summary> /// RolePlayerPositionChangeRule: typeof(ORMSolutions.ORMArchitect.ORMAbstraction.UniquenessIncludesConceptTypeChild) /// Reorder the columns in a uniqueness constraint when the order changes /// </summary> private static void UniquenessConstraintRoleOrderChanged(RolePlayerOrderChangedEventArgs e) { Uniqueness uniqueness; LinkedElementCollection<UniquenessConstraint> constraints; int constraintCount; if (null != (uniqueness = e.SourceElement as Uniqueness) && e.SourceDomainRole.Id == UniquenessIncludesConceptTypeChild.UniquenessDomainRoleId && 0 != (constraintCount = (constraints = UniquenessConstraintIsForUniqueness.GetUniquenessConstraint(uniqueness)).Count)) { LinkedElementCollection<ConceptTypeChild> conceptTypeChildren = uniqueness.ConceptTypeChildCollection; int conceptTypeChildCount = conceptTypeChildren.Count; for (int i = 0; i < constraintCount; ++i) { LinkedElementCollection<Column> constraintColumns = constraints[i].ColumnCollection; int constraintColumnCount = constraintColumns.Count; if (constraintColumnCount == conceptTypeChildCount) { constraintColumns.Move(e.OldOrdinal, e.NewOrdinal); } else { // UNDONE: The question of exactly how many columns are associated with a reference to // a conceptTypeChild is highly non-trivial. Punt on the issue for now by regenerating // the model. ConceptType conceptType = uniqueness.ConceptType; if (conceptType != null) { RebuildAbstractionModel(conceptType.Model); } } } } }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnEmbeddingDiagramNodeMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.EmbeddingDiagramNode) this.embeddingNodeVMs.Move(args.OldOrdinal, args.NewOrdinal); foreach (EmbeddingDiagramNodeViewModel vm in this.embeddingNodeVMs) vm.UpdateNodePosition(); }
/// <summary> /// RolePlayerPositionChangeRule: typeof(UniquenessConstraintIncludesColumn) /// If a uniqueness constraint column is being repositioned, then reposition the corresponding column /// in any reference constraints that target the columns in the uniqueness constraint. /// </summary> private static void UniquenessConstraintColumnPositionChanged(RolePlayerOrderChangedEventArgs e) { if (e.CounterpartDomainRole.Id == UniquenessConstraintIncludesColumn.ColumnDomainRoleId) { UniquenessConstraint uniquenessConstraint = (UniquenessConstraint)e.SourceElement; int oldIndex = e.OldOrdinal; int newIndex = e.NewOrdinal; foreach (ReferenceConstraint referenceConstraint in uniquenessConstraint.ReferenceConstraintCollection) { LinkedElementCollection <ColumnReference> columnRefs = referenceConstraint.ColumnReferenceCollection; int columnRefCount = columnRefs.Count; if (newIndex < columnRefCount && oldIndex < columnRefCount && columnRefs[oldIndex].TargetColumn == e.CounterpartRolePlayer) // Sanity check { Column sourceColumn = columnRefs[oldIndex].SourceColumn; columnRefs.Move(oldIndex, newIndex); // Any uniqueness constraint that includes all columns in the // reference constraint will generate in a different order and // should be updated Table sourceTable; if (null != (sourceTable = referenceConstraint.SourceTable)) { foreach (UniquenessConstraint sourceUniquenessConstraint in sourceTable.UniquenessConstraintCollection) { LinkedElementCollection <Column> uniquenessColumns = sourceUniquenessConstraint.ColumnCollection; int uniquenessColumnCount = uniquenessColumns.Count; if (uniquenessColumnCount >= columnRefCount) { int firstMatchColumn = int.MaxValue; for (int i = 0; i < columnRefCount; ++i) { Column matchColumn = columnRefs[i].SourceColumn; int j = 0; for (; j < uniquenessColumnCount; ++j) { if (uniquenessColumns[j] == matchColumn) { firstMatchColumn = Math.Min(firstMatchColumn, j); break; } } if (j == uniquenessColumnCount) { // Not included firstMatchColumn = int.MaxValue; break; } } if (firstMatchColumn != int.MaxValue) { uniquenessColumnCount -= firstMatchColumn; if (newIndex < uniquenessColumnCount && oldIndex < uniquenessColumnCount && uniquenessColumns[firstMatchColumn + oldIndex] == sourceColumn) // Sanity check { uniquenessColumns.Move(firstMatchColumn + oldIndex, firstMatchColumn + newIndex); } // If this does not line up then something is clearly off, but // this is a non-critical error in that the model is still correctly // aligned and generates correct DDL. // However, the constraint will now have a different column order // than with a full regeneration. // UNDONE: Delay validation routine for this situation } } } } } else { // Something is off, delay validate this later ReferenceConstraintTargetsTable tableLink = ReferenceConstraintTargetsTable.GetLinkToTargetTable(referenceConstraint); if (tableLink != null) { FrameworkDomainModel.DelayValidateElement(tableLink, DelayValidateTargetUniquenessConstraint); } } } } }
private static void RolePlayerOrderChangedEvent(object sender, RolePlayerOrderChangedEventArgs e) { SetComparisonConstraint constraint; ExternalConstraintShape ecs; ORMDiagram ormDiagram; if (null != (constraint = e.SourceElement as SetComparisonConstraint)) { foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(constraint)) { if (null != (ecs = pel as ExternalConstraintShape)) { // If the constraint being changed is also the current stick object, // then refresh the linked facts as well ecs.RedrawAssociatedPels(null != (ormDiagram = ecs.Diagram as ORMDiagram) && ecs == ormDiagram.StickyObject); } } } }
/// <summary> /// Called whenever a model element is moved. /// </summary> /// <param name="sender">ViewModelStore</param> /// <param name="args">Event Arguments for notification of the movement of a model element.</param> protected virtual void OnRolePlayerMoved(object sender, RolePlayerOrderChangedEventArgs args) { EventManager.GetEvent <ModelRolePlayerMovedEvent>().Publish(args); }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args">Arguments.</param> protected virtual void OnRolePlayerMoved(RolePlayerOrderChangedEventArgs args) { if (this.SortingProvider != null) { if (this.SortingProvider.ModelTreeSortingState != Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.ModelTree.ModelTreeSortingState.Sorted) { if (args.SourceElement == this.Element) { // find index of domain class of the required type first for (int i = 0; i < this.ChildrenStorage.Count; i++) { if (this.ChildrenStorage[i].ElementLinkDomainClassId == args.DomainRelationship.Id) { this.ChildrenStorage.Move(i + args.OldOrdinal, i + args.NewOrdinal); break; } } } } } /* * if (this.SortingProvider != null) * if (this.SortingProvider.ModelTreeSortingState != ModelTreeSortingState.Sorted) * { * if (args.SourceElement == this.Element) * { * // find index of domain class of the required type first * for (int i = 0; i < this.ChildrenStorage.Count; i++) * if (this.ChildrenStorage[i].ElementLinkDomainClassId == args.DomainRelationship.Id) * { * for (int y = i; y < this.ChildrenStorage.Count; y++) * { * if (this.ChildrenStorage[y].Element == args.CounterpartRolePlayer) * { * if (args.NewOrdinal == (y - i)) * return; * * // reorder elements * System.Collections.ObjectModel.ReadOnlyCollection<ElementLink> lllinks = DomainRoleInfo.GetElementLinks<ElementLink>(this.Element, DomainModelElement.GetSourceDomainRole(args.DomainRelationship).Id); * for (int ii = 0; ii < lllinks.Count; ii++) * for (int iy = i; iy < this.ChildrenStorage.Count; iy++) * { * if (this.ChildrenStorage[iy].ElementLink == lllinks[ii]) * { * // need to move? * if (iy - i != ii) * this.ChildrenStorage.Move(iy, ii); * * break; * } * } * } * * } * //this.ChildrenStorage.Move(i + args.OldOrdinal, i + args.NewOrdinal); * break; * } * } * }*/ /* * if (args.SourceElement == this.Element) * { * // find index of domain class of the required type first * for (int i = 0; i < this.ChildrenStorage.Count; i++) * if (this.ChildrenStorage[i].ElementLinkDomainClassId == args.DomainRelationship.Id) * { * this.ChildrenStorage.Move(i + args.OldOrdinal, i + args.NewOrdinal); * break; * } * }*/ }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnShapeClassNodeMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.TreeNode) this.shapeClassNodeVMs.Move(args.OldOrdinal, args.NewOrdinal); foreach (ShapeClassNodeViewModel vm in this.shapeClassNodeVMs) vm.UpdateNodePosition(); }
/// <summary> /// Called on a role player beeing moved. /// </summary> /// <param name="args"></param> private void OnRootDiagramNodeMoved(RolePlayerOrderChangedEventArgs args) { if (args.SourceElement == this.DiagramClassView) this.rootNodeVMs.Move(args.OldOrdinal, args.NewOrdinal); foreach (RootDiagramNodeViewModel vm in this.rootNodeVMs) vm.UpdateNodePosition(); }