Example #1
0
        public static void HandleDoubleClickOnItem(BaseEntity entity, Action <object> copyCommitMessageDelegate = null)
        {
            try
            {
                if (entity == null)
                {
                    return;
                }

                if (Keyboard.IsKeyDown(Key.LeftAlt) || Keyboard.IsKeyDown(Key.RightAlt))
                {
                    if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                    {
                        copyCommitMessageDelegate?.Invoke(null);
                    }
                    else
                    {
                        OpenInBrowser(entity);
                    }
                }
                else if (entity.TypeName.Equals(Task.TYPE_TASK) && (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift)))
                {
                    ViewDetails(((Task)entity).Story);
                }
                else
                {
                    if (DetailsToolWindow.IsEntityTypeSupported(Utility.GetConcreteEntityType(entity)))
                    {
                        ViewDetails(entity);
                    }
                    else
                    {
                        OpenInBrowser(entity);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to process double click operation.\n\n" + "Failed with message: " + ex.Message, ToolWindowHelper.AppName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #2
0
        /// <summary>
        /// Unregister the given details window from the window manager
        /// </summary>
        internal static void UnregisterDetailsWindow(DetailsToolWindow detailWindow)
        {
            var windowControl = detailWindow.Content as OctaneToolWindowControl;

            if (windowControl == null)
            {
                return;
            }

            var viewModel = windowControl.DataContext as DetailedItemViewModel;

            if (viewModel == null)
            {
                return;
            }

            var uniqueId = GetUniqueIdentifier(viewModel.Entity);

            lock (Lock)
            {
                OpenedDetailWindows.Remove(uniqueId);
            }
        }
Example #3
0
        /// <summary>
        /// Construct the context menu for the given selected item
        /// </summary>
        internal static void ConstructContextMenu(ContextMenu cm, BaseItemViewModel selectedItem,
                                                  Action <object> viewDetailsDelegate,
                                                  Action <object> viewTaskParentDetailsDelegate,
                                                  Action <object> viewCommentParentDetailsDelegate,
                                                  Action <object> openInBrowserDelegate,
                                                  Action <object> copyCommitMessageDelegate,
                                                  Action <object> downloadScriptDelegate,
                                                  Action <object> startWorkDelegate,
                                                  Action <object> stopWorkDelegate,
                                                  Action <object> addToMyWorkDelegate,
                                                  Action <object> removeFromMyWorkDelegate)
        {
            try
            {
                if (cm == null)
                {
                    return;
                }

                cm.Items.Clear();

                if (selectedItem == null)
                {
                    return;
                }

                var selectedEntity = selectedItem.Entity;

                var entityType = Utility.GetConcreteEntityType(selectedEntity);

                // view details
                if (viewDetailsDelegate != null &&
                    DetailsToolWindow.IsEntityTypeSupported(entityType))
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = ViewDetailsHeader,
                        Command = new DelegatedCommand(viewDetailsDelegate)
                    });
                }

                // view task parent details
                var taskParentEntity = Utility.GetTaskParentEntity(selectedEntity);
                if (viewTaskParentDetailsDelegate != null &&
                    selectedEntity.TypeName == Task.TYPE_TASK &&
                    taskParentEntity != null &&
                    DetailsToolWindow.IsEntityTypeSupported(entityType))
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = ViewTaskParentDetailsHeader,
                        Command = new DelegatedCommand(viewTaskParentDetailsDelegate)
                    });
                }

                // view comment parent details
                var commentParentEntity = GetCommentParentEntity(selectedItem);
                if (viewCommentParentDetailsDelegate != null &&
                    commentParentEntity != null &&
                    DetailsToolWindow.IsEntityTypeSupported(Utility.GetConcreteEntityType(commentParentEntity)))
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = ViewCommentParentDetailsHeader,
                        Command = new DelegatedCommand(viewCommentParentDetailsDelegate)
                    });
                }

                // open in browser
                if (openInBrowserDelegate != null)
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = OpenInBrowserHeader,
                        Command = new DelegatedCommand(openInBrowserDelegate)
                    });
                }

                var octaneItem = selectedItem as OctaneItemViewModel;

                // download gherkin script
                if (downloadScriptDelegate != null &&
                    (entityType == TestGherkin.SUBTYPE_GHERKIN_TEST || entityType == TestBDDScenario.SUBTYPE_BDD_SCENARIO_TEST))
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = DownloadScriptHeader,
                        Command = new DelegatedCommand(downloadScriptDelegate)
                    });
                }

                // start work
                if (startWorkDelegate != null &&
                    octaneItem != null &&
                    !octaneItem.IsActiveWorkItem &&
                    (entityType == WorkItem.SUBTYPE_STORY ||
                     entityType == WorkItem.SUBTYPE_QUALITY_STORY ||
                     entityType == WorkItem.SUBTYPE_DEFECT ||
                     entityType == Task.TYPE_TASK))
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = StartWorkHeader,
                        Command = new DelegatedCommand(startWorkDelegate)
                    });
                }

                // stop work
                if (stopWorkDelegate != null &&
                    octaneItem != null &&
                    octaneItem.IsActiveWorkItem &&
                    (entityType == WorkItem.SUBTYPE_STORY ||
                     entityType == WorkItem.SUBTYPE_QUALITY_STORY ||
                     entityType == WorkItem.SUBTYPE_DEFECT ||
                     entityType == Task.TYPE_TASK))
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = StopWorkHeader,
                        Command = new DelegatedCommand(stopWorkDelegate)
                    });
                }

                // copy commit message
                if (octaneItem != null &&
                    octaneItem.IsSupportCopyCommitMessage &&
                    (entityType == WorkItem.SUBTYPE_STORY ||
                     entityType == WorkItem.SUBTYPE_QUALITY_STORY ||
                     entityType == WorkItem.SUBTYPE_DEFECT ||
                     entityType == Task.TYPE_TASK))
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = CopyCommitMessageHeader,
                        Command = new DelegatedCommand(copyCommitMessageDelegate)
                    });
                }


                // add to my work
                if (addToMyWorkDelegate != null &&
                    (DetailsToolWindow.IsEntityTypeSupported(entityType) ||
                     entityType == TestBDDScenario.SUBTYPE_BDD_SCENARIO_TEST))
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = AddToMyWorkHeader,
                        Command = new DelegatedCommand(addToMyWorkDelegate)
                    });
                }

                // remove from my work
                if (removeFromMyWorkDelegate != null)
                {
                    cm.Items.Add(new MenuItem
                    {
                        Header  = RemoveFromMyWorkHeader,
                        Command = new DelegatedCommand(removeFromMyWorkDelegate)
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to show context menu.\n\n" + "Failed with message: " + ex.Message, AppName, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }