예제 #1
0
        public void Execute()
        {
            if (this.ServiceProvider != null)
            {
                ITeamExplorer service = this.ServiceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
                if (this.ContextManager == null)
                {
                    this.ContextManager = (ITeamFoundationContextManager)this.ServiceProvider.GetService(typeof(ITeamFoundationContextManager));
                }
                if (this.ContextManager != null)
                {
                    this.ContextManager.ContextChanged += new EventHandler <ContextChangedEventArgs>(this.ContextManager_ContextChanged);
                }
                if (service != null)
                {
                    if (NavigationItemCandidates != null)
                    {
                        string text = string.Empty;

                        foreach (var navigationItemCandidates in NavigationItemCandidates)
                        {
                            if (!navigationItemCandidates.IsValueCreated)
                            {
                                continue;
                            }

                            text += navigationItemCandidates.Value.Text + Environment.NewLine;
                        }

                        service.ShowNotification(text, NotificationType.Information, NotificationFlags.None, null, Guid.NewGuid());
                    }
                    else
                    {
                        service.ShowNotification("This is a simple notification", NotificationType.Information, NotificationFlags.None, null, new Guid());
                    }

                    //ITeamExplorer explorer = ServiceProvider.GetService(typeof(ITeamExplorer)) as ITeamExplorer;
                    //if (explorer != null)
                    //{
                    //    var page = explorer.CurrentPage;
                    //    string info = page.GetId().ToString() + Environment.NewLine;
                    //    var sections = page.GetSections();
                    //    foreach (var section in sections)
                    //        info += section.Title + " " + section.GetId() + Environment.NewLine;
                    //    MessageBox.Show(info);
                    //}
                }
            }
        }
        private void ShowNotification(string message, NotificationType type)
        {
            ITeamExplorer teamExplorer = GetService <ITeamExplorer>();

            if (teamExplorer != null)
            {
                Guid guid = Guid.NewGuid();
                teamExplorer.ShowNotification(message, type, NotificationFlags.None, null, guid);
            }
        }
 public void CreateStash()
 {
     if (_gitCommandExecuter.TryCreateStash(_message, out var errorMessage))
     {
         _teamExplorer.CurrentPage.RefreshPageAndSections();
     }
     else
     {
         _teamExplorer?.ShowNotification(errorMessage, NotificationType.Error, NotificationFlags.None, null, Guid.NewGuid());
     }
 }
예제 #4
0
        protected Guid ShowNotification(string message, NotificationType type)
        {
            if (itfs != null)
            {
                Guid guid = Guid.NewGuid();
                itfs.ShowNotification(message, type, NotificationFlags.All, null, guid);

                return(guid);
            }

            return(Guid.Empty);
        }
        public Guid ShowNotification(string message, NotificationType type)
        {
            ITeamExplorer teamExplorer = this.GetService <ITeamExplorer>();

            if (teamExplorer != null)
            {
                Guid guid = Guid.NewGuid();
                teamExplorer.ShowNotification(message, type, NotificationFlags.None, null, guid);
                return(guid);
            }

            return(Guid.Empty);
        }
        public void CreateStash()
        {
            var result = _dte.ItemOperations.PromptToSave;

            if (_gitCommandExecuter.TryCreateStash(_message, _includeUntrackedFiles, out var errorMessage))
            {
                _teamExplorer.CurrentPage.RefreshPageAndSections();
                Message = string.Empty;
                IncludeUntrackedFiles = false;
            }
            else
            {
                _teamExplorer?.ShowNotification(errorMessage, NotificationType.Error, NotificationFlags.None, null, Guid.NewGuid());
            }
        }
