/// <summary> /// Gathers dependencies for given model elements and and wraps them for display. /// </summary> /// <param name="elements">Model elements to display dependencies for.</param> /// <param name="options">Options</param> public void Set(List <ModelElement> elements, DependenciesRetrivalOptions options) { Clear(); this.retrivalOptions = options; if (elements == null) { throw new ArgumentNullException("elements"); } this.modelElements = elements; // gather dependencies if (options != null) { this.dependenciesData = this.ViewModelStore.TopMostStore.GetDomainModelServices().DependenciesItemsProvider.GetDependencies(modelElements, options); } else { this.dependenciesData = this.ViewModelStore.TopMostStore.GetDomainModelServices().DependenciesItemsProvider.GetDependencies(modelElements); } List <DependencyItem> dependencies = this.dependenciesData.ActiveDependencies; List <DependencyItemViewModel> dependenciesVM = new List <DependencyItemViewModel>(); foreach (DependencyItem item in dependencies) { dependenciesVM.Add(new DependencyItemViewModel(this.ViewModelStore, item, this.doSubscribeToEvents)); } foreach (DependencyItemViewModel item in dependenciesVM) { Add(item); } if (doSubscribeToEvents) { // subscribe to events notifying of new dependencies beeing created foreach (DependencyOriginItem originItem in this.dependenciesData.OriginDependencies) { //this.ViewModelStore.EventManager.GetEvent<ModelElementAddedEvent>().Subscribe(originItem.RelationshipInfo, OnElementLinkAdded); this.ViewModelStore.EventManager.GetEvent <ModelElementLinkAddedEvent>().Subscribe(originItem.RelationshipInfo, originItem.ElementId, OnElementLinkAdded); } } Sort(sortOrder, isAscending); }
/// <summary> /// Gatheres dependencies on elements that are about to be deleted and wraps them for display. /// </summary> /// <param name="elementsToBeDeleted">Elements that are about to be deleted.</param> /// <param name="options">Options</param> public void Set(List <ModelElement> elementsToBeDeleted, DependenciesRetrivalOptions options) { // for each element that is about to be deleted gather child elements, so that we display all relationships that are // about to be deleted. List <ModelElement> elements = new List <ModelElement>(); elements.AddRange(elementsToBeDeleted); foreach (ModelElement element in elements) { List <ModelElement> children = this.ViewModelStore.GetDomainModelServices(element).ElementChildrenProvider.GetChildren(element, true); foreach (ModelElement child in children) { if (!elementsToBeDeleted.Contains(child)) { elementsToBeDeleted.Add(child); } } } this.dependenciesViewModel.Set(elementsToBeDeleted); }
/// <summary> /// Gathers dependencies for given model elements and and wraps them for display. /// </summary> /// <param name="elements">Model elements to display dependencies for.</param> /// <param name="options">Options</param> public void Set(List<ModelElement> elements, DependenciesRetrivalOptions options) { Clear(); this.retrivalOptions = options; if (elements == null) throw new ArgumentNullException("elements"); this.modelElements = elements; // gather dependencies if (options != null) this.dependenciesData = this.ViewModelStore.TopMostStore.GetDomainModelServices().DependenciesItemsProvider.GetDependencies(modelElements, options); else this.dependenciesData = this.ViewModelStore.TopMostStore.GetDomainModelServices().DependenciesItemsProvider.GetDependencies(modelElements); List<DependencyItem> dependencies = this.dependenciesData.ActiveDependencies; List<DependencyItemViewModel> dependenciesVM = new List<DependencyItemViewModel>(); foreach (DependencyItem item in dependencies) dependenciesVM.Add(new DependencyItemViewModel(this.ViewModelStore, item, this.doSubscribeToEvents)); foreach (DependencyItemViewModel item in dependenciesVM) { Add(item); } if (doSubscribeToEvents) { // subscribe to events notifying of new dependencies beeing created foreach (DependencyOriginItem originItem in this.dependenciesData.OriginDependencies) //this.ViewModelStore.EventManager.GetEvent<ModelElementAddedEvent>().Subscribe(originItem.RelationshipInfo, OnElementLinkAdded); this.ViewModelStore.EventManager.GetEvent<ModelElementLinkAddedEvent>().Subscribe(originItem.RelationshipInfo, originItem.ElementId, OnElementLinkAdded); } Sort(sortOrder, isAscending); }
/// <summary> /// Gatheres dependencies on elements that are about to be deleted and wraps them for display. /// </summary> /// <param name="elementsToBeDeleted">Elements that are about to be deleted.</param> /// <param name="options">Options</param> public void Set(List<ModelElement> elementsToBeDeleted, DependenciesRetrivalOptions options) { // for each element that is about to be deleted gather child elements, so that we display all relationships that are // about to be deleted. List<ModelElement> elements = new List<ModelElement>(); elements.AddRange(elementsToBeDeleted); foreach (ModelElement element in elements) { List<ModelElement> children = this.ViewModelStore.GetDomainModelServices(element).ElementChildrenProvider.GetChildren(element, true); foreach (ModelElement child in children) if (!elementsToBeDeleted.Contains(child)) elementsToBeDeleted.Add(child); } this.dependenciesViewModel.Set(elementsToBeDeleted); }