/// <summary> /// Do the following when a new EntityType shape is created: /// - Add the new EntityType to the model /// </summary> /// <param name="e"></param> public override void ElementAdded(ElementAddedEventArgs e) { base.ElementAdded(e); var addedEntity = e.ModelElement as EntityType; Debug.Assert(addedEntity != null); Debug.Assert(addedEntity.EntityDesignerViewModel != null); if ((addedEntity != null) && (addedEntity.EntityDesignerViewModel != null)) { var viewModel = addedEntity.EntityDesignerViewModel; Debug.Assert(viewModel != null); var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store); Debug.Assert(tx != null, "Make sure we have a Current Active Tx"); if (tx != null && !tx.IsSerializing) { // Remove the added DSL EntityType. // When Escher model is updated, there will be a code that will create the EntityType back viewModel.EntityTypes.Remove(addedEntity); addedEntity.Delete(); // create the model change and add it to the current transaction changelist ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new EntityTypeAdd()); } } }
/// <summary> /// Do the following when a new Association is created: /// - Initialize the "End1" and "End2" properties (displayed on the connector decorators) /// - Set the "Name" property to a sensible default /// - Update the navigation property of the Source and Target entities /// </summary> public override void ElementAdded(ElementAddedEventArgs e) { base.ElementAdded(e); var addedAssociation = e.ModelElement as Association; Debug.Assert(addedAssociation != null); Debug.Assert(addedAssociation.SourceEntityType != null); Debug.Assert(addedAssociation.TargetEntityType != null); Debug.Assert(addedAssociation.SourceEntityType.EntityDesignerViewModel != null); if (addedAssociation != null && addedAssociation.SourceEntityType != null && addedAssociation.TargetEntityType != null && addedAssociation.SourceEntityType.EntityDesignerViewModel != null) { var tx = ModelUtils.GetCurrentTx(e.ModelElement.Store); Debug.Assert(tx != null); if (tx != null && !tx.IsSerializing) { // create the new association ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new AssociationAdd(addedAssociation)); } } }
public override void ElementAdded(ElementAddedEventArgs 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; DomainProperty domainProperty = e.ModelElement as DomainProperty; if (domainProperty != null) { if (domainProperty.Type == null) foreach (DomainType type in domainProperty.Element.ParentModelContext.MetaModel.DomainTypes) if (type.Name == "String") { domainProperty.Type = type; break; } if (domainProperty.SerializationName == "") { domainProperty.SerializationName = domainProperty.Name; domainProperty.IsSerializationNameTracking = TrackingEnum.IgnoreOnce; } } }
public override void ElementAdded(ElementAddedEventArgs e) { ShapeElementContainsChildShapes con = e.ModelElement as ShapeElementContainsChildShapes; if (con != null) { NodeShape childShape = con.ChildShape; NodeShape parentShape = con.ParentShape; if (childShape != null && parentShape != null) { if (childShape.IsDeleted) return; if (parentShape.IsDeleted) return; parentShape.AddToShapeMapping(childShape); childShape.UpdateAbsoluteLocation(); if (childShape.Location == PointD.Empty) childShape.SetAtFreePositionOnParent(); } else con.Delete(); } }
public override void ElementAdded(ElementAddedEventArgs 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; GeneratedDomainElement generatedDomainElement = e.ModelElement as GeneratedDomainElement; if (generatedDomainElement != null) { System.Collections.ObjectModel.ReadOnlyCollection<ModelElement> elements = generatedDomainElement.Store.ElementDirectory.FindElements(DomainClass.DomainClassId); foreach (ModelElement m in elements) if (m is DomainClass) if ((m as DomainClass).IsDomainModel) { generatedDomainElement.Namespace = (m as DomainClass).Namespace; return; } } }
public override void ElementAdded(ElementAddedEventArgs 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; DomainClass domainClass = e.ModelElement as DomainClass; if (domainClass != null) { if (domainClass.DomainModelTreeNodes.Count == 0) { RootNode node = new RootNode(domainClass.Store); node.DomainElement = domainClass; node.IsElementHolder = true; // add to the domain model diagram tree domainClass.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(node); domainClass.ModelContext.ViewContext.DomainModelTreeView.RootNodes.Add(node); } } }
/// <summary> /// Called whenever a model element is added to the store. /// </summary> /// <param name="sender">ViewModelStore</param> /// <param name="args">Event Arguments for notification of the creation of new model element.</param> protected virtual void OnElementAdded(object sender, ElementAddedEventArgs args) { EventManager.GetEvent<ModelElementAddedEvent>().Publish(args); if( args.ModelElement is ElementLink ) EventManager.GetEvent<ModelElementLinkAddedEvent>().Publish(args); }
public override void ElementAdded(ElementAddedEventArgs 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 (enumerationLiteral.DisplayName == "") { enumerationLiteral.DisplayName = StringHelper.BreakUpper(enumerationLiteral.Name); enumerationLiteral.IsDisplayNameTracking = TrackingEnum.IgnoreOnce; } if (enumerationLiteral.SerializationName == "") { enumerationLiteral.SerializationName = enumerationLiteral.Name; enumerationLiteral.IsSerializationNameTracking = TrackingEnum.IgnoreOnce; } } }
public override void ElementAdded(ElementAddedEventArgs e) { // if aren't adding a shape, just return var addedShape = e.ModelElement as ShapeElement; if (addedShape == null) { return; } // only layout classes and links if (!(addedShape is EntityTypeShape || addedShape is AssociationConnector || addedShape is InheritanceConnector)) { return; } // layout this new shape var diagram = addedShape.Diagram as EntityDesignerDiagram; if (diagram != null && diagram.Arranger != null) { diagram.Arranger.Add(addedShape, false); } }
private void OnElementAdded(ElementAddedEventArgs args) { SpecificDependenciesItemViewModel vm = this.CreateSpecificViewModel(this.ViewModelStore, args.ModelElement); this.itemViewModels.Add(vm); UpdateIndices(); }
public override void ElementAdded(ElementAddedEventArgs e) { PrimitiveDataTypeCollection dataContractPrimitiveCollection = e.ModelElement as PrimitiveDataTypeCollection; if (dataContractPrimitiveCollection == null) { return; } DataContractModel root = dataContractPrimitiveCollection.DataContractModel; if(root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(dataContractPrimitiveCollection, root.ImplementationTechnology); } if(string.IsNullOrEmpty(dataContractPrimitiveCollection.ItemType)) { dataContractPrimitiveCollection.ItemType = typeof(string).FullName; } if (String.IsNullOrEmpty(dataContractPrimitiveCollection.Namespace)) { dataContractPrimitiveCollection.Namespace = ArtifactLinkHelper.DefaultNamespace(e.ModelElement); } UpdateDataContractCollectionType(dataContractPrimitiveCollection, CollectionTypes.Values[CollectionTypes.ListKey]); }
/// <summary> /// Triggers this notification rule whether a <see cref="ElementSchema"/> is added. /// </summary> /// <param name="e">The provided data for this event.</param> public override void ElementAdded(ElementAddedEventArgs e) { Guard.NotNull(() => e, e); var element = (ExtensionPointSchema)e.ModelElement; if (!element.Store.TransactionManager.CurrentTransaction.IsSerializing) { if (element.Owner == null) { var relationship = (ViewHasExtensionPoints)DomainRelationshipInfo.FindEmbeddingElementLink(element); if (relationship != null) { relationship.WithTransaction(r => { r.Cardinality = Runtime.Cardinality.ZeroToMany; }); } } else { var relationship = (ElementHasExtensionPoints)DomainRelationshipInfo.FindEmbeddingElementLink(element); if (relationship != null) { relationship.WithTransaction(r => { r.Cardinality = Runtime.Cardinality.ZeroToMany; }); } } } }
/// <summary> /// Triggers this notification rule whether a <see cref="AbstractElement"/> is added. /// </summary> /// <param name="e">The provided data for this event.</param> public override void ElementAdded(ElementAddedEventArgs e) { Guard.NotNull(() => e, e); var element = (AbstractElement)e.ModelElement; var info = FindInfo(element); if (info != null) { element.Info = info; if (string.IsNullOrEmpty(element.InstanceName)) { element.InstanceName = info.DisplayName; } element.SyncPropertiesFrom(info.Properties); element.SyncElementsFrom(info.Elements); var patternManager = element.Store.GetService<IPatternManager>(); if (patternManager != null) { element.SyncExtensionPointsFrom(info.ExtensionPoints, patternManager); } } else { tracer.Warn(Resources.TracerWarning_ElementInfoNotFound, element.Id); } }
/// <summary> /// This method is called when the rule is fired, that is when a new connection is added to the model. /// </summary> /// <param name="e">the ElementAddedEventArgs</param> public override void ElementAdded(ElementAddedEventArgs e) { BinaryLinkShape c = e.ModelElement as BinaryLinkShape; if (c == null) return; CompartmentMappingUtil.RerouteCompartmentMappings(c); }
public override void ElementAdded(ElementAddedEventArgs e) { NodeShape nodeShape = e.ModelElement as NodeShape; if (nodeShape != null) { //nodeShape.FixUpMissingLinkShapes(); } }
/// <summary> /// AddRule: typeof(AssimilationMappingCustomizesFactType) /// </summary> private static void AssimilationMappingAddedRule(ElementAddedEventArgs e) { ORMCore.ORMModel ormModel = ((AssimilationMappingCustomizesFactType)e.ModelElement).FactType.Model; if (ormModel != null) { RebuildAbstractionModel(AbstractionModelIsForORMModel.GetAbstractionModel(ormModel)); } }
/// <summary> /// Called whenever a relationship of type ModalDiagramReferencesDomainClass is added and /// the element hosted by this model is the source. /// </summary> /// <param name="args"></param> private void OnReferenceAdded(ElementAddedEventArgs args) { ModalDiagramReferencesDomainClass con = args.ModelElement as ModalDiagramReferencesDomainClass; if (con != null) { SetReference(con.DomainClass); } }
public override void ElementAdded(ElementAddedEventArgs e) { Endpoint endpoint = e.ModelElement as Endpoint; IExtensibleObject extensibleObject = endpoint as IExtensibleObject; if(extensibleObject.ExtensionProvider != null) { ExtensionProviderHelper.AttachObjectExtender(endpoint, extensibleObject.ExtensionProvider); } }
public override void ElementAdded(ElementAddedEventArgs e) { ServiceDescription service = e.ModelElement as ServiceDescription; IExtensibleObject extensibleObject = service as IExtensibleObject; if(extensibleObject.ExtensionProvider != null) { ExtensionProviderHelper.AttachObjectExtender(service, extensibleObject.ExtensionProvider); } }
public override void ElementAdded(ElementAddedEventArgs e) { FaultContract faultContract = e.ModelElement as FaultContract; DataContractModel root = faultContract.DataContractModel; if(root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(faultContract, root.ImplementationTechnology); } }
/// <summary> /// Triggers this notification rule when a <see cref="CustomizableElementSchema"/> is added. /// </summary> /// <param name="e">The provided data for this event.</param> public override void ElementAdded(ElementAddedEventArgs e) { Guard.NotNull(() => e, e); // Ensure this element has a customization policy and settings var element = (CustomizableElementSchema)e.ModelElement; if (element != null) { element.EnsurePolicyAndDefaultSettings(); } }
public override void ElementAdded(ElementAddedEventArgs e) { Transition transition = (Transition)e.ModelElement; if (!transition.Store.TransactionManager.CurrentTransaction.IsSerializing) { if (!string.IsNullOrEmpty(transition.Successor.Key)) transition.Key = transition.Successor.Key; if (transition.Successor.Predecessors.Count == 1) transition.Successor.Initial = false; } }
public override void ElementAdded(ElementAddedEventArgs e) { Message messageContract = e.ModelElement as Message; ServiceContractModel root = messageContract.ServiceContractModel; if(root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(messageContract, root.ImplementationTechnology); } }
public override void ElementAdded(ElementAddedEventArgs e) { DataContractCollection dataContractCollection = e.ModelElement as DataContractCollection; DataContractModel root = dataContractCollection.DataContractModel; if(root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(dataContractCollection, root.ImplementationTechnology); } }
/// <summary> /// Element added logic. /// </summary> /// <param name="e"></param> public override void ElementAdded(ElementAddedEventArgs e) { base.ElementAdded(e); if (e.ModelElement as DomainModelElement == null) return; if (e.ModelElement.Store.InSerializationTransaction) return; this.factoryHelper.AddShapesForElement(e.ModelElement as DomainModelElement); }
public override void ElementAdded(ElementAddedEventArgs e) { ReferenceDataType rdt = e.ModelElement as ReferenceDataType; if (rdt != null && rdt.DataContract != null) { DataContractCompartmentShape shape = DomainModelHelper.GetShapeFromElement<DataContractCompartmentShape>(rdt.DataContract); if (shape != null) { shape.OutlineDashStyle = System.Drawing.Drawing2D.DashStyle.Dash; shape.OutlineThickness = 0.0165F; } } }
public override void ElementAdded(ElementAddedEventArgs e) { MessageBase contract = e.ModelElement as MessageBase; ServiceContractModel root = contract.ServiceContractModel; if(root != null) { if(String.IsNullOrEmpty(contract.Namespace)) { contract.Namespace = root.Namespace; } } }
public override void ElementAdded(ElementAddedEventArgs e) { PrimitiveMessagePart messagePart = e.ModelElement as PrimitiveMessagePart; if (messagePart.Message != null) { ServiceContractModel root = messagePart.Message.ServiceContractModel; if (root != null && root.ImplementationTechnology != null) { ExtensionProviderHelper.AttachObjectExtender(messagePart, root.ImplementationTechnology); } } }
public override void ElementAdded(ElementAddedEventArgs e) { var associationConnector = e.ModelElement as AssociationConnector; Debug.Assert(associationConnector != null); var tx = ModelUtils.GetCurrentTx(associationConnector.Store); Debug.Assert(tx != null); if (tx != null && !tx.IsSerializing) { ViewModelChangeContext.GetNewOrExistingContext(tx).ViewModelChanges.Add(new AssociationConnectorAdd(associationConnector)); } }
public override void ElementAdded(ElementAddedEventArgs e) { Contract contract = e.ModelElement as Contract; DataContractModel root = contract.DataContractModel; if(root != null) { if(String.IsNullOrEmpty(contract.Namespace)) { contract.Namespace = root.Namespace; } } }