コード例 #1
0
        private void Open(PopupViewType popupViewType, Action <bool> onClose)
        {
            OnClose.SafeInvoke(false);
            OnClose = null;

            var viewNeedsAuthentication = popupViewType == PopupViewType.PublishView;

            if (viewNeedsAuthentication)
            {
                Client.GetCurrentUser(user =>
                {
                    OpenInternal(popupViewType, onClose);
                    shouldCloseOnFinish = true;
                },
                                      exception =>
                {
                    authenticationView.Initialize(exception);
                    OpenInternal(PopupViewType.AuthenticationView, completedAuthentication =>
                    {
                        if (completedAuthentication)
                        {
                            Open(popupViewType, onClose);
                        }
                    });
                    shouldCloseOnFinish = false;
                });
            }
            else
            {
                OpenInternal(popupViewType, onClose);
                shouldCloseOnFinish = true;
            }
        }
コード例 #2
0
        public static PopupWindow OpenWindow(PopupViewType popupViewType, Action <bool> onClose = null)
        {
            var popupWindow = GetWindow <PopupWindow>(true);

            popupWindow.Open(popupViewType, onClose);

            return(popupWindow);
        }
コード例 #3
0
        private void Open(PopupViewType popupViewType, Action <bool> onClose)
        {
            OnClose.SafeInvoke(false);
            OnClose = null;

            var viewNeedsAuthentication = popupViewType == PopupViewType.PublishView;

            if (viewNeedsAuthentication)
            {
                var userHasAuthentication = false;
                foreach (var keychainConnection in Platform.Keychain.Connections.OrderByDescending(HostAddress.IsGitHubDotCom))
                {
                    var apiClient = new ApiClient(Platform.Keychain, Platform.ProcessManager, TaskManager,
                                                  Environment, keychainConnection.Host);

                    try
                    {
                        apiClient.EnsureValidCredentials();
                        userHasAuthentication = true;
                        break;
                    }
                    catch (Exception ex)
                    {
                        Logger.Trace(ex, "Exception validating host {0}", keychainConnection.Host);
                    }
                }

                if (userHasAuthentication)
                {
                    OpenInternal(popupViewType, onClose);
                    shouldCloseOnFinish = true;
                }
                else
                {
                    authenticationView.Initialize(null);
                    OpenInternal(PopupViewType.AuthenticationView, completedAuthentication =>
                    {
                        if (completedAuthentication)
                        {
                            Open(popupViewType, onClose);
                        }
                    });

                    shouldCloseOnFinish = false;
                }
            }
            else
            {
                OpenInternal(popupViewType, onClose);
                shouldCloseOnFinish = true;
            }
        }
コード例 #4
0
        private void OpenInternal(PopupViewType popupViewType, Action <bool> onClose)
        {
            if (onClose != null)
            {
                OnClose += onClose;
            }

            var fromView = ActiveView;

            ActiveViewType = popupViewType;
            SwitchView(fromView, ActiveView);
            Show();
        }
コード例 #5
0
        public static PopupWindow Open(PopupViewType popupViewType, Action <bool> onClose = null)
        {
            var popupWindow = GetWindow <PopupWindow>(true);

            popupWindow.OnClose.SafeInvoke(false);

            if (onClose != null)
            {
                popupWindow.OnClose += onClose;
            }

            popupWindow.ActiveViewType = popupViewType;
            popupWindow.titleContent   = new GUIContent(popupWindow.ActiveView.Title, Styles.SmallLogo);
            popupWindow.OnEnable();
            popupWindow.Show();
            popupWindow.Refresh();

            return(popupWindow);
        }
コード例 #6
0
        public static PopupWindow Open(PopupViewType popupViewType, Action <bool> onClose = null)
        {
            var popupWindow = GetWindow <PopupWindow>(true);

            popupWindow.OnClose.SafeInvoke(false);

            if (onClose != null)
            {
                popupWindow.OnClose += onClose;
            }

            popupWindow.ActiveViewType = popupViewType;
            popupWindow.titleContent   = new GUIContent(popupWindow.ActiveView.Title, Styles.SmallLogo);

            popupWindow.InitializeWindow(EntryPoint.ApplicationManager);
            popupWindow.Show();

            return(popupWindow);
        }
コード例 #7
0
        private void Open(PopupViewType popupViewType, Action <bool> onClose)
        {
            OnClose.SafeInvoke(false);
            OnClose = null;

            //Logger.Trace("OpenView: {0}", popupViewType.ToString());

            var viewNeedsAuthentication = popupViewType == PopupViewType.PublishView;

            if (viewNeedsAuthentication)
            {
                //Logger.Trace("Validating to open view");

                Client.ValidateCurrentUser(() => {
                    //Logger.Trace("User validated opening view");

                    OpenInternal(popupViewType, onClose);
                    shouldCloseOnFinish = true;
                }, exception => {
                    //Logger.Trace("User required validation opening AuthenticationView");
                    authenticationView.Initialize(exception);
                    OpenInternal(PopupViewType.AuthenticationView, completedAuthentication => {
                        if (completedAuthentication)
                        {
                            //Logger.Trace("User completed validation opening view: {0}", popupViewType.ToString());

                            Open(popupViewType, onClose);
                        }
                    });

                    shouldCloseOnFinish = false;
                });
            }
            else
            {
                OpenInternal(popupViewType, onClose);
                shouldCloseOnFinish = true;
            }
        }