private void GroupNameChanged(object sender, ElementPropertyChangedEventArgs e) { var group = e.ModelElement as Group; var newName = e.NewValue.ToString(); var noError = true; if (string.IsNullOrEmpty(newName) || string.IsNullOrWhiteSpace(newName)) { System.Windows.Forms.MessageBox.Show(Validation.GroupNameEmpty); noError = false; return; } if (newName.Length > 50) { System.Windows.Forms.MessageBox.Show(Validation.GroupNameLength); noError = false; return; } if (noError) { return; } using (Transaction t = group.Store.TransactionManager.BeginTransaction("Fix Name")) { group.GroupName = e.OldValue.ToString(); t.Commit(); } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == DataContractBase.NameDomainPropertyId) { DataContractBase dataContract = e.ModelElement as DataContractBase; string oldValue = e.OldValue.ToString(); foreach (Contract element in dataContract.Contracts) { if (element is DataContract) { ((DataContract)element).DataMembers.ForEach(delegate(DataMember dataElement) { UpdatedElement(dataElement as ModelElementReference, e); }); } else if (element is FaultContract) { ((FaultContract)element).DataMembers.ForEach(delegate(DataMember dataElement) { UpdatedElement(dataElement as ModelElementReference, e); }); } } } }
/// <summary> /// ChangeRule: typeof(CardinalityConstraint) /// Trigger a text change notification when the modality changes /// </summary> private static void CardinalityChangedRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == CardinalityConstraint.ModalityDomainPropertyId) { ((CardinalityConstraint)e.ModelElement).OnTextChanged(); } }
private void ModuleRenamed(object source, ElementPropertyChangedEventArgs e) { //If an element with the old name exists it means the designer is auto-assigning a new name //to a newly dropped element and there's no need to rename the corresponding code element. In //fact that would be wrong because we would end up renaming the code element corresponding to the //model element with the old name, whose name hasn't changed. if (((Module)e.ModelElement).CountModulesWithName((string)e.OldValue) > 0) { return; } FileCodeModel2 fcm = GetGeneratedFileCodeModel(); if (fcm == null) { return; } CodeElement2 field = FindElement(fcm.CodeElements, (string)e.OldValue, vsCMElement.vsCMElementVariable); if (field != null) { field.RenameSymbol((string)e.NewValue); } UpdateView(); }
/// <summary> /// ChangeRule: typeof(FactType) /// </summary> private static void FactTypeNameChangedRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == FactType.NameChangedDomainPropertyId) { FrameworkDomainModel.DelayValidateElement(e.ModelElement, DelayValidateUnaryBinarization); } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { base.ElementPropertyChanged(e); if (e.ModelElement == null) { return; } if (e.ModelElement.Store.InSerializationTransaction) { return; } if (e.ModelElement.IsDeleting || e.ModelElement.IsDeleted) { return; } LinkShape linkShape = e.ModelElement as LinkShape; if (linkShape != null) { if (e.DomainProperty.Id == LinkShape.EdgePointsDomainPropertyId) { linkShape.UpdateAnchorPlacement(); } } }
/// <summary> /// Called whenever the location of the hosted shape changes. /// </summary> /// <param name="args"></param> protected virtual void OnLocationChanged(ElementPropertyChangedEventArgs args) { PointD oldLocation = this.itemLocation; PointD newLocation = (PointD)args.NewValue; if (this.Location != newLocation) { this.itemLocation = newLocation; if (oldLocation.X != this.itemLocation.X || oldLocation.Y != this.itemLocation.Y) { OnPropertyChanged("Location"); if (oldLocation.X != this.itemLocation.X) { OnPropertyChanged("Left"); } if (oldLocation.Y != this.itemLocation.Y) { OnPropertyChanged("Top"); } } } }
// For now, the abstraction model is fully regenerated whenever // an potential mapping change occurs. If there were any // concept types in the model they will be deleted and regenerated, // so it is currently sufficient to listen to a limited number of changes // and fully regenerate below the schema. The added rules are only needed // for cases where we start from an empty ORM model /// <summary> /// ChangeRule: typeof(ORMSolutions.ORMArchitect.ORMAbstraction.ConceptTypeChild) /// </summary> private static void ConceptTypeChildChangedRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == ConceptTypeChild.IsMandatoryDomainPropertyId) { ValidateAssociatedColumnsIsNullable((ConceptTypeChild)e.ModelElement); } }
/// <summary> /// ChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.FactType) /// </summary> private static void FactTypeNameChangedRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == ORMCore.FactType.NameChangedDomainPropertyId) { FactTypeNamePartChanged((ORMCore.FactType)e.ModelElement); } }
/// <summary> /// Handles the property change event for the settings. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); base.ElementPropertyChanged(e); var changedCommand = e.ModelElement as CommandSettings; if (changedCommand != null && changedCommand.Extends != null) { if (e.DomainProperty.Id == CommandSettings.PropertiesDomainPropertyId) { if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { // Find all unfold commands on the same element that changed var element = changedCommand.Owner; var unfoldCommands = element.AutomationSettings .Select(s => s.As <ICommandSettings>()) .Where(s => s != null && s.TypeId == typeof(UnfoldVsTemplateCommand).FullName); if (unfoldCommands.Any()) { unfoldCommands.ToList().ForEach(cmd => { tracer.Shield(() => { SyncNameExtension.EnsureSyncNameExtensionAutomation(changedCommand.Owner); }, Resources.UnfoldVsCommandChangeRule_ErrorSyncNameFailed, cmd.Name); }); } } } } }
/// <summary> /// Handles the property change event for the settings. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); base.ElementPropertyChanged(e); var changedCommand = e.ModelElement as CommandSettings; if (changedCommand != null && changedCommand.Extends != null) { if (e.DomainProperty.Id == CommandSettings.PropertiesDomainPropertyId) { if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { // Find all unfold commands on the same element that changed var element = changedCommand.Owner; var unfoldCommands = element.AutomationSettings .Select(s => s.As<ICommandSettings>()) .Where(s => s != null && s.TypeId == typeof(UnfoldVsTemplateCommand).FullName); if (unfoldCommands.Any()) { unfoldCommands.ToList().ForEach(cmd => { tracer.Shield(() => { SyncNameExtension.EnsureSyncNameExtensionAutomation(changedCommand.Owner); }, Resources.UnfoldVsCommandChangeRule_ErrorSyncNameFailed, cmd.Name); }); } } } } }
/// <summary> /// ChangeRule: typeof(Microsoft.VisualStudio.Modeling.Diagrams.NodeShape), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddConnectionRulePriority; /// </summary> private static void AbsoluteBoundsChangedRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == NodeShape.AbsoluteBoundsDomainPropertyId) { MultiShapeUtility.CheckLinksOnBoundsChange(e); } }
/// <summary> /// Handles property change events for the listed classes of this rule. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); if (e.DomainProperty.Id == PropertySchema.TypeDomainPropertyId) { if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { var property = (PropertySchema)e.ModelElement; // Clear any previous DefaultValue of the property. var defaultValueName = Reflector<PropertySchema>.GetPropertyName(x => x.RawDefaultValue); var descriptor = TypeDescriptor.GetProperties(property)[defaultValueName]; descriptor.ResetValue(property); // Repaint the owners compartment shape (to update the custom displayed text value) if (property.Owner != null) { foreach (var shape in PresentationViewsSubject.GetPresentation(property.Owner)) { CompartmentShape compartment = shape as CompartmentShape; if (compartment != null) { compartment.Invalidate(); } } } } } }
/// <summary> /// ChangeRule: typeof(RelationalDiagram) /// Disallows changing the name of the Relational Diagram /// Changes the name of the <see cref="T:RelationalDiagram"/> to /// its default name if changed by a user. /// </summary> private static void NameChangedRule(ElementPropertyChangedEventArgs e) { Guid attributeId = e.DomainProperty.Id; if (attributeId == Diagram.NameDomainPropertyId) { RelationalDiagram diagram = e.ModelElement as RelationalDiagram; string name = ORMSolutions.ORMArchitect.Framework.Design.ResourceAccessor <RelationalDiagram> .ResourceManager.GetString(NameResourceName); if (diagram != null && diagram.Name != name) { diagram.Name = name; } } else if (attributeId == RelationalDiagram.DisplayDataTypesDomainPropertyId) { foreach (PresentationElement pel in ((RelationalDiagram)e.ModelElement).NestedChildShapes) { TableShape shape; ColumnElementListCompartment compartment; if (null != (shape = pel as TableShape) && null != (compartment = shape.FindCompartment("ColumnsCompartment") as ColumnElementListCompartment)) { compartment.InvalidateOrUpdateSize(); } } } }
/// <summary> /// Called whenever properties change. /// </summary> /// <param name="args"></param> private void OnSerializationClassPropertyChanged(ElementPropertyChangedEventArgs args) { if (args.DomainProperty.Id == SerializationClass.SerializationNameDomainPropertyId) { OnPropertyChanged("SerializationName"); } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.ModelElement != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) return; if (e.ModelElement == null) return; if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None) return; EmbeddingRelationship embeddingRelationship = e.ModelElement as EmbeddingRelationship; if (embeddingRelationship != null) { if (e.DomainProperty.Id == EmbeddingRelationship.SerializationNameDomainPropertyId) { SerializedEmbeddingRelationship c = embeddingRelationship.SerializedEmbeddingRelationship; if (c.SerializationName != embeddingRelationship.SerializationName) { c.SerializationName = embeddingRelationship.SerializationName; if (embeddingRelationship.IsSerializationNameTracking != TrackingEnum.False) c.IsSerializationNameTracking = TrackingEnum.IgnoreOnce; else c.IsSerializationNameTracking = TrackingEnum.False; } } } }
/// <summary> /// Handles note change. /// </summary> private void NoteAlteredEventHandler(object sender, ElementPropertyChangedEventArgs e) { ModelElement element = e.ModelElement; Store store = element.Store; if (e.DomainProperty.Id == GetNoteTextPropertyId(store)) { // First, see if the note element implements INoteOwner directly INoteOwner <NoteType> noteOwner = element as INoteOwner <NoteType>; NoteRoleAndHandler[] ownerLinks; if (noteOwner != null) { NoteAlteredEventHandler(noteOwner); } else if (null != (ownerLinks = GetOwningRelationshipHandlers(store, false))) { // If note, find the owning element for (int i = 0; i < ownerLinks.Length; ++i) { if (null != (noteOwner = ownerLinks[i].DomainRole.GetLinkedElement(element) as INoteOwner <NoteType>)) { NoteAlteredEventHandler(noteOwner); break; } } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.ModelElement != null) { if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null) { if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { return; } } } if (e.ModelElement == null) { return; } if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None) { return; } SerializedDomainModel serializedDomainModel = e.ModelElement as SerializedDomainModel; if (serializedDomainModel != null) { /*string idElementName = serializedDomainModel.SerializedIdAttributeName; * ReadOnlyCollection<ModelElement> elements = serializedDomainModel.Store.ElementDirectory.FindElements(SerializedIdProperty.DomainClassId); * foreach (ModelElement m in elements) * (m as SerializedIdProperty).SerializationName = idElementName; * */ serializedDomainModel.Model.SerializedIdAttributeName = serializedDomainModel.SerializedIdAttributeName; } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.ModelElement != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) return; if (e.ModelElement == null) return; if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None) return; SerializedReferenceRelationship serializedReferenceRelationship = e.ModelElement as SerializedReferenceRelationship; if (serializedReferenceRelationship != null) { if (serializedReferenceRelationship.IsSerializationNameTracking == TrackingEnum.True) serializedReferenceRelationship.IsSerializationNameTracking = TrackingEnum.False; else if (serializedReferenceRelationship.IsSerializationNameTracking == TrackingEnum.IgnoreOnce) serializedReferenceRelationship.IsSerializationNameTracking = TrackingEnum.True; if (serializedReferenceRelationship.ReferenceRelationship.SerializationName != serializedReferenceRelationship.SerializationName) { serializedReferenceRelationship.ReferenceRelationship.SerializationName = serializedReferenceRelationship.SerializationName; serializedReferenceRelationship.ReferenceRelationship.IsSerializationNameTracking = serializedReferenceRelationship.IsSerializationNameTracking; } } }
/// <summary> /// Handles property change events for the listed classes of this rule. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); var element = e.ModelElement; if (element != null) { // Repaint the connector (to update decorators) if (!element.Store.TransactionManager.CurrentTransaction.IsSerializing) { if (e.DomainProperty.Id == ViewHasElements.CardinalityDomainPropertyId) { RepaintRelationshipConnectors <ViewHasElements>(element); } if (e.DomainProperty.Id == ViewHasExtensionPoints.CardinalityDomainPropertyId) { RepaintRelationshipConnectors <ViewHasExtensionPoints>(element); } if (e.DomainProperty.Id == ElementHasElements.CardinalityDomainPropertyId) { RepaintRelationshipConnectors <ElementHasElements>(element); } if (e.DomainProperty.Id == ElementHasExtensionPoints.CardinalityDomainPropertyId) { RepaintRelationshipConnectors <ElementHasExtensionPoints>(element); } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if(e.DomainProperty.Id == DataContractBase.NameDomainPropertyId) { DataContractBase dataContract = e.ModelElement as DataContractBase; string oldValue = e.OldValue.ToString(); foreach(Contract element in dataContract.Contracts) { if(element is DataContract) { ((DataContract)element).DataMembers.ForEach(delegate(DataMember dataElement) { UpdatedElement(dataElement as ModelElementReference, e); }); } else if(element is FaultContract) { ((FaultContract)element).DataMembers.ForEach(delegate(DataMember dataElement) { UpdatedElement(dataElement as ModelElementReference, e); }); } } } }
/// <summary> /// Triggers this notification rule whether a <see cref="ViewSchema"/> is updated. /// </summary> /// <param name="e">The provided data for this event.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { var view = (ViewSchema)e.ModelElement; if (view.IsDefault) { var otherViews = view.Pattern.Views.Where(vw => vw != view && vw.IsDefault); view.Store.TransactionManager.DoWithinTransaction(() => { foreach (var otherView in otherViews) { otherView.SetLocks(Locks.None); otherView.IsDefault = false; } }); view.SetLocks(Locks.Delete); } else if (view.Pattern.Views.Count == 1 || !view.Pattern.Views.Any(vw => vw.IsDefault)) { view.WithTransaction(vw => vw.IsDefault = true); } } }
/// <summary> /// Called whenever properties change. /// </summary> /// <param name="args"></param> private void OnSerializedReferenceRelationshipPropertyChanged(ElementPropertyChangedEventArgs args) { if (args.DomainProperty.Id == ReferenceRelationship.SerializationAttributeNameDomainPropertyId) { OnPropertyChanged("SerializationAttributeName"); } }
private void ChangedHandler(object sender, ElementPropertyChangedEventArgs e) { if (FindNodeForElement(e.ModelElement) is EFModelElementTreeNode treeNode) { treeNode.Update(); } }
/// <summary> /// ChangeRule: typeof(ORMSolutions.ORMArchitect.ORMAbstraction.ConceptType) /// </summary> private static void ConceptTypeChangedRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == ConceptType.NameDomainPropertyId) { ValidateTableNameChanged(TableIsPrimarilyForConceptType.GetTable((ConceptType)e.ModelElement)); } }
/// <summary> /// ChangeRule: typeof(RingConstraint), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddConnectionRulePriority; /// </summary> private static void RingConstraintPropertyChangeRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == RingConstraint.RingTypeDomainPropertyId) { RingConstraint ringConstraint = (RingConstraint)e.ModelElement; if (!ringConstraint.IsDeleted) { foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(ringConstraint)) { RingConstraintShape ringConstraintShape = pel as RingConstraintShape; if (ringConstraintShape != null) { foreach (LinkConnectsToNode connection in DomainRoleInfo.GetElementLinks <LinkConnectsToNode>(ringConstraintShape, LinkConnectsToNode.NodesDomainRoleId)) { BinaryLinkShape binaryLink = connection.Link as BinaryLinkShape; if (binaryLink != null) { binaryLink.RecalculateRoute(); } } SizeD oldSize = ringConstraintShape.Size; ringConstraintShape.AutoResize(); if (oldSize == ringConstraintShape.Size) { ringConstraintShape.InvalidateRequired(true); } } } } } }
/// <summary> /// Reorder compartment items when a column is renamed. /// </summary> private static void ColumnRenamedEvent(object sender, ElementPropertyChangedEventArgs e) { Column column = (Column)e.ModelElement; Table table; if (!column.IsDeleted && null != (table = column.Table)) { foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(table)) { TableShape shape = pel as TableShape; if (shape != null) { foreach (ShapeElement childShape in shape.NestedChildShapes) { ColumnElementListCompartment compartment; OrderedElementList <Column, ColumnElementListCompartment> columnList; int oldIndex; int newIndex; if (null != (compartment = childShape as ColumnElementListCompartment) && null != (columnList = compartment.Items as OrderedElementList <Column, ColumnElementListCompartment>)) { if (columnList.OnElementReorder(column, out oldIndex, out newIndex)) { MoveSubFieldSelectionOnOrderChange(tableShape, compartment, oldIndex, newIndex); } } } } } } }
/// <summary> /// ChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.SetConstraint) /// </summary> private static void SetConstraintChangedRule(ElementPropertyChangedEventArgs e) { Guid propertyId = e.DomainProperty.Id; if (propertyId == SetConstraint.ModalityDomainPropertyId) { SetConstraint constraint = (SetConstraint)e.ModelElement; if (IsRelevantConstraint(constraint.Constraint)) { foreach (Role role in constraint.RoleCollection) { // Note that constraint.FactTypeCollection does not resolve the // BinarizedFactType. Notifying twice on one FactType is harmless // due to delayed validation. FactTypeConstraintPatternChanged(role.BinarizedFactType); } } } else if (propertyId == SetConstraint.NameDomainPropertyId) { UniquenessConstraint uniquenessConstraint; Uniqueness uniqueness; if (null != (uniquenessConstraint = e.ModelElement as UniquenessConstraint) && null != (uniqueness = UniquenessIsForUniquenessConstraint.GetUniqueness(uniquenessConstraint))) { uniqueness.Name = uniquenessConstraint.Name; } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { var associationConnector = e.ModelElement as AssociationConnector; Debug.Assert(associationConnector != null); if (associationConnector != null) { // for some reason when deleting connector, DSL invokes ChangeRule, so just return if it's deleted if (associationConnector.IsDeleted) { return; } var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store); Debug.Assert(tx != null); if (tx != null && !tx.IsSerializing) { if (e.DomainProperty.Id == LinkShape.EdgePointsDomainPropertyId || e.DomainProperty.Id == LinkShape.ManuallyRoutedDomainPropertyId) { ViewModelChangeContext.GetNewOrExistingContext(tx) .ViewModelChanges.Add(new AssociationConnectorChange(associationConnector, e.DomainProperty.Id)); } } } }
private static void RoleNameVisibilityChangedEvent(object sender, ElementPropertyChangedEventArgs e) { FactTypeShape factTypeShape = (FactTypeShape)e.ModelElement; if (!factTypeShape.IsDeleted) { DisplayRoleNames display = factTypeShape.DisplayRoleNames; bool shouldBeVisible = display == DisplayRoleNames.On || (display == DisplayRoleNames.UserDefault && OptionsPage.CurrentRoleNameDisplay == RoleNameDisplay.On); foreach (ShapeElement childShape in factTypeShape.RelativeChildShapes) { RoleNameShape roleNameShape; if (null != (roleNameShape = childShape as RoleNameShape) && (shouldBeVisible ^ roleNameShape.IsVisible)) { if (shouldBeVisible) { roleNameShape.Show(); } else { roleNameShape.Hide(); } } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { base.ElementPropertyChanged(e); if (e.ModelElement == null) return; if (e.ModelElement.Store.InSerializationTransaction ) return; NodeShape nodeShape = e.ModelElement as NodeShape; if (nodeShape != null) { if (e.DomainProperty.Id == NodeShape.LocationDomainPropertyId) { PointD oldLocation = (PointD)e.OldValue; PointD newLocation = (PointD)e.NewValue; nodeShape.CorrectLinkShapesOnLocationChanged(oldLocation, newLocation); } else if(e.DomainProperty.Id == NodeShape.SizeDomainPropertyId) { SizeD oldSize = (SizeD)e.OldValue; SizeD newSize = (SizeD)e.NewValue; if( oldSize.Width != 0.0 && oldSize.Height != 0.0 ) nodeShape.CorrectLinkShapesOnSizeChanged(oldSize, newSize); } } }
/// <summary> /// ChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ObjectType) /// This method calls the DelayValidateElement method when the name of an ObjectType has been changed. /// </summary> private static void ExtensionObjectTypeChangeRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == ObjectType.NameDomainPropertyId) { FrameworkDomainModel.DelayValidateElement(e.ModelElement, DelayValidateObjectTypeHasMeaningfulNameError); } }
/// <summary> /// Handles property change events for the listed classes of this rule. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); if (e.DomainProperty.Id == PropertySchema.TypeDomainPropertyId) { if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { var property = (PropertySchema)e.ModelElement; // Clear any previous DefaultValue of the property. var defaultValueName = Reflector <PropertySchema> .GetPropertyName(x => x.RawDefaultValue); var descriptor = TypeDescriptor.GetProperties(property)[defaultValueName]; descriptor.ResetValue(property); // Repaint the owners compartment shape (to update the custom displayed text value) if (property.Owner != null) { foreach (var shape in PresentationViewsSubject.GetPresentation(property.Owner)) { CompartmentShape compartment = shape as CompartmentShape; if (compartment != null) { compartment.Invalidate(); } } } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { var inheritanceConnector = e.ModelElement as InheritanceConnector; Debug.Assert(inheritanceConnector != null); if (inheritanceConnector != null) { // for some reason when deleting connector, DSL invokes ChangeRule, so just return if it's deleted if (inheritanceConnector.IsDeleted) { return; } var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store); Debug.Assert(tx != null); if (tx != null && !tx.IsSerializing) { if (e.DomainProperty.Id == LinkShape.EdgePointsDomainPropertyId || e.DomainProperty.Id == LinkShape.ManuallyRoutedDomainPropertyId) { ViewModelChangeContext.GetNewOrExistingContext(tx) .ViewModelChanges.Add(new InheritanceConnectorChange(inheritanceConnector, e.DomainProperty.Id)); } } } }
/// <summary> /// ChangeRule: typeof(ORMSolutions.ORMArchitect.Core.ObjectModel.ValueComparisonConstraint), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AddConnectionRulePriority; /// </summary> private static void ValueComparisonConstraintPropertyChangeRule(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == ValueComparisonConstraint.OperatorDomainPropertyId) { ModelElement element = e.ModelElement; if (!element.IsDeleted) { // Redraw the ring constraint wherever it is displayed. foreach (PresentationElement pel in PresentationViewsSubject.GetPresentation(element)) { ValueComparisonConstraintShape constraintShape; if (null != (constraintShape = pel as ValueComparisonConstraintShape)) { ((IInvalidateDisplay)constraintShape).InvalidateRequired(true); if (ValueComparisonConstraint.IsDirectionalOperator((ValueComparisonOperator)e.OldValue) ^ ValueComparisonConstraint.IsDirectionalOperator((ValueComparisonOperator)e.NewValue)) { foreach (LinkShape linkShape in LinkConnectsToNode.GetLink(constraintShape)) { ExternalConstraintLink constraintLink; if (null != (constraintLink = linkShape as ExternalConstraintLink)) { ((IInvalidateDisplay)constraintLink).InvalidateRequired(true); } } } } } } } }
private void CustomReferenceModeChangeEvent(object sender, ElementPropertyChangedEventArgs e) { CustomReferenceMode customReferenceMode = e.ModelElement as CustomReferenceMode; if (customReferenceMode != null && !customReferenceMode.IsDeleted && customReferenceMode.Model == this.myModel) { if (myModify != null) { Guid attributeId = e.DomainProperty.Id; int column = -1; if (attributeId == CustomReferenceMode.CustomFormatStringDomainPropertyId) { column = (int)Columns.FormatString; } else if (attributeId == CustomReferenceMode.NameDomainPropertyId) { column = (int)Columns.Name; } // The reference mode kind column keys off the relationship between // a reference mode and its kind. The change may also fire here if the // ReferenceMode.KindDisplay is used to change it, but we ignore the // property change in favor of the backing object. if (column != -1) { int row = this.FindReferenceMode(customReferenceMode); myModify(this, BranchModificationEventArgs.DisplayDataChanged(new DisplayDataChangedData(VirtualTreeDisplayDataChanges.Text, this, row, column, 1))); } } } }
public void OnModelPropertyChanged(ElementPropertyChangedEventArgs e) { if (ModelPropertyChanged != null) { ModelPropertyChanged(e); } }
/// <summary> /// ChangeRule: typeof(ORMBaseBinaryLinkShape), FireTime=TopLevelCommit, Priority=DiagramFixupConstants.AutoLayoutShapesRulePriority; /// Keep relative child elements a fixed distance away from the fact /// when the shape changes. /// </summary> private static void LinkChangeRule(ElementPropertyChangedEventArgs e) { Guid attributeId = e.DomainProperty.Id; if (attributeId == ORMBaseBinaryLinkShape.EdgePointsDomainPropertyId) { ORMBaseBinaryLinkShape parentShape = e.ModelElement as ORMBaseBinaryLinkShape; LinkedElementCollection <ShapeElement> childShapes = parentShape.RelativeChildShapes; int childCount = childShapes.Count; for (int i = 0; i < childCount; ++i) { LinkConnectorShape linkConnector = childShapes[i] as LinkConnectorShape; if (linkConnector != null) { RectangleD bounds = parentShape.AbsoluteBoundingBox; linkConnector.Location = new PointD(bounds.Width / 2, bounds.Height / 2); ReadOnlyCollection <LinkConnectsToNode> links = DomainRoleInfo.GetElementLinks <LinkConnectsToNode>(linkConnector, LinkConnectsToNode.NodesDomainRoleId); int linksCount = links.Count; for (int j = 0; j < linksCount; ++j) { LinkConnectsToNode link = links[j]; BinaryLinkShape linkShape = link.Link as BinaryLinkShape; if (linkShape != null) { // Changing the location is not reliably reconnecting all shapes, especially // during load. Force the link to reconnect with a RecalculateRoute call linkShape.RecalculateRoute(); } } break; } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.ModelElement != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) return; if (e.ModelElement == null) return; if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None) return; SerializedDomainClass serializedDomainClass = e.ModelElement as SerializedDomainClass; if (serializedDomainClass != null) { if (e.DomainProperty.Id == SerializedDomainClass.SerializationNameDomainPropertyId) { if (serializedDomainClass.IsSerializationNameTracking == TrackingEnum.True) serializedDomainClass.IsSerializationNameTracking = TrackingEnum.False; else if (serializedDomainClass.IsSerializationNameTracking == TrackingEnum.IgnoreOnce) serializedDomainClass.IsSerializationNameTracking = TrackingEnum.True; if (serializedDomainClass.DomainClass.SerializationName != serializedDomainClass.SerializationName) { serializedDomainClass.DomainClass.SerializationName = serializedDomainClass.SerializationName; serializedDomainClass.DomainClass.IsSerializationNameTracking = serializedDomainClass.IsSerializationNameTracking; } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.ModelElement != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) return; if (e.ModelElement == null) return; if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None) return; ReferenceRelationship referenceRelationship = e.ModelElement as ReferenceRelationship; if (referenceRelationship != null) { if (e.DomainProperty.Id == ReferenceRelationship.SerializationNameDomainPropertyId) { SerializedReferenceRelationship c = referenceRelationship.SerializedReferenceRelationship; if (c.SerializationName != referenceRelationship.SerializationName) { c.SerializationName = referenceRelationship.SerializationName; if (referenceRelationship.IsSerializationNameTracking != TrackingEnum.False) c.IsSerializationNameTracking = TrackingEnum.IgnoreOnce; else c.IsSerializationNameTracking = TrackingEnum.False; } } else if (e.DomainProperty.Id == ReferenceRelationship.SerializationAttributeNameDomainPropertyId) { SerializedReferenceRelationship r = referenceRelationship.SerializedReferenceRelationship; foreach (SerializedDomainRole domainRole in r.SerializedDomainRoles) domainRole.SerializationAttributeName = referenceRelationship.SerializationAttributeName; } else if (e.DomainProperty.Id == ReferenceRelationship.SerializationSourceNameDomainPropertyId) { if (referenceRelationship.IsSerializationSourceNameTracking == TrackingEnum.True) referenceRelationship.IsSerializationSourceNameTracking = TrackingEnum.False; else if( referenceRelationship.IsSerializationSourceNameTracking == TrackingEnum.IgnoreOnce) referenceRelationship.IsSerializationSourceNameTracking = TrackingEnum.True; foreach (SerializedDomainRole r in referenceRelationship.Source.SerializedDomainRoles) r.SerializationName = referenceRelationship.SerializationSourceName; } else if (e.DomainProperty.Id == ReferenceRelationship.SerializationTargetNameDomainPropertyId) { if (referenceRelationship.IsSerializationTargetNameTracking == TrackingEnum.True) referenceRelationship.IsSerializationTargetNameTracking = TrackingEnum.False; else if (referenceRelationship.IsSerializationTargetNameTracking == TrackingEnum.IgnoreOnce) referenceRelationship.IsSerializationTargetNameTracking = TrackingEnum.True; foreach (SerializedDomainRole r in referenceRelationship.Target.SerializedDomainRoles) r.SerializationName = referenceRelationship.SerializationTargetName; } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { var entityShape = e.ModelElement as EntityTypeShape; Debug.Assert(entityShape != null); var tx = ModelUtils.GetCurrentTx(entityShape.Store); Debug.Assert(tx != null); if (tx != null && !tx.IsSerializing) { if (e.DomainProperty.Id == NodeShape.AbsoluteBoundsDomainPropertyId) { var oldAbsoluteBounds = (RectangleD)e.OldValue; var newAbsoluteBounds = (RectangleD)e.NewValue; // If only the height changed then we don't need to change anything in the model. // Also check an edge case where the first entity shape added to the diagram is added at a location that is within the NestedShapeMargin // in the top left corner. In this scenario, the ViewModel EntityShape is by default added to the top left of diagram at the NestedShapeMargin // value (i.e. (0.5,0.5)). This means that if the user tries add a shape at a point less than (0.5,0.5), i.e. if they drop/right-click in the // top left corner, it will not change the location of the shape because any point smaller than (0.5,0.5) will be rounded off to (0.5,0.5) // because of the NestedShapeMargin. This means that the old and new value of the absolute bounds will not change after the drop point // is applied to the new ViewModel shape's default location. Normally this would not be a problem, but when we create the EntityTypeShape in // the model we initally assign it a random (x,y) value (see CreateEntityTypeShapeCommand.cs) and we're relying on the EntityTypeShapeChange // command issued by this rule to update the model x,y values so that the correct co-ords are persisted in the *.diagram file. // Therefore there is an extra check in the IF statement below to catch the case where the user adds their first shape in the diagram at the // top left corner inside the NestedShapeMargin as this is the easiest edge case to hit. Note that this will not protect against edge cases // from subsequent updates where the user drops a new shape exactly on the same point as the initial location of the new ViewModel shape // (the initial co-ords cascade from top-left down to the bottom-right as more shapes are added). If our users are dextrous enough to hit the // edge cases for new entities and it's causing issues it would probably be best to remove this check entirely and always return an // EntityTypeShapeChange (and forgo the optimization). if (oldAbsoluteBounds.X == newAbsoluteBounds.X && oldAbsoluteBounds.Y == newAbsoluteBounds.Y && oldAbsoluteBounds.Width == newAbsoluteBounds.Width && (newAbsoluteBounds.X > entityShape.Diagram.NestedShapesMargin.Width || newAbsoluteBounds.Y > entityShape.Diagram.NestedShapesMargin.Height)) { return; } } if (e.DomainProperty.Id == NodeShape.AbsoluteBoundsDomainPropertyId || e.DomainProperty.Id == NodeShape.IsExpandedDomainPropertyId) { foreach (var link in entityShape.Link) { link.ManuallyRouted = false; } ViewModelChangeContext.GetNewOrExistingContext(tx) .ViewModelChanges.Add(new EntityTypeShapeChange(entityShape, e.DomainProperty.Id)); } } }
/// <summary> /// Do the following when an EntityType changes: /// - Update roles in related Associations /// </summary> /// <param name="e"></param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { base.ElementPropertyChanged(e); // if the element is deleted or about to be deleted, this rule will get fired. // Just return immediately here because we don't care if the entity-type's property has changed. if (e.ModelElement.IsDeleted || e.ModelElement.IsDeleting) { return; } var changedEntity = e.ModelElement as EntityType; Debug.Assert(changedEntity != null); Debug.Assert(changedEntity.EntityDesignerViewModel != null); if (changedEntity != null && changedEntity.EntityDesignerViewModel != null) { var viewModel = changedEntity.EntityDesignerViewModel; var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store); Debug.Assert(tx != null); // don't do the auto update stuff if we are in the middle of deserialization if (tx != null && !tx.IsSerializing) { // are they changing the name? if (e.DomainProperty.Id == NameableItem.NameDomainPropertyId) { // if we are creating this Entity, there is no 'change' to do if (viewModel.ModelXRef.GetExisting(changedEntity) == null) { return; } if (!EscherAttributeContentValidator.IsValidCsdlEntityTypeName(changedEntity.Name)) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, Resources.Error_EntityNameInvalid, changedEntity.Name)); } if (ModelUtils.IsUniqueName(changedEntity, changedEntity.Name, viewModel.EditingContext) == false) { throw new InvalidOperationException( String.Format(CultureInfo.CurrentCulture, Resources.Error_EntityNameDuplicate, changedEntity.Name)); } ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new EntityTypeChange(changedEntity)); } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.DomainProperty.Id == Operation.NameDomainPropertyId) { Operation operation = e.ModelElement as Operation; string oldValue = e.OldValue.ToString(); if (oldValue != string.Empty && operation.Action.EndsWith(oldValue, StringComparison.OrdinalIgnoreCase)) { operation.Action = Operation.BuildDefaultAction(operation); } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { base.ElementPropertyChanged(e); var changedProperty = e.ModelElement as ScalarProperty; Debug.Assert(changedProperty != null); // this rule will fire if a PropertyRef gets deleted (this happens if a keyed property that has a sibling keyed property is deleted), // in which case we ignore this change. if (changedProperty.IsDeleted) { return; } Debug.Assert(changedProperty.EntityType != null && changedProperty.EntityType.EntityDesignerViewModel != null); if (changedProperty != null && changedProperty.EntityType != null && changedProperty.EntityType.EntityDesignerViewModel != null) { var diagram = changedProperty.EntityType.EntityDesignerViewModel.GetDiagram(); Debug.Assert(diagram != null, "EntityDesignerDiagram is null"); // if EntityKey property changed, we need to invalidate properties compartment for this property to refresh the icon if (e.DomainProperty.Id == ScalarProperty.EntityKeyDomainPropertyId) { foreach (var pe in PresentationViewsSubject.GetPresentation(changedProperty.EntityType)) { var entityShape = pe as EntityTypeShape; if (entityShape != null) { entityShape.PropertiesCompartment.Invalidate(true); } } } var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store); Debug.Assert(tx != null); // don't do the auto update stuff if we are in the middle of deserialization if (tx != null && !tx.IsSerializing) { if (e.DomainProperty.Id == ScalarProperty.EntityKeyDomainPropertyId) { ViewModelChangeContext.GetNewOrExistingContext(tx) .ViewModelChanges.Add(new ScalarPropertyKeyChange(changedProperty)); } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.ModelElement != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) return; if (e.ModelElement == null) return; if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None) return; EnumerationLiteral enumerationLiteral = e.ModelElement as EnumerationLiteral; if (enumerationLiteral != null) { if (e.DomainProperty.Id == EnumerationLiteral.NameDomainPropertyId) { if (enumerationLiteral.IsDisplayNameTracking == TrackingEnum.True) { if (enumerationLiteral.DisplayName != StringHelper.BreakUpper(enumerationLiteral.Name)) { enumerationLiteral.DisplayName = StringHelper.BreakUpper(enumerationLiteral.Name); enumerationLiteral.IsDisplayNameTracking = TrackingEnum.IgnoreOnce; } } if (enumerationLiteral.IsSerializationNameTracking == TrackingEnum.True) { if (enumerationLiteral.SerializationName != enumerationLiteral.Name) { enumerationLiteral.SerializationName = enumerationLiteral.Name; enumerationLiteral.IsSerializationNameTracking = TrackingEnum.IgnoreOnce; } } } else if (e.DomainProperty.Id == EnumerationLiteral.DisplayNameDomainPropertyId) { if (enumerationLiteral.IsDisplayNameTracking == TrackingEnum.IgnoreOnce) enumerationLiteral.IsDisplayNameTracking = TrackingEnum.True; else if (enumerationLiteral.IsDisplayNameTracking == TrackingEnum.True) enumerationLiteral.IsDisplayNameTracking = TrackingEnum.False; } else if (e.DomainProperty.Id == EnumerationLiteral.SerializationNameDomainPropertyId) { if (enumerationLiteral.IsSerializationNameTracking == TrackingEnum.IgnoreOnce) enumerationLiteral.IsSerializationNameTracking = TrackingEnum.True; else if (enumerationLiteral.IsSerializationNameTracking == TrackingEnum.True) enumerationLiteral.IsSerializationNameTracking = TrackingEnum.False; } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.NewValue is IExtensionProvider) { // update all extenders foreach (ModelElement element in e.ModelElement.Store.ElementDirectory.AllElements) { if (typeof(IExtensibleObject).IsAssignableFrom(element.GetType())) { ExtensionProviderHelper.AttachObjectExtender((IExtensibleObject)element, (IExtensionProvider)e.NewValue); } } } }
private void UpdatedElement(ModelElementReference element, ElementPropertyChangedEventArgs e) { if (element != null) { if (element.Name.Equals(e.OldValue)) { element.Name = e.NewValue.ToString(); } if (element.Type.Equals(e.OldValue)) { element.Type = e.NewValue.ToString(); } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.NewValue is IExtensionProvider) { HostApplication hostApp = e.ModelElement as HostApplication; foreach (ServiceDescription sd in hostApp.ServiceDescriptions) { ExtensionProviderHelper.AttachObjectExtender((IExtensibleObject)sd, (IExtensionProvider)e.NewValue); foreach (Endpoint endpoint in sd.Endpoints) { ExtensionProviderHelper.AttachObjectExtender((IExtensibleObject)endpoint, (IExtensionProvider)e.NewValue); } } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { base.ElementPropertyChanged(e); ModelProperty property = e.ModelElement as ModelProperty; if (property != null) { Transaction transaction = property.Store.TransactionManager.CurrentTransaction.TopLevelTransaction; if (transaction != null && !transaction.IsSerializing) { // TODO: Add nested class support if (property.ModelClass != null) property.ModelClass.Model.OnModelPropertyChanged(e); } } }
private void BaseScheduledTaskStartDateChanged(object sender, ElementPropertyChangedEventArgs e) { var scheduledTask = e.ModelElement as BaseScheduledTask; var newValue = Convert.ToDateTime(e.NewValue); var oldValue = Convert.ToDateTime(e.OldValue); if (newValue > DateTime.Now) return; System.Windows.Forms.MessageBox.Show(Validation.STaskDateInvalid); using (Transaction t = scheduledTask.Store.TransactionManager.BeginTransaction("Fix Date")) { scheduledTask.StartDate = (oldValue > DateTime.Now) ? oldValue : DateTime.Now.AddDays(1); t.Commit(); } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { if (e.ModelElement != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction != null) if (e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) return; if (e.ModelElement == null) return; if (ImmutabilityExtensionMethods.GetLocks(e.ModelElement) != Locks.None) return; DomainRelationship domainRelationship = e.ModelElement as DomainRelationship; if (domainRelationship != null) { if (e.DomainProperty.Id == DomainRelationship.NameDomainPropertyId) { if (domainRelationship.IsNameTracking == TrackingEnum.True) domainRelationship.IsNameTracking = TrackingEnum.False; else if (domainRelationship.IsNameTracking == TrackingEnum.IgnoreOnce) domainRelationship.IsNameTracking = TrackingEnum.True; foreach (DomainRole role in domainRelationship.RolesPlayed) { if (role.IsNameTracking == TrackingEnum.True) { if (role.Name != domainRelationship.Name) { role.Name = domainRelationship.Name; role.IsNameTracking = TrackingEnum.IgnoreOnce; } } } } else if (e.DomainProperty.Id == DomainRelationship.InheritanceModifierDomainPropertyId) { if (((InheritanceModifier)e.NewValue) == InheritanceModifier.Abstract || ((InheritanceModifier)e.OldValue) == InheritanceModifier.Abstract) { SerializationHelper.UpdateDerivedElementsSerializationDomainRoles(domainRelationship.Source.RolePlayer); } } } }
/// <summary> /// Handles the property change event for the AssociatedArtifact properties. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); if (e.DomainProperty.Id == ArtifactExtension.OnArtifactActivationDomainPropertyId || e.DomainProperty.Id == ArtifactExtension.OnArtifactDeletionDomainPropertyId) { // Ensure we are not in deserialization mode. if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { ArtifactExtension artifactExtension = (ArtifactExtension)e.ModelElement; if (artifactExtension != null) { artifactExtension.EnsureActivateArtifactExtensionAutomation(); artifactExtension.EnsureDeleteArtifactExtensionAutomation(); } } } }
/// <summary> /// Raised when a property of the model element is changed. /// </summary> /// <param name="e">Event arguments.</param> public override void ElementPropertyChanged( ElementPropertyChangedEventArgs e) { // Validations if (e == null) { throw new ArgumentNullException("e"); } // What property is being changed? if (e.ModelElement is Property) { if(e.DomainProperty.Name.Equals("Order")) { HandleOrderPropertyChanged(e.ModelElement); } } }
public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { base.ElementPropertyChanged(e); if (e.ModelElement == null) return; if (e.ModelElement.Store.InSerializationTransaction) return; LinkShape linkShape = e.ModelElement as LinkShape; if (linkShape != null) { if (e.DomainProperty.Id == LinkShape.RoutingModeDomainPropertyId) { linkShape.Layout(FixedGeometryPoints.SourceAndTarget); } } }
/// <summary> /// Handles the property change event for the AssociatedGuidance properties. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); if ((e.DomainProperty.Id == GuidanceExtension.ExtensionIdDomainPropertyId) || (e.DomainProperty.Id == GuidanceExtension.GuidanceInstanceNameDomainPropertyId) || (e.DomainProperty.Id == GuidanceExtension.GuidanceSharedInstanceDomainPropertyId) || (e.DomainProperty.Id == GuidanceExtension.GuidanceActivateOnCreationDomainPropertyId)) { // Ensure we are not in deserialization mode. if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { GuidanceExtension guidanceExtension = (GuidanceExtension)e.ModelElement; if (guidanceExtension != null) { guidanceExtension.EnsureGuidanceExtensionAutomation(); } } } }
/// <summary> /// Handles the property change event for the settings. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); if (e.DomainProperty.Id == TemplateSettings.SyncNameDomainPropertyId) { var template = e.ModelElement as TemplateSettings; if (template != null && template.Extends != null) { if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { tracer.Shield(() => { SyncNameExtension.EnsureSyncNameExtensionAutomation(template.Owner); }, Resources.TemplateSettingsChangeRule_ErrorSyncNameFailed, template.Name); } } } }
/// <summary> /// Handles the property change event for the set of validation properties. /// </summary> /// <param name="e">The event args.</param> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); if ((e.DomainProperty.Id == ValidationExtension.ValidationOnBuildDomainPropertyId) || (e.DomainProperty.Id == ValidationExtension.ValidationOnCustomEventDomainPropertyId) || (e.DomainProperty.Id == ValidationExtension.ValidationOnMenuDomainPropertyId) || (e.DomainProperty.Id == ValidationExtension.ValidationOnSaveDomainPropertyId)) { // Ensure we are not in deserialization mode. if (!e.ModelElement.Store.TransactionManager.CurrentTransaction.IsSerializing) { ValidationExtension validationExtension = (ValidationExtension)e.ModelElement; if (validationExtension != null) { validationExtension.EnsureValidationExtensionAutomation(); } } } }
/// <summary> /// Handles the property change event for this element. /// </summary> public override void ElementPropertyChanged(ElementPropertyChangedEventArgs e) { Guard.NotNull(() => e, e); base.ElementPropertyChanged(e); // Change the color of the shape for this element if (e.DomainProperty.Id == SuppliedAsset.IsUserSuppliedDomainPropertyId) { SuppliedAsset element = e.ModelElement as SuppliedAsset; if (element != null) { // Get shape for the mel var suppliedAssetShape = PresentationViewsSubject.GetPresentation(element).OfType<SuppliedAssetShape>().FirstOrDefault(); if (suppliedAssetShape != null) { suppliedAssetShape.SetShapeBrushColor(DiagramBrushes.ShapeBackground, suppliedAssetShape.GetStereotypeFillColor()); } } } }