/// <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 override void ProcessContextMenu(DslEditorMenuModel::MenuItemViewModel contextMenu, DslEditorTreeViewModel::ModelElementTreeViewModel element, System.Collections.Generic.List<DslEditorViewModelContracts::IModelTreeContextMenuProvider> processedProviders) { base.ProcessContextMenu(contextMenu, element, processedProviders); if( element.Element is global::Tum.PDE.VSPluginDSL.DomainClass2 ) { DslEditorMenuModel::MenuItemViewModel openModalVMs = this.FindMenuViewModel(contextMenu, "OpenModalViewsFromModelTreeId"); if( openModalVMs == null ) { openModalVMs = new DslEditorMenuModel::MenuItemViewModel(contextMenu.ViewModelStore); openModalVMs.Text = "Open"; openModalVMs.UserData = "OpenModalViewsFromModelTreeId"; contextMenu.Children.Insert(0, openModalVMs); contextMenu.Children.Insert(1, new DslEditorMenuModel::SeparatorMenuItemViewModel(contextMenu.ViewModelStore)); } if( element.Element is global::Tum.PDE.VSPluginDSL.DomainClass2 ) { DslEditorMenuModel::MenuItemViewModel<DslEditorTreeViewModel::ModelElementTreeViewModel> openVM = new DslEditorMenuModel::MenuItemViewModel<DslEditorTreeViewModel::ModelElementTreeViewModel>(contextMenu.ViewModelStore); openVM.Text = "Open " + "Modal View"; openVM.Command = new DslEditorCommands::DelegateCommand<DslEditorTreeViewModel::ModelElementTreeViewModel>(OpenModalDiagramTemplate); openVM.CommandParameter = element; openModalVMs.Children.Add(openVM); } } }
public ModelTreeStateMachineLanguageViewModel(DslEditorViewModelData::ViewModelStore viewModelStore, DslModeling::ModelElement element, DslModeling::ElementLink link, System.Guid domainRoleId, DslEditorTreeViewModel::ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, DslEditorViewModel::MainModelTreeViewModel mainModelTreeVm) : base(viewModelStore, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm) { }
public override DslEditorViewModelModelTree::ModelElementTreeViewModel CreateModelElementTreeViewModel(DslModeling::ModelElement element, DslModeling::ElementLink link, System.Guid domainRoleId, DslEditorViewModelModelTree::ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, DslEditorViewModel::MainModelTreeViewModel mainModelTreeVm) { if( element is DslEditorModeling::IDomainModelOwnable ) { if( global::Tum.FamilyTreeDSL.FamilyTreeDSLDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId() ) return new Tum.FamilyTreeDSL.ViewModel.ModelTree.ModelTreeFamilyTreeDSLViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); } return new DslEditorViewModelModelTree::ModelElementTreeViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); }
public override DslEditorViewModelModelTree::ModelElementTreeViewModel CreateModelElementTreeViewModel(DslModeling::ModelElement element, DslModeling::ElementLink link, System.Guid domainRoleId, DslEditorViewModelModelTree::ModelElementTreeViewModel parent, bool bHookUpEvents, bool bCreateContextMenus, DslEditorViewModel::MainModelTreeViewModel mainModelTreeVm) { if( element is DslEditorModeling::IDomainModelOwnable ) { if( global::Tum.VModellXT.VModellXTDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId() ) return new Tum.VModellXT.ViewModel.ModelTree.ModelTreeVModellXTViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); if( global::Tum.VModellXT.Basis.VModellXTBasisDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId() ) return new Tum.VModellXT.Basis.ViewModel.ModelTree.ModelTreeVModellXTBasisViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); if( global::Tum.VModellXT.Statik.VModellXTStatikDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId() ) return new Tum.VModellXT.Statik.ViewModel.ModelTree.ModelTreeVModellXTStatikViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); if( global::Tum.VModellXT.Dynamik.VModellXTDynamikDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId() ) return new Tum.VModellXT.Dynamik.ViewModel.ModelTree.ModelTreeVModellXTDynamikViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); if( global::Tum.VModellXT.Anpassung.VModellXTAnpassungDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId() ) return new Tum.VModellXT.Anpassung.ViewModel.ModelTree.ModelTreeVModellXTAnpassungViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); if( global::Tum.VModellXT.Konventionsabbildungen.VModellXTKonventionsabbildungenDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId() ) return new Tum.VModellXT.Konventionsabbildungen.ViewModel.ModelTree.ModelTreeVModellXTKonventionsabbildungenViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); if( global::Tum.VModellXT.Aenderungsoperationen.VModellXTAenderungesoperationenDomainModel.DomainModelId == (element as DslEditorModeling::IDomainModelOwnable).GetDomainModelTypeId() ) return new Tum.VModellXT.Aenderungsoperationen.ViewModel.ModelTree.ModelTreeVModellXTAenderungesoperationenViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); } return new DslEditorViewModelModelTree::ModelElementTreeViewModel(this.Store, element, link, domainRoleId, parent, bHookUpEvents, bCreateContextMenus, mainModelTreeVm); }
/// <summary> /// Method used to add a element into a sorted collection without destroying the sorting order. /// </summary> /// <param name="collection">Sorted collection to add the new view models to.</param> /// <param name="link">Embedding relationship including the model element as the child (target).</param> /// <param name="c">View model representing the model element to be added to the collection.</param> public override void InsertElement(DslEditorTreeViewModel::BaseModelElementTreeViewModel parent, System.Collections.ObjectModel.ObservableCollection<DslEditorTreeViewModel::BaseModelElementTreeViewModel> collection, DslModeling::ElementLink link, DslEditorTreeViewModel::BaseModelElementTreeViewModel c) { if (parent.ElementLinkOrder.Count <= 1) InsertElement(0, parent, collection, link, c); else { int index = 0; System.Collections.Generic.List<System.Guid> typesBeforeCurrent = new System.Collections.Generic.List<System.Guid>(); System.Guid currentType = c.ElementLinkDomainClassId; for (int i = 0; i < parent.ElementLinkOrder.Count; i++) if (parent.ElementLinkOrder[i] == currentType) { index = i; break; } else typesBeforeCurrent.Add(parent.ElementLinkOrder[i]); if (index > 0) { for (int i = 0; i < collection.Count; i++) { if (typesBeforeCurrent.Contains(collection[i].ElementLinkDomainClassId)) continue; InsertElement(i, parent, collection, link, c); return; } InsertElement(collection.Count, parent, collection, link, c); return; } InsertElement(index, parent, collection, link, c); } }
/// <summary> /// Method used to add a element into a sorted collection without destroying the sorting order. /// </summary> /// <param name="typeIndex">Index in the collection at which the link type's elements start.</param> /// <param name="collection">Sorted collection to add the new view models to.</param> /// <param name="link">Embedding relationship including the model element as the child (target).</param> /// <param name="c">View model representing the model element to be added to the collection.</param> protected virtual void InsertElement(int typeIndex, DslEditorTreeViewModel::BaseModelElementTreeViewModel parent, System.Collections.ObjectModel.ObservableCollection<DslEditorTreeViewModel::BaseModelElementTreeViewModel> collection, DslModeling::ElementLink link, DslEditorTreeViewModel::BaseModelElementTreeViewModel c) { System.Collections.ObjectModel.ReadOnlyCollection<DslModeling::ElementLink> lllinks = DslModeling::DomainRoleInfo.GetElementLinks<DslModeling::ElementLink>(parent.Element, DslEditorModeling::DomainModelElement.GetSourceDomainRole(link.GetDomainRelationship()).Id); int indexOfLink = lllinks.IndexOf(link) + typeIndex; if (indexOfLink >= collection.Count) collection.Add(c); else collection.Insert(indexOfLink, c); }
/// <summary> /// Opens the view model for the ModalDiagramTemplate. /// </summary> /// <param name="treeVM">Tree vm executing this command.</param> public virtual void OpenModalDiagramTemplate(DslEditorTreeViewModel::ModelElementTreeViewModel treeVM) { VSPluginDSLModalDiagramTemplateSurfaceViewModel vm = new VSPluginDSLModalDiagramTemplateSurfaceViewModel(treeVM.ViewModelStore, treeVM.Element as DslEditorModeling::DomainModelElement); DslEditorViewModelEvents::OpenViewModelEventArgs args = new DslEditorViewModelEvents::OpenViewModelEventArgs(vm); args.DockingPaneStyle = Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.DockingPaneStyle.DockedInDocumentPane; treeVM.EventManager.GetEvent<DslEditorViewModelEvents::OpenViewModelEvent>().Publish(args); }