/// <summary>
        /// SelectRelationshipCommand executed;
        /// </summary>
        public void SelectRelationshipCommand_Executed()
        {
            if (this.SelectedItems.Count == 1)
            {
                SerializedDomainClassViewModel classViewModel = this.SelectedItems[0] as SerializedDomainClassViewModel;
                if (classViewModel != null)
                {
                    if (classViewModel.Parent != null)
                    {
                        SelectedItemsCollection col = new SelectedItemsCollection();
                        col.Add(classViewModel.Parent.GetHostedElement());

                        EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
                    }
                }

                SerializedReferenceRelationshipViewModel refRelViewModel = this.SelectedItems[0] as SerializedReferenceRelationshipViewModel;
                if (refRelViewModel != null)
                {
                    if (!refRelViewModel.IsInFullSerialization)
                    {
                        SelectedItemsCollection col = new SelectedItemsCollection();
                        col.Add(refRelViewModel.SerializationElement);
                        EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Navigates forward.
        /// </summary>
        public void NavigateForward()
        {
            if (currentHistoryIndex < currentHistory.Count && currentHistoryIndex >= 0)
            {
                // verify that none of the elements are in deleted state
                for (int i = currentHistoryIndex + 1; i < currentHistory.Count; i++)
                {
                    bool isDeleted = false;
                    SelectedItemsCollection col = currentHistory[i];
                    foreach (ModelElement m in col)
                    {
                        if (m.IsDeleted || m.IsDeleting)
                        {
                            isDeleted = true;
                            break;
                        }
                    }

                    if (!isDeleted)
                    {
                        SelectionChangedEventArgs args = new SelectionChangedEventArgs(null, col);
                        args.UserData = NavigationManagerIdentifier;
                        this.viewModelStore.EventManager.GetEvent <SelectionChangedEvent>().Publish(args);

                        currentHistoryIndex++;

                        return;
                    }
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Method to verify if navigation can occur.
        /// </summary>
        /// <returns>True if navigation can occur. False otherwise.</returns>
        public bool CanNavigateBackward()
        {
            if (this.currentHistory.Count == 1 && currentHistoryIndex < 0)
            {
                return(false);
            }

            // verify that none of the elements are in deleted state
            for (int i = currentHistoryIndex - 1; i >= 0; i--)
            {
                bool isDeleted = false;
                SelectedItemsCollection col = currentHistory[i];
                foreach (ModelElement m in col)
                {
                    if (m.IsDeleted || m.IsDeleting)
                    {
                        isDeleted = true;
                        break;
                    }
                }

                if (!isDeleted)
                {
                    return(true);
                }
            }


            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Execute the Html navigation command.
        /// </summary>
        public void NavigateToHtmlHyperlink(HtmlHyperlink hyperlink)
        {
            if (hyperlink.TargetName.Length == 0)
            {
                return;
            }

            bool bFoundTarget = false;

            if (hyperlink.TargetName[0] == '#')
            {
                string href = hyperlink.TargetName.Substring(1, hyperlink.TargetName.Length - 1);
                if (KeyGenerator.Instance.CanConvertVModellIDToGuid(href))
                {
                    Guid         id           = KeyGenerator.Instance.ConvertVModellIDToGuid(href);
                    ModelElement modelElement = this.Store.ElementDirectory.FindElement(id);
                    if (modelElement != null)
                    {
                        bFoundTarget = true;

                        SelectedItemsCollection col = new SelectedItemsCollection();
                        col.Add(modelElement);
                        EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
                    }
                }
            }

            if (!bFoundTarget)
            {
                System.Windows.MessageBox.Show(hyperlink.TargetName);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Method to verify if navigation can occur.
        /// </summary>
        /// <returns>True if navigation can occur. False otherwise.</returns>
        public bool CanNavigateForward()
        {
            if (currentHistoryIndex < currentHistory.Count && currentHistoryIndex >= 0)
            {
                // verify that none of the elements are in deleted state
                for (int i = currentHistoryIndex + 1; i < currentHistory.Count; i++)
                {
                    bool isDeleted = false;
                    SelectedItemsCollection col = currentHistory[i];
                    foreach (ModelElement m in col)
                    {
                        if (m.IsDeleted || m.IsDeleting)
                        {
                            isDeleted = true;
                            break;
                        }
                    }

                    if (!isDeleted)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
        /// <summary>
        /// Callback from SelectionChangedEvent.
        /// </summary>
        /// <param name="eventArgs">eventArgs.</param>
        protected override void ReactOnViewSelection(SelectionChangedEventArgs eventArgs)
        {
            this.selectedItemsCollection = eventArgs.SelectedItems;
            this.SelectedItemViewModel = null;
            

            if (this.IsInitialized && this.IsDockingPaneVisible)
                Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.Threading.DispatcherExtensions.InvokeAsynchronouslyInBackground(
                    System.Windows.Threading.Dispatcher.CurrentDispatcher, new Action(UpdateVM));
        }
Exemplo n.º 7
0
        /// <summary>
        /// Callback from SelectionChangedEvent.
        /// Executes UpdatePropertyGrid asynchronously on the thread Dispatcher.Current is associated with.
        /// </summary>
        /// <param name="eventArgs">SelectionChangedEventArgs.</param>
        protected virtual void ReactOnViewSelection(SelectionChangedEventArgs eventArgs)
        {
            this.selectedItemsCollection = eventArgs.SelectedItems;

            if (this.IsInitialized && this.IsDockingPaneVisible)
            {
                Threading.DispatcherExtensions.InvokeAsynchronouslyInBackground(
                    System.Windows.Threading.Dispatcher.CurrentDispatcher, new Action(UpdateDependenciesVM));
            }
        }
        /// <summary>
        /// Callback from SelectionChangedEvent.
        /// </summary>
        /// <param name="eventArgs">SelectionChangedEventArgs.</param>
        protected override void ReactOnViewSelection(SelectionChangedEventArgs eventArgs)
        {
            if (eventArgs.SourceViewModel != this)
            {
                this.selectedItemsCollection = eventArgs.SelectedItems;

                Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.Threading.DispatcherExtensions.InvokeAsynchronouslyInBackground(
                    System.Windows.Threading.Dispatcher.CurrentDispatcher, new Action(UpdateSelectedElement));
            }
        }
Exemplo n.º 9
0
        internal void SelectedItems_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            SelectedItemsCollection selection = (SelectedItemsCollection)sender;

            if (selection.Count == 1 && selection[0] is XCaseViewBase)
            {
                DeselectAll(modelClasses);
                DeselectAll(nestedPackages);

                XCaseViewBase selectedXCaseClass = (XCaseViewBase)selection[0];

                if (selectedXCaseClass.ModelElement.VersionManager != null &&
                    selectedXCaseClass.ModelElement.Version != project.Version)
                {
                    BindToProject(selectedXCaseClass.ModelElement.VersionManager.VersionedProjects[selectedXCaseClass.ModelElement.Version]);
                }

                if (selectedXCaseClass.Controller != null && selectedXCaseClass.Controller.NamedElement is Class && !(selectedXCaseClass.Controller.NamedElement is AssociationClass))
                {
                    Class selectedClass;
                    if (selectedXCaseClass.Controller.NamedElement is PIMClass)
                    {
                        selectedClass = selectedXCaseClass.Controller.NamedElement as Class;
                    }
                    else
                    {
                        selectedClass = (selectedXCaseClass.Controller.NamedElement as PSMClass).RepresentedClass;
                        if (selectedClass is AssociationClass)
                        {
                            selectedClass = null;
                        }
                    }
                    if (selectedClass != null)
                    {
                        Package nestingPackage = selectedClass.Package;
                        if (nestingPackage == model)
                        {
                            ExpandAndSelectClass(modelClasses, selectedClass);
                        }
                        else
                        {
                            Collection <Package> packagePath = new Collection <Package>();
                            Package package = nestingPackage;
                            while (package != null)
                            {
                                packagePath.Add(package);
                                package = package.NestingPackage;
                            }

                            ExpandNestedPackages(nestedPackages, selectedClass, packagePath, packagePath.Count - 1);
                        }
                    }
                }
            }
        }
Exemplo n.º 10
0
        void ObjectModelBrowser_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            SelectedItemsCollection col = new SelectedItemsCollection();

            col.Add(this.SelectedElement);

            if (LanguageDSLDocData.ViewModelStore != null)
            {
                LanguageDSLDocData.ViewModelStore.EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(null, col));
            }
        }
        /// <summary>
        /// Navigate To Element Command executed.
        /// </summary>
        protected virtual void NavigateToElementCommand_Executed()
        {
            BaseModelElementViewModel selectedValue = GetPropertyValue() as BaseModelElementViewModel;

            if (selectedValue != null)
            {
                SelectedItemsCollection col = new SelectedItemsCollection();
                col.Add(selectedValue.Element);
                EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
            }
        }
        /// <summary>
        /// Callback from SelectionChangedEvent.
        /// </summary>
        /// <param name="eventArgs">eventArgs.</param>
        protected override void ReactOnViewSelection(SelectionChangedEventArgs eventArgs)
        {
            this.selectedItemsCollection = eventArgs.SelectedItems;
            this.SelectedItemViewModel   = null;


            if (this.IsInitialized && this.IsDockingPaneVisible)
            {
                Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.Threading.DispatcherExtensions.InvokeAsynchronouslyInBackground(
                    System.Windows.Threading.Dispatcher.CurrentDispatcher, new Action(UpdateVM));
            }
        }
Exemplo n.º 13
0
 /// <summary>
 /// Navigate To Element Command executed.
 /// </summary>
 protected virtual void NavigateToElementCommand_Executed()
 {
     if (SelectedObject != null)
     {
         ModelElement selectedValue = SelectedObject.Element;
         if (selectedValue != null)
         {
             SelectedItemsCollection col = new SelectedItemsCollection();
             col.Add(selectedValue);
             EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
         }
     }
 }
        /// <summary>
        /// Navigate to model element
        /// </summary>
        public virtual void Navigate()
        {
            if (this.Element == null)
                return;

            if (this.Element.IsDeleted || this.Element.IsDeleting)
                return;

            SelectedItemsCollection col = new SelectedItemsCollection();
            col.Add(this.Element);

            // notify observers, that selection has changed
            this.EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
        }
Exemplo n.º 15
0
        public ListControl( SectionFactory sectionFactory )
            : base(sectionFactory)
        {
            InitializeComponent();

            _itemList = new BufferedList();
            _itemList.ListControl = this;
            _selectedItems = new SelectedItemsCollection( this );

            _customiseListSection = SectionFactory.CreateCustomiseListSection( this );
            _listSection = SectionFactory.CreateListSection( this );

            Canvas.Children.Add( _customiseListSection );
            Canvas.Children.Add( _listSection );
        }
        /// <summary>
        /// Navigate to model element
        /// </summary>
        public override void Navigate()
        {
            if (this.Source == null)
            {
                return;
            }
            if (this.Source.IsDeleted || this.Source.IsDeleting)
            {
                return;
            }

            SelectedItemsCollection col = new SelectedItemsCollection();

            col.Add(Source);

            // notify observers, that selection has changed
            this.EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
        }
Exemplo n.º 17
0
        /// <summary>
        /// Navigate to target model element
        /// </summary>
        public virtual void NavigateToTarget()
        {
            if (this.DependencyItem.TargetElement == null)
            {
                return;
            }
            if (this.DependencyItem.TargetElement.IsDeleted || this.DependencyItem.TargetElement.IsDeleting)
            {
                return;
            }

            SelectedItemsCollection col = new SelectedItemsCollection();

            col.Add(this.DependencyItem.TargetElement);

            // notify observers, that selection has changed
            this.EventManager.GetEvent <SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
        }
        /// <summary>
        /// Callback from SelectionChangedEvent. 
        /// Executes UpdatePropertyGrid asynchronously on the thread Dispatcher.Current is associated with.
        /// </summary>
        /// <param name="eventArgs">SelectionChangedEventArgs.</param>
        protected virtual void ReactOnViewSelection(SelectionChangedEventArgs eventArgs)
        {
            this.selectedItemsCollection = eventArgs.SelectedItems;

            if (this.IsInitialized && this.IsDockingPaneVisible)
                Threading.DispatcherExtensions.InvokeAsynchronouslyInBackground(
                    System.Windows.Threading.Dispatcher.CurrentDispatcher, new Action(UpdateDependenciesVM));
        }
        /// <summary>
        /// SelectRelationshipCommand executed;
        /// </summary>
        public void SelectRelationshipCommand_Executed()
        {
            if (this.SelectedItems.Count == 1)
            {
                SerializedDomainClassViewModel classViewModel = this.SelectedItems[0] as SerializedDomainClassViewModel;
                if (classViewModel != null)
                    if (classViewModel.Parent != null)
                    {
                        SelectedItemsCollection col = new SelectedItemsCollection();
                        col.Add(classViewModel.Parent.GetHostedElement());

                        EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
                    }

                SerializedReferenceRelationshipViewModel refRelViewModel = this.SelectedItems[0] as SerializedReferenceRelationshipViewModel;
                if (refRelViewModel != null)
                    if (!refRelViewModel.IsInFullSerialization)
                    {
                        SelectedItemsCollection col = new SelectedItemsCollection();
                        col.Add(refRelViewModel.SerializationElement);
                        EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
                    }
            }
        }
 /// <summary>
 /// Navigate To Element Command executed.
 /// </summary>
 protected virtual void NavigateToElementCommand_Executed()
 {
     BaseModelElementViewModel selectedValue = GetPropertyValue() as BaseModelElementViewModel;
     if (selectedValue != null)
     {
         SelectedItemsCollection col = new SelectedItemsCollection();
         col.Add(selectedValue.Element);
         EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
     }
 }
        /// <summary>
        /// View properties command executed.
        /// </summary>
        private void ViewPropertiesCommand_Executed()
        {
            SelectedItemsCollection col = new SelectedItemsCollection();
            foreach (BaseModelElementViewModel vm in this.SelectedItems)
            {
                col.Add(vm.GetHostedElement());
            }

            EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
        }
        void ObjectModelBrowser_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            SelectedItemsCollection col = new SelectedItemsCollection();
            col.Add(this.SelectedElement);

            if (LanguageDSLDocData.ViewModelStore != null)
                LanguageDSLDocData.ViewModelStore.EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(null, col));
        }
 /// <summary>
 /// Callback from SelectionChangedEvent.
 /// </summary>
 /// <param name="eventArgs">SelectionChangedEventArgs.</param>
 protected virtual void ReactOnViewSelection(SelectionChangedEventArgs eventArgs)
 {
     this.selectedItemsCollection = eventArgs.SelectedItems;
 }
Exemplo n.º 24
0
 /// <summary>
 /// Callback from SelectionChangedEvent.
 /// </summary>
 /// <param name="eventArgs">SelectionChangedEventArgs.</param>
 protected virtual void ReactOnViewSelection(SelectionChangedEventArgs eventArgs)
 {
     this.selectedItemsCollection = eventArgs.SelectedItems;
 }
Exemplo n.º 25
0
        /// <summary>
        /// Invoked when a collection of selected elements on the canvas is changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void SelectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            //return;
            SelectedItemsCollection selection = (SelectedItemsCollection)sender;

            if (currentGrid != null)
            {
                currentGrid.UpdateContent();
                currentGrid = null;
            }

            Clear();

            if (selection.Count == 1)
            {
                ISelectable selectedItem = selection[0];
                string      selectedType = selectedItem.GetType().Name;
                if (selectedType == tPIM_Class)
                {
                    DisplaySelectedPIMClass((XCaseViewBase)selectedItem);
                }
                else if (selectedType == tPSM_Class)
                {
                    DisplaySelectedPSMClass((XCaseViewBase)selectedItem);
                }
                else if (selectedType == tXCaseComment)
                {
                    DisplaySelectedComment((XCaseComment)selectedItem);
                }
                else if (selectedType == tPIM_Association)
                {
                    DisplaySelectedAssociation((PIM_Association)selectedItem);
                }
                else if (selectedType == tAssociationDiamond)
                {
                    if (((AssociationDiamond)selectedItem).Association.AssociationClass != null)
                    {
                        DisplaySelectedAssociationClass(((AssociationDiamond)selectedItem).Association.AssociationClass);
                    }
                    else
                    {
                        DisplaySelectedAssociation(((AssociationDiamond)selectedItem).Association);
                    }
                }
                else if (selectedType == tPIM_AssociationClass)
                {
                    DisplaySelectedAssociationClass((PIM_AssociationClass)selectedItem);
                }
                else if (selectedType == tAssociationLabel)
                {
                    if (((AssociationLabel)selectedItem).Association != null)
                    {
                        if (((AssociationLabel)selectedItem).Association.AssociationClass == null)
                        {
                            DisplaySelectedAssociation(((AssociationLabel)selectedItem).Association);
                        }

                        else
                        {
                            DisplaySelectedAssociationClass(
                                ((AssociationLabel)selectedItem).Association.AssociationClass);
                        }
                    }
                    else if (((AssociationLabel)selectedItem).PSM_Association != null)
                    {
                        DisplaySelectedPSMAssociation(((AssociationLabel)selectedItem).PSM_Association);
                    }
                }
                else if (selectedType == tPSM_ContentContainer)
                {
                    DisplaySelectedPSMContentContainer((PSM_ContentContainer)selectedItem);
                }
                else if (selectedType == tPSM_Association)
                {
                    DisplaySelectedPSMAssociation((PSM_Association)selectedItem);
                }
                else if (selectedType == tPSM_AttributeContainer)
                {
                    DisplayAttributeContainer(((PSM_AttributeContainer)selectedItem));
                }
                else
                {
                }
            }
        }
Exemplo n.º 26
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="sourceViewModel">View model that triggers the event.</param>
 /// <param name="selectedComponents">Selected components in that view model.</param>
 public SelectionChangedEventArgs(BaseViewModel sourceViewModel, SelectedItemsCollection selectedItems)
     : base(sourceViewModel)
 {
     this.selectedItems = selectedItems;
     this.userData      = null;
 }
 /// <summary>
 /// Navigate To Element Command executed.
 /// </summary>
 protected virtual void NavigateToElementCommand_Executed()
 {
     if (SelectedObject != null)
     {
         ModelElement selectedValue = SelectedObject.Element;
         if (selectedValue != null)
         {
             SelectedItemsCollection col = new SelectedItemsCollection();
             col.Add(selectedValue);
             EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));
         }
     }
 }
        /// <summary>
        /// Callback from SelectionChangedEvent.
        /// </summary>
        /// <param name="eventArgs">SelectionChangedEventArgs.</param>
        protected override void ReactOnViewSelection(SelectionChangedEventArgs eventArgs)
        {
            if (eventArgs.SourceViewModel != this)
            {
                this.selectedItemsCollection = eventArgs.SelectedItems;

                Tum.PDE.ToolFramework.Modeling.Visualization.ViewModel.Threading.DispatcherExtensions.InvokeAsynchronouslyInBackground(
                    System.Windows.Threading.Dispatcher.CurrentDispatcher, new Action(UpdateSelectedElement));
            }
        }
Exemplo n.º 29
0
 /// <summary>
 /// Returns a collection of property view models for the given selected elements.
 /// </summary>
 /// <param name="elements">Selected elements collection.</param>
 /// <returns>Collection of property view models. Can be empty.</returns>
 public abstract List <PropertyGridViewModel> CreatePropertyEditorViewModels(SelectedItemsCollection elements);
 /// <summary>
 /// Returns a collection of property view models for the given selected elements.
 /// </summary>
 /// <param name="elements">Selected elements collection.</param>
 /// <returns>Collection of property view models. Can be empty.</returns>
 public abstract List<PropertyGridViewModel> CreatePropertyEditorViewModels(SelectedItemsCollection elements);
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="sourceViewModel">View model that triggers the event.</param>
 /// <param name="selectedItems">Selected components in that view model.</param>
 public SelectionChangedEventArgs(BaseViewModel sourceViewModel, SelectedItemsCollection selectedItems)
     : base(sourceViewModel)
 {
     this.selectedItems = selectedItems;
     this.userData = null;
 }
        /// <summary>
        /// Execute the Html navigation command.
        /// </summary>
        public void NavigateToHtmlHyperlink(HtmlHyperlink hyperlink)
        {
            if (hyperlink.TargetName.Length == 0)
                return;

            bool bFoundTarget = false;
            if (hyperlink.TargetName[0] == '#')
            {
                string href = hyperlink.TargetName.Substring(1, hyperlink.TargetName.Length - 1);
                if (KeyGenerator.Instance.CanConvertVModellIDToGuid(href))
                {
                    Guid id = KeyGenerator.Instance.ConvertVModellIDToGuid(href);
                    ModelElement modelElement = this.Store.ElementDirectory.FindElement(id);
                    if (modelElement != null)
                    {
                        bFoundTarget = true;

                        SelectedItemsCollection col = new SelectedItemsCollection();
                        col.Add(modelElement);
                        EventManager.GetEvent<SelectionChangedEvent>().Publish(new SelectionChangedEventArgs(this, col));

                    }
                }
            }

            if (!bFoundTarget)
                System.Windows.MessageBox.Show(hyperlink.TargetName);
        }