/// <summary>
        /// Converts the property value and returns the converted value.
        /// </summary>
        /// <returns>Converted property value.</returns>
        public override object GetPropertyValue()
        {
            global::Tum.VModellXT.Musterbibliothek model = this.Elements[0] as global::Tum.VModellXT.Musterbibliothek;

            if (model.VModell == null)
            {
                return("");
            }

            DslEditorModeling::IParentModelElement parent = model.GetDomainModelServices().ElementParentProvider.GetParentModelElement(model);

            if (parent == null)
            {
                throw new System.ArgumentNullException("Parent of element " + model.ToString() + " can not be null");
            }

            string path             = parent.DomainFilePath;
            string vModellDirectory = new System.IO.FileInfo(path).DirectoryName;

            global::Tum.VModellXT.VModell refModel = model.VModell;
            string curPath = Tum.PDE.ToolFramework.Modeling.Visualization.VMXExtensions.Path.PathHelper.EvaluateRelativePath(
                vModellDirectory, (refModel as DslEditorModeling::IParentModelElement).DomainFilePath);

            return(curPath);
        }
        /// <summary>
        /// Loads the model from the given file path and sets it to its appropriate element.
        /// </summary>
        /// <param name="filePath">File path to load the model from. Can be null to indicate that there is no referenced domain model.</param>
        protected override void SetReferencedModel(string filePath)
        {
            using (new Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.UI.WaitCursor())
            {
                global::Tum.VModellXT.Musterbibliothek model = this.Elements[0] as global::Tum.VModellXT.Musterbibliothek;
                string file = filePath;

                DslEditorModeling::IParentModelElement parent = model.GetDomainModelServices().ElementParentProvider.GetParentModelElement(model);
                if (parent == null)
                {
                    throw new System.ArgumentNullException("Parent of element " + model.ToString() + " can not be null");
                }

                string path             = parent.DomainFilePath;
                string vModellDirectory = new System.IO.FileInfo(path).DirectoryName;
                //string curPath = Tum.PDE.ToolFramework.Modeling.Visualization.VMXExtensions.Path.PathHelper.EvaluateRelativePath(
                //	vModellDirectory, file);

                // load model
                try
                {
                    if (!System.IO.File.Exists(file))
                    {
                        System.IO.FileStream s = System.IO.File.Create(file);
                        s.Close();
                    }

                    using (DslModeling::Transaction transaction = this.Store.TransactionManager.BeginTransaction("Set referenced model"))
                    {
                        global::Tum.VModellXT.VModellXTDocumentData data = this.ViewModelStore.ModelData as global::Tum.VModellXT.VModellXTDocumentData;
                        global::Tum.VModellXT.VModell referenceModel     = data.ModelContextVModellXT.LoadInternal(file) as  global::Tum.VModellXT.VModell;
                        model.VModell = referenceModel;

                        transaction.Commit();
                    }
                }
                catch (System.Exception ex)
                {
                    DslEditorViewModelServices::IMessageBoxService messageBox = this.GlobalServiceProvider.Resolve <DslEditorViewModelServices::IMessageBoxService>();
                    messageBox.ShowError(ex.Message);
                }

                this.ModelData.FlushUndoRedoStacks();
            }
        }
		/// <summary>
		/// Helper method to create and initialize a new Musterbibliothek.
		/// </summary>
		internal protected virtual global::Tum.VModellXT.Musterbibliothek CreateModelHelperMusterbibliothek(DslModeling::Partition modelPartition)
		{
			global::Tum.VModellXT.Musterbibliothek model = new global::Tum.VModellXT.Musterbibliothek(modelPartition, 
				global::Tum.VModellXT.VModellXTDomainModelIdProvider.Instance.AssignId(null));
			if( VModellXTElementNameProvider.Instance.HasName(model) )
				VModellXTElementNameProvider.Instance.SetName(model, "Musterbibliothek");
				
			return model;
		}
        /// <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);
        }