protected virtual BaseModelElementTreeViewModel AddChildElement(ElementLink relationship, ModelElement element, bool isInDeserialization) { if (element == null || relationship == null) { return(null); } // check if already added if (!isInDeserialization) { foreach (Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.ModelTree.BaseModelElementTreeViewModel vm in this.Children) { // this can actually happen without any error occuring, because it depends on // the order of transactions.. e.g.: // 1. Add parent in first transaction. Add child in second --> this clause will not occur. // 2. Add parent and child in one transaction. This clause will occur, because parent // automatically adds its children and there is no easy way of preventing this method from // beeing called. if (vm.Element.Id == element.Id) { return(vm); } } } // create new view model for this specified element ModelElementTreeViewModel viewModel = this.ViewModelStore.Factory.CreateModelElementTreeViewModel(element, relationship, GetTargetDomainRole(relationship.GetDomainRelationship()).Id, this, DoHookUpEvents, DoCreateContextMenus, this.MainModelTreeViewModel); if (viewModel == null) { throw new System.ArgumentNullException("Could not resolve VM for " + element.ToString()); } // add new VModellvariante into children collection this.AddElementToCollection(relationship, viewModel); // set selection to new element if (!isInDeserialization) { if (this.MainModelTreeViewModel != null) { if (this.MainModelTreeViewModel.IsActiveView && !this.ViewModelStore.InLoad) { //viewModel.IsSelected = true; if (viewModel.Parent != null) { if (!viewModel.Parent.IsExpanded) { viewModel.Parent.IsExpanded = true; } } } } } return(viewModel); }
/// <summary> /// Modify the context menu view model by adding custom menu items. /// </summary> /// <param name="contextMenu">Context menu view model containing automatically added menu items.</param> /// <param name="element">Host element.</param> /// <param name="processedProviders">Providers that have already been visited.</param> public virtual void ProcessContextMenu(MenuItemViewModel contextMenu, ModelElementTreeViewModel element, List <IModelTreeContextMenuProvider> processedProviders) { processedProviders.Add(this); foreach (IModelTreeContextMenuProvider p in this.InjectedContextMenuProviders) { if (!processedProviders.Contains(p)) { p.ProcessContextMenu(contextMenu, element, processedProviders); } } }
/// <summary> /// Modify the context menu view model by adding custom menu items. /// </summary> /// <param name="contextMenu">Context menu view model containing automatically added menu items.</param> /// <param name="element">Host element.</param> public void ProcessContextMenu(MenuItemViewModel contextMenu, ModelElementTreeViewModel element) { this.ProcessContextMenu(contextMenu, element, new List <IModelTreeContextMenuProvider>()); }
public ModelElementTreeViewModel(ViewModelStore viewModelStore, ModelElement element, ElementLink link, System.Guid domainRoleId, ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, MainModelTreeViewModel mainModelTreeVm) : base(viewModelStore, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm) { }
/// <summary> /// Creates the tree view model for the given model element. /// </summary> /// <param name="element">VModell represented by this view model.</param> /// <param name="link">Element link, targeting the hosted element.</param> /// <param name="domainRoleId">Domain role id of the role that the hosted element belongs to.</param> /// <param name="parent">Parent of this view model.</param> /// <param name="bHookUpEvents">Hook up into model events to update the created view model on changes in model if true.</param> /// <param name="bCreateContextMenus">Creates context menus for adding and deleting model elements if true.</param> /// <param name="mainModelTreeVm">Model tree view model, this element vm belongs to.</param> public abstract ModelElementTreeViewModel CreateModelElementTreeViewModel(ModelElement element, ElementLink link, System.Guid domainRoleId, ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, MainModelTreeViewModel mainModelTreeVm);
/// <summary> /// Modify the context menu view model by adding custom menu items. /// </summary> /// <param name="contextMenu">Context menu view model containing automatically added menu items.</param> /// <param name="element">Host element.</param> public void ProcessContextMenu(MenuItemViewModel contextMenu, ModelElementTreeViewModel element) { this.ProcessContextMenu(contextMenu, element, new List<IModelTreeContextMenuProvider>()); }
/// <summary> /// Modify the context menu view model by adding custom menu items. /// </summary> /// <param name="contextMenu">Context menu view model containing automatically added menu items.</param> /// <param name="element">Host element.</param> /// <param name="processedProviders">Providers that have already been visited.</param> public virtual void ProcessContextMenu(MenuItemViewModel contextMenu, ModelElementTreeViewModel element, List<IModelTreeContextMenuProvider> processedProviders) { processedProviders.Add(this); foreach (IModelTreeContextMenuProvider p in this.InjectedContextMenuProviders) if( !processedProviders.Contains(p) ) p.ProcessContextMenu(contextMenu, element, processedProviders); }
public ModelElementTreeViewModel(ViewModelStore viewModelStore, ModelElement element, ElementLink link, System.Guid domainRoleId, ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, MainModelTreeViewModel mainModelTreeVm) : base(viewModelStore, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm) { }