예제 #7
0
        /// <summary>
        /// Handler which attempts to sign in to a SonarQube server.
        /// </summary>
        private async Task OnSignInAsync(object parameter)
        {
            var connectionInfo = ConnectionInformationDialog.ShowDialog(_lastAttemptedSignIn);

            if (connectionInfo is null)
            {
                return;
            }

            _lastAttemptedSignIn = connectionInfo;
            ISonarQubeClient client = null;

            IsSignedIn  = false;
            IsSigningIn = true;

            try
            {
                client = await _clientManager.LogInAsync(new Uri(connectionInfo.ServerUrl), connectionInfo.Login, connectionInfo.Password);

                IsSignedIn = (null != client);
            }
            catch
            {
                IsSignedIn = false;
            }

            IsSigningIn = false;

            if (IsSignedIn)
            {
                _teamExplorer.HideNotification(ConnectionNotificationId);
                NavigateToProjectPage(client);
            }
            else
            {
                _teamExplorer.ShowNotification($"Could not connect to \"{connectionInfo.ServerUrl}\".",
                                               NotificationType.Error, NotificationFlags.None, null, ConnectionNotificationId);
            }
        }
        /// <summary>
        /// Tries to create stash staged (if operatiopn wasn't successful - shows Team Explorer notification).
        /// </summary>
        /// <param name="message">message that should be assigned to the Stash.</param>
        /// <returns>True if operation was successful, otherwise - false.</returns>
        public bool TryCreateStashStaged(string message)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            IVsThreadedWaitDialog2 dialog = null;

            if (_dialogFactory != null)
            {
                _dialogFactory.CreateInstance(out dialog);
            }

            // Step 1. git stash keep staged.
            if (dialog != null)
            {
                dialog.StartWaitDialogWithPercentageProgress("Stash staged", "Step 1: git stash --keep-index", "Waiting...", null, "Waiting", false, 0, 4, 1);
            }

            if (!_gitCommandExecuter.TryCreateStashKeepIndex(out var errorMessage))
            {
                dialog?.EndWaitDialog(out _);
                _teamExplorer.ShowNotification(errorMessage, NotificationType.Error, NotificationFlags.None, null, Guid.NewGuid());
                return(false);
            }

            // Step 2. git stash
            if (dialog != null)
            {
                dialog.UpdateProgress($"Step 2: git stash save '{message}'", "Waiting...", "Waiting", 2, 4, true, out _);
            }

            if (!_gitCommandExecuter.TryCreateStash(message, true, out errorMessage))
            {
                dialog?.EndWaitDialog(out _);
                _teamExplorer.ShowNotification(errorMessage, NotificationType.Error, NotificationFlags.None, null, Guid.NewGuid());
                return(false);
            }

            // Step 3. git stash apply
            if (dialog != null)
            {
                dialog.UpdateProgress("Step 3: git stash apply stash@{1}", "Waiting...", "Waiting", 3, 4, true, out _);
            }

            if (!_gitCommandExecuter.TryApplyStash(1, out errorMessage))
            {
                dialog?.EndWaitDialog(out _);
                _teamExplorer.ShowNotification(errorMessage, NotificationType.Error, NotificationFlags.None, null, Guid.NewGuid());
                return(false);
            }

            // Step 4. git stash drop
            if (dialog != null)
            {
                dialog.UpdateProgress("Step 4: git stash drop stash@{1}", "Waiting...", "Waiting", 4, 4, true, out _);
            }

            if (!_gitCommandExecuter.TryDeleteStash(1, out errorMessage))
            {
                dialog?.EndWaitDialog(out _);
                _teamExplorer.ShowNotification(errorMessage, NotificationType.Error, NotificationFlags.None, null, Guid.NewGuid());
                return(false);
            }

            dialog?.EndWaitDialog(out _);
            return(true);
        }
        /// <summary>
        /// Tries to create stash (if operatiopn wasn't successful - shows Team Explorer notification).
        /// </summary>
        /// <param name="message">message that should be assigned to the Stash.</param>
        /// <param name="includeUntrackedFiles">Flag indicates that untracked files should be included.</param>
        /// <returns>True if operation was successful, otherwise - false.</returns>
        public bool TryCreateStash(string message, bool includeUntrackedFiles)
        {
            Microsoft.VisualStudio.Shell.ThreadHelper.ThrowIfNotOnUIThread();

            var result = _dte.ItemOperations.PromptToSave;

            if (_gitCommandExecuter.TryCreateStash(message, includeUntrackedFiles, out var errorMessage))
            {
                _teamExplorer.CurrentPage.RefreshPageAndSections();
                return(true);
            }
            else
            {
                _teamExplorer?.ShowNotification(errorMessage, NotificationType.Error, NotificationFlags.None, null, Guid.NewGuid());
                return(false);
            }
        }