/// <summary> /// Deletes the DomainElement view model that is hosting the given DomainElement. /// </summary> /// <param name="element">DomainElement.</param> public virtual void DeleteElementType(global::Tum.PDE.ModelingDSL.DEType element) { if( element == null ) return; if( this.ElementTypeVM != null ) if( this.ElementTypeVM.Element == element ) { this.ViewModelStore.SpecificViewModelStore.RemoveVM(this.ElementTypeVM, this.Id); if( !this.ViewModelStore.SpecificViewModelStore.IsVMInUse(this.ElementTypeVM) ) this.ElementTypeVM.Dispose(); this.ElementTypeVMHost = null; } OnPropertyChanged("ElementTypeVM"); }
/// <summary> /// Clean up. /// </summary> protected override void OnDispose() { if( this.Element != null ) { this.EventManager.GetEvent<DslEditorViewModelEvents::ModelElementLinkAddedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(global::Tum.PDE.ModelingDSL.DomainElementReferencesDEType.DomainClassId), true, this.Element.Id, new System.Action<DslModeling::ElementAddedEventArgs>(OnElementTypeAdded)); this.EventManager.GetEvent<DslEditorViewModelEvents::ModelElementLinkDeletedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRelationship(global::Tum.PDE.ModelingDSL.DomainElementReferencesDEType.DomainClassId), true, this.Element.Id, new System.Action<DslModeling::ElementDeletedEventArgs>(OnElementTypeRemoved)); this.EventManager.GetEvent<DslEditorViewModelEvents::ModelRolePlayerChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRole(global::Tum.PDE.ModelingDSL.DomainElementReferencesDEType.DomainElementDomainRoleId), new System.Action<DslModeling::RolePlayerChangedEventArgs>(OnElementTypeChanged)); this.EventManager.GetEvent<DslEditorViewModelEvents::ModelRolePlayerChangedEvent>().Unsubscribe(this.Store.DomainDataDirectory.GetDomainRole(global::Tum.PDE.ModelingDSL.DomainElementReferencesDEType.DETypeDomainRoleId), new System.Action<DslModeling::RolePlayerChangedEventArgs>(OnElementTypeChanged)); if( this.ElementTypeVM != null ) { this.ViewModelStore.SpecificViewModelStore.RemoveVM(this.ElementTypeVM, this.Id); if( !this.ViewModelStore.SpecificViewModelStore.IsVMInUse(this.ElementTypeVM) ) if( !this.ElementTypeVM.IsDisposed && !this.ElementTypeVM.IsDisposing ) this.ElementTypeVM.Dispose(); this.ElementTypeVMHost = null; } } base.OnDispose(); }
/// <summary> /// Adds a new DomainType view model for the given DomainType. /// </summary> /// <param name="element">DomainType.</param> public virtual void AddDomainType(global::Tum.PDE.ModelingDSL.DomainType element) { if( element == null && !ShouldCreateVMForNullElements("Tum.PDE.ModelingDSL.DomainType")) return; if( this.DomainTypeVM != null ) if( this.DomainTypeVM.Element == element ) return; DslEditorViewModel::BaseSpecificModelElementViewModel vm = null; if( element != null ) vm= this.ViewModelStore.SpecificViewModelStore.TryGetVM("DslEditorViewModel::BaseSpecificModelElementViewModel", element.Id) as DslEditorViewModel::BaseSpecificModelElementViewModel; if( vm == null ) vm = new DslEditorViewModel::BaseSpecificModelElementViewModel(this.ViewModelStore, element, this); //this.ViewModelStore.SpecificViewModelStore.AddVM(vm, this.Id); this.DomainTypeVMHost = vm; OnPropertyChanged("DomainTypeVM"); }