/// <summary>
        /// Ensures that the user truly wants to remove a reference to a domain model.
        /// </summary>
        /// <returns>True to remove; False otherwise.</returns>
        protected override bool EnsureClosing()
        {
            if (!IsReferencedModelSet)
            {
                return(true);
            }

            global::Tum.VModellXT.Musterbibliothek refModel = this.Elements[0] as global::Tum.VModellXT.Musterbibliothek;

            // we need to gather references that will be deleted if the referenced model is removed

            // 1. gather excluded domain models
            System.Collections.Generic.List <DslModeling::ModelElement> excludedDomainModels = new System.Collections.Generic.List <DslModeling::ModelElement>();
            foreach (DslModeling::ModelElement domainModel in this.Store.ElementDirectory.FindElements(global::Tum.VModellXT.Musterbibliothek.DomainClassId))
            {
                if (domainModel == refModel)
                {
                    continue;
                }

                DslModeling::ModelElement parent = domainModel;
                while (parent != null)
                {
                    parent = VModellXTElementParentProvider.Instance.GetParentModelElement(parent) as DslModeling::ModelElement;
                    if (parent == refModel)
                    {
                        excludedDomainModels.Add(parent);
                        break;
                    }
                }
            }

            // 2. add elements of those excluded domain models to get existing dependencies on them to
            // the actual domain models
            System.Collections.Generic.List <DslModeling::ModelElement> elements = VModellXTElementChildrenProvider.Instance.GetChildren(refModel.VModell, false);

            // 3. ensure user wants to continue
            using (DslEditorViewModelDeletion::DeletionViewModel vm = new DslEditorViewModelDeletion::DeletionViewModel(this.ViewModelStore))
            {
                vm.Set(elements, new RetrivalOptions(excludedDomainModels));
                vm.Description = "Attention: This deletion can not be undone! \r\n \r\n" + vm.Description;

                bool?result = this.GlobalServiceProvider.Resolve <DslEditorViewModelServices::IUIVisualizerService>().ShowDialog("DeleteElementsPopup", vm);
                if (!result == true)
                {
                    return(false);
                }
            }
            System.GC.Collect();

            // 4. delete referenced model and flush undo/redo stacks
            using (new Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.UI.WaitCursor())
            {
                using (DslModeling::Transaction transaction = this.Store.TransactionManager.BeginTransaction("Delete referenced model"))
                {
                    refModel.VModell.Delete();
                    transaction.Commit();
                }
            }
            this.ModelData.FlushUndoRedoStacks();

            return(true);
        }
        /// <summary>
        /// Ensures that the user truly wants to remove a reference to a domain model.
        /// </summary>
        /// <returns>True to remove; False otherwise.</returns>
        protected override bool EnsureClosing()
		{
			if (!IsReferencedModelSet)
                return true;

			global::Tum.VModellXT.Musterbibliothek refModel = this.Elements[0] as global::Tum.VModellXT.Musterbibliothek;
            
			// we need to gather references that will be deleted if the referenced model is removed
            
            // 1. gather excluded domain models
            System.Collections.Generic.List<DslModeling::ModelElement> excludedDomainModels = new System.Collections.Generic.List<DslModeling::ModelElement>();
			foreach(DslModeling::ModelElement domainModel in this.Store.ElementDirectory.FindElements(global::Tum.VModellXT.Musterbibliothek.DomainClassId))
			{
				if( domainModel == refModel )
					continue;
			
				DslModeling::ModelElement parent = domainModel;
				while(parent != null )
				{			
					parent = VModellXTElementParentProvider.Instance.GetParentModelElement(parent) as DslModeling::ModelElement;
					if( parent == refModel )
					{
						excludedDomainModels.Add(parent);
						break;
					}
				}					
			}
            
            // 2. add elements of those excluded domain models to get existing dependencies on them to 
            // the actual domain models
            System.Collections.Generic.List<DslModeling::ModelElement> elements = VModellXTElementChildrenProvider.Instance.GetChildren(refModel.VModell, false);

            // 3. ensure user wants to continue
            using( DslEditorViewModelDeletion::DeletionViewModel vm = new DslEditorViewModelDeletion::DeletionViewModel(this.ViewModelStore) )
			{
        	    vm.Set(elements, new RetrivalOptions(excludedDomainModels));
        	    vm.Description = "Attention: This deletion can not be undone! \r\n \r\n" + vm.Description;

        	    bool? result = this.GlobalServiceProvider.Resolve<DslEditorViewModelServices::IUIVisualizerService>().ShowDialog("DeleteElementsPopup", vm);
        	    if (!result == true)
        	        return false;

        	    }
            System.GC.Collect();

            // 4. delete referenced model and flush undo/redo stacks
            using (new Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.UI.WaitCursor())
            {
                using (DslModeling::Transaction transaction = this.Store.TransactionManager.BeginTransaction("Delete referenced model"))
                {
                    refModel.VModell.Delete();
                    transaction.Commit();
                }
            }
            this.ModelData.FlushUndoRedoStacks();

            return true;
		}