/// <summary> /// Deletes the rs view model that is hosting the given node. /// </summary> /// <param name="node">Node.</param> public void DeleteEmbeddingNode(EmbeddingNode node) { for (int i = this.embeddingNodeVMs.Count - 1; i >= 0; i--) { if (this.embeddingNodeVMs[i].EmbeddingNode.Id == node.Id) { this.embeddingNodeVMs[i].Dispose(); this.embeddingNodeVMs.RemoveAt(i); } } }
/// <summary> /// Adds a new embedding rs view model for the given node. /// </summary> /// <param name="node">Node.</param> public void AddEmbeddingNode(EmbeddingNode node) { // verify that node hasnt been added yet foreach (EmbeddingNodeViewModel viewModel in this.embeddingNodeVMs) { if (viewModel.EmbeddingNode.Id == node.Id) { return; } } EmbeddingNodeViewModel vm = new EmbeddingNodeViewModel(this.ViewModelStore, node, this); this.embeddingNodeVMs.Add(vm); }
/// <summary> /// Adds a new embedding relationship instance. Needs to be called within a modeling transaction. /// </summary> /// <param name="source">Domain class representing the parent.</param> /// <param name="target">Domain class representing the child.</param> public static void AddNewEmbeddingRS(EmbeddingRelationship emb, DomainClass source, AttributedDomainElement target, bool bTargetElementHolder) { // tree nodes // 1. find the element holder node for source // 2. add new EmbeddingRSNode, connect to rs // 3. add new EmbeddingNode for target TreeNode elementHolderNode = null; foreach (TreeNode node in source.DomainModelTreeNodes) { if (node.IsElementHolder) { elementHolderNode = node; break; } } if (elementHolderNode == null) { throw new ArgumentNullException("elementHolderNode"); } EmbeddingRSNode rsNode = new EmbeddingRSNode(source.Store); rsNode.Relationship = emb; EmbeddingNode embNode = new EmbeddingNode(source.Store); embNode.DomainElement = target; embNode.IsElementHolder = bTargetElementHolder; if (!bTargetElementHolder) { embNode.IsExpanded = false; } elementHolderNode.EmbeddingRSNodes.Add(rsNode); rsNode.EmbeddingNode = embNode; source.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(rsNode); source.ModelContext.ViewContext.DomainModelTreeView.ModelTreeNodes.Add(embNode); }
/// <summary> /// Deletes the rs view model that is hosting the given node. /// </summary> /// <param name="node">Node.</param> public void DeleteEmbeddingNode(EmbeddingNode node) { for (int i = this.embeddingNodeVMs.Count - 1; i >= 0; i--) if (this.embeddingNodeVMs[i].EmbeddingNode.Id == node.Id) { this.embeddingNodeVMs[i].Dispose(); this.embeddingNodeVMs.RemoveAt(i); } }
/// <summary> /// Adds a new embedding rs view model for the given node. /// </summary> /// <param name="node">Node.</param> public void AddEmbeddingNode(EmbeddingNode node) { // verify that node hasnt been added yet foreach (EmbeddingNodeViewModel viewModel in this.embeddingNodeVMs) if (viewModel.EmbeddingNode.Id == node.Id) return; EmbeddingNodeViewModel vm = new EmbeddingNodeViewModel(this.ViewModelStore, node, this); this.embeddingNodeVMs.Add(vm); }
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; } TreeNodeReferencesEmbeddingRSNodes con = e.ModelElement as TreeNodeReferencesEmbeddingRSNodes; if (con != null) { EmbeddingRSNode rsNode = con.EmbeddingRSNode; if (rsNode != null) { EmbeddingNode node = rsNode.EmbeddingNode; if (node != null) { // since this node still exists, it isnt included in the deletion process // --> move to root node if this node is the element holder, as its parent has been deleted if (node.IsElementHolder) { RootNode rootNode = new RootNode(node.Store); rootNode.DomainElement = node.DomainElement; node.EmbeddingModelTreeViewModel.RootNodes.Add(rootNode); node.EmbeddingModelTreeViewModel.ModelTreeNodes.Add(rootNode); // copy sub tree for (int i = node.EmbeddingRSNodes.Count - 1; i >= 0; i--) { node.EmbeddingRSNodes[i].TreeNode = rootNode; } for (int i = node.ReferenceRSNodes.Count - 1; i >= 0; i--) { node.ReferenceRSNodes[i].TreeNode = rootNode; } for (int i = node.InheritanceNodes.Count - 1; i >= 0; i--) { node.InheritanceNodes[i].TreeNode = rootNode; } for (int i = node.ShapeClassNodes.Count - 1; i >= 0; i--) { node.ShapeClassNodes[i].TreeNode = rootNode; } rootNode.IsElementHolder = true; rootNode.IsEmbeddingTreeExpanded = node.IsEmbeddingTreeExpanded; rootNode.IsExpanded = true; rootNode.IsInheritanceTreeExpanded = node.IsInheritanceTreeExpanded; rootNode.IsReferenceTreeExpanded = node.IsReferenceTreeExpanded; rootNode.IsShapeMappingTreeExpanded = node.IsShapeMappingTreeExpanded; } node.Delete(); } rsNode.Delete(); } } }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> /// <param name="embeddingNode">Embedding node.</param> /// <param name="parent">Parent.</param> public EmbeddingNodeViewModel(ViewModelStore viewModelStore, EmbeddingNode embeddingNode, EmbeddingRSNodeViewModel parent) : base(viewModelStore, embeddingNode, parent.Parent) { this.parentTreeNode = parent; }