Ejemplo n.º 1
0
        private void OnViewSelectionChanged(object sender, EventArgs e)
        {
            LoadWorkItems();
            ViewSelectionViewModel.ShowViewOptions = false;
            var defaultProfile = Repository.Instance.ProfileProvider.GetDefaultProfile();

            try
            {
                DetachFromProfileProvider();
                if (ViewSelectionViewModel.IsMergeCandidatesSelected())
                {
                    var result = ViewSelectionViewModel.GetMergeSourceTargetBranches();
                    defaultProfile.WIQueryName        = null;
                    defaultProfile.WISourceBranch     = result.SourceBranch.Name;
                    defaultProfile.WITargetBranch     = result.TargetBranch.Name;
                    defaultProfile.WISourcePathFilter = result.PathFilter;
                }
                else if (ViewSelectionViewModel.IsQuerySelected())
                {
                    var query = ViewSelectionViewModel.GetSelectedQuery();
                    defaultProfile.WISourceBranch     = null;
                    defaultProfile.WITargetBranch     = null;
                    defaultProfile.WISourcePathFilter = null;
                    defaultProfile.WIQueryName        = query.QualifiedTitle;
                }
            }
            finally
            {
                AttachToProfileProvider();
            }
        }
Ejemplo n.º 2
0
        void Merge(object o)
        {
            try
            {
                var candidates = FilteredChangesets.Where(cs => cs.IsSelected).Select(cs => cs.TfsChangeset);

                if (!candidates.Any())
                {
                    var mbvm = new MessageBoxViewModel("Perform merge", "No changesets are currently selected.", MessageBoxViewModel.MessageBoxButtons.OK);
                    Repository.Instance.ViewManager.ShowModal(mbvm);
                }
                else
                {
                    var mergeViewModel = new PrepareMergeViewModel(TfsItemCache, candidates);
                    var result         = ViewSelectionViewModel.GetMergeSourceTargetBranches();
                    mergeViewModel.MergeSource = result != null ? result.SourceBranch : null;
                    mergeViewModel.MergeTarget = result != null ? result.TargetBranch : null;
                    mergeViewModel.PathFilter  = result != null ? result.PathFilter : null;
                    mergeViewModel.SetDefaults();

                    if (Repository.Instance.Settings.FetchSettings <bool>(Constants.Settings.PerformNonModalMergeKey))
                    {
                        vMergePackage.OpenMergeView(mergeViewModel);
                    }
                    else
                    {
                        Repository.Instance.ViewManager.ShowModal(mergeViewModel, "Modal");
                    }
                }
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex, true);
            }
        }
Ejemplo n.º 3
0
        void Merge(object o)
        {
            try
            {
                var candidates = WorkItems.Where(wi => wi.IsSelected).Select(wi => wi.TfsWorkItem);

                if (!candidates.Any())
                {
                    var mbvm = new MessageBoxViewModel("Perform merge", "No work items are currently selected.", MessageBoxViewModel.MessageBoxButtons.OK);
                    Repository.Instance.ViewManager.ShowModal(mbvm);
                }
                else if (!candidates.Any(candidate => candidate.RelatedChangesetCount > 0))
                {
                    var mbvm = new MessageBoxViewModel("Perform merge", "The selected work items don't have any linked changesets.", MessageBoxViewModel.MessageBoxButtons.OK);
                    Repository.Instance.ViewManager.ShowModal(mbvm);
                }
                else
                {
                    PrepareMergeViewModel mergeViewModel;
                    try
                    {
                        mergeViewModel = new PrepareMergeViewModel(TfsItemCache, WorkItems.Where(wi => wi.IsSelected).Select(wi => wi.TfsWorkItem));
                    }
                    catch (ArgumentException)
                    {
                        var mbvm = new MessageBoxViewModel(
                            "Perform merge",
                            String.Format("The selected work items don't have any linked changesets in the current team project\r\n({0}).", Repository.Instance.TfsBridgeProvider.ActiveTeamProject.Name),
                            MessageBoxViewModel.MessageBoxButtons.OK);
                        Repository.Instance.ViewManager.ShowModal(mbvm);
                        mergeViewModel = null;
                    }

                    if (mergeViewModel != null)
                    {
                        var result = ViewSelectionViewModel.GetMergeSourceTargetBranches();
                        mergeViewModel.MergeSource = result != null ? result.SourceBranch : null;
                        mergeViewModel.MergeTarget = result != null ? result.TargetBranch : null;
                        mergeViewModel.PathFilter  = result != null ? result.PathFilter : null;
                        mergeViewModel.SetDefaults();
                        if (Repository.Instance.Settings.FetchSettings <bool>(Constants.Settings.PerformNonModalMergeKey))
                        {
                            vMergePackage.OpenMergeView(mergeViewModel);
                        }
                        else
                        {
                            Repository.Instance.ViewManager.ShowModal(mergeViewModel, "Modal");
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 4
0
        private void LoadWorkItems()
        {
            if (Repository.Instance.TfsConnectionInfo.Uri == null)
            {
                ResetWorkItems();
                return;
            }

            if (ViewSelectionViewModel.IsMergeCandidatesSelected())
            {
                var result = ViewSelectionViewModel.GetMergeSourceTargetBranches();
                ResetWorkItems();

                Repository.Instance.BackgroundTaskManager.Start(
                    Constants.Tasks.LoadWorkItemsTaskKey,
                    ItemsLoading,
                    (task) =>
                {
                    LoadWorkItems(result.SourceBranch, result.TargetBranch, result.PathFilter, task);
                });
            }
            else if (ViewSelectionViewModel.IsQuerySelected())
            {
                var query = ViewSelectionViewModel.GetSelectedQuery();
                ResetWorkItems();

                Repository.Instance.BackgroundTaskManager.Start(
                    Constants.Tasks.LoadWorkItemsTaskKey,
                    ItemsLoading,
                    (task) =>
                {
                    LoadWorkItems(query, task);
                });
            }
            else
            {
                ItemsLoading.IsLoading = false;
            }
        }