/// <summary> /// Called whenever a relationship of type RelationshipShapeClassReferencesReferenceRelationship is deleted and /// the element hosted by this model is the source. /// </summary> /// <param name="args"></param> private void OnRSShapeElementRemoved(ElementDeletedEventArgs args) { RelationshipShapeClassReferencesReferenceRelationship con = args.ModelElement as RelationshipShapeClassReferencesReferenceRelationship; if (con != null) { DeleteElement(); } }
/// <summary> /// Called whenever a relationship of type RelationshipShapeClassReferencesReferenceRelationship is added and /// the element hosted by this model is the source. /// </summary> /// <param name="args"></param> private void OnRSShapeElementAdded(ElementAddedEventArgs args) { RelationshipShapeClassReferencesReferenceRelationship con = args.ModelElement as RelationshipShapeClassReferencesReferenceRelationship; if (con != null) { AddRSShapeElement(con.DomainRelationship); } }
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; } RelationshipShapeClassReferencesReferenceRelationship con = e.ModelElement as RelationshipShapeClassReferencesReferenceRelationship; if (con != null) { if (con.DomainRelationship is ReferenceRelationship) { ReferenceRelationship rel = con.DomainRelationship as ReferenceRelationship; ReferenceRSNode node = rel.ReferenceRSNode; // create new shape relationship node ShapeRelationshipNode shapeNode = new ShapeRelationshipNode(con.Store); shapeNode.RelationshipShapeClass = con.RelationshipShapeClass; node.ShapeRelationshipNodes.Add(shapeNode); rel.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(shapeNode); if (rel.SerializedReferenceRelationship != null) { if (!rel.SerializedReferenceRelationship.IsInFullSerialization) { if (System.Windows.MessageBox.Show("Shape mapping has been defined for the ReferenceRelationship '" + rel.Name + "'. The Relationship is not serialized in full form. Would you like to change the serialization of this relationship to full form (strongly adviced)?", "Serialization", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question) == System.Windows.MessageBoxResult.Yes) { rel.SerializedReferenceRelationship.IsInFullSerialization = true; } } } } } }
/// <summary> /// Called on a role player changing. /// </summary> /// <param name="args"></param> private void OnRSShapeElementChanged(RolePlayerChangedEventArgs args) { RelationshipShapeClassReferencesReferenceRelationship con = args.ElementLink as RelationshipShapeClassReferencesReferenceRelationship; if (con != null) { if (con.RelationshipShapeClass == this.DiagramTreeNode.PresentationElementClass) { DeleteElement(); AddRSShapeElement(con.DomainRelationship); } } }
public override void ElementDeleting(ElementDeletingEventArgs 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; } RelationshipShapeClassReferencesReferenceRelationship con = e.ModelElement as RelationshipShapeClassReferencesReferenceRelationship; if (con != null) { if (con.DomainRelationship is ReferenceRelationship) { RelationshipShapeClass shape = con.RelationshipShapeClass; ShapeRelationshipNode node = shape.ShapeRelationshipNode; if (node != null) { // delete ReferenceRelationship rel = con.DomainRelationship as ReferenceRelationship; ReferenceRSNode n = rel.ReferenceRSNode; if (n != null) { if (n.ShapeRelationshipNodes.Contains(node)) { n.ShapeRelationshipNodes.Remove(node); } } node.Delete(); } } } }
public override void RolePlayerChanged(RolePlayerChangedEventArgs e) { if (e.ElementLink != null) { if (e.ElementLink.Store.TransactionManager.CurrentTransaction != null) { if (e.ElementLink.Store.TransactionManager.CurrentTransaction.IsSerializing) { return; } } } if (e.ElementLink == null) { return; } if (ImmutabilityExtensionMethods.GetLocks(e.ElementLink) != Locks.None) { return; } RelationshipShapeClassReferencesReferenceRelationship con = e.ElementLink as RelationshipShapeClassReferencesReferenceRelationship; if (con != null) { RelationshipShapeClass shape = con.RelationshipShapeClass; ShapeRelationshipNode node = shape.ShapeRelationshipNode; // delete old ReferenceRelationship relOld = e.OldRolePlayer as ReferenceRelationship; if (relOld != null) { ReferenceRSNode nodeOld = relOld.ReferenceRSNode; if (nodeOld != null) { node.RelationshipShapeClass = null; if (nodeOld.ShapeRelationshipNodes.Contains(node)) { nodeOld.ShapeRelationshipNodes.Remove(node); } } node.Delete(); } // create new ReferenceRelationship rel = e.NewRolePlayer as ReferenceRelationship; if (rel != null) { ReferenceRSNode n = rel.ReferenceRSNode; // create new shape relationship node ShapeRelationshipNode shapeNode = new ShapeRelationshipNode(con.Store); shape.ShapeRelationshipNode = shapeNode; n.ShapeRelationshipNodes.Add(shapeNode); rel.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(shapeNode); if (rel.SerializedReferenceRelationship != null) { if (!rel.SerializedReferenceRelationship.IsInFullSerialization) { if (System.Windows.MessageBox.Show("Shape mapping has been defined for the ReferenceRelationship '" + rel.Name + "'. The Relationship is not serialized in full form. Would you like to change the serialization of this relationship to full form (strongly adviced)?", "Serialization", System.Windows.MessageBoxButton.YesNo, System.Windows.MessageBoxImage.Question) == System.Windows.MessageBoxResult.Yes) { rel.SerializedReferenceRelationship.IsInFullSerialization = true; } } } } } }