Ejemplo n.º 1
0
        public ErrorController(IErrorView view, IEnumerable <BackgroundException> exceptions, string transcript)
        {
            View = view;

            View.SetModel(exceptions);
            View.ModelErrorMessageGetter =
                delegate(object rowObject)
            {
                BackgroundException failure = (BackgroundException)rowObject;
                return(GetReadableTitle(failure) + ": " + failure.getMessage());
            };

            View.ModelHostGetter = delegate(object rowObject)
            {
                BackgroundException failure = (BackgroundException)rowObject;
                if (null == failure.getPath())
                {
                    return(failure.getSession().getHost().toURL());
                }
                return(failure.getPath().getAbsolute());
            };
            View.ModelDescriptionGetter =
                delegate(object rowObject) { return(GetDetailedCauseMessage((BackgroundException)rowObject)); };

            bool log = !string.IsNullOrEmpty(transcript);

            View.Transcript        = transcript;
            View.TranscriptVisible = log &&
                                     Preferences.instance().getBoolean("alert.toggle.transcript");
            View.TranscriptEnabled      = log;
            View.ToggleTranscriptEvent += View_ToggleTranscriptEvent;
        }
 public bool prompt(BackgroundException failure)
 {
     if (_supressed)
     {
         return(_option);
     }
     if (_controller.Visible)
     {
         AtomicBoolean c = new AtomicBoolean(true);
         _controller.Invoke(delegate
         {
             TaskDialogResult result = _controller.View.CommandBox(LocaleFactory.localizedString("Error"),
                                                                   failure.getMessage() ?? LocaleFactory.localizedString("Unknown"),
                                                                   failure.getDetail() ?? LocaleFactory.localizedString("Unknown"), null, null,
                                                                   LocaleFactory.localizedString("Always"),
                                                                   LocaleFactory.localizedString("Continue", "Credentials"), true, TaskDialogIcon.Warning,
                                                                   TaskDialogIcon.Information, delegate(int opt, bool verificationChecked)
             {
                 if (verificationChecked)
                 {
                     _supressed = true;
                     _option    = c.Value;
                 }
             });
             if (result.Result == TaskDialogSimpleResult.Cancel)
             {
                 c.SetValue(false);
             }
         }, true);
         return(c.Value);
     }
     // Abort
     return(false);
 }
Ejemplo n.º 3
0
        public bool alert(Host host, BackgroundException failure, StringBuilder log)
        {
            FailureDiagnostics.Type type = _diagnostics.determine(failure);
            if (type == FailureDiagnostics.Type.cancel)
            {
                return(false);
            }
            _notification.alert(host, failure, log);
            bool r = false;

            _controller.Invoke(delegate
            {
                string footer   = ProviderHelpServiceFactory.get().help(host.getProtocol());
                string title    = LocaleFactory.localizedString("Error");
                string message  = failure.getMessage() ?? LocaleFactory.localizedString("Unknown");
                string detail   = failure.getDetail() ?? LocaleFactory.localizedString("Unknown");
                string expanded = log.length() > 0 ? log.toString() : null;
                string commandButtons;
                if (type == FailureDiagnostics.Type.network)
                {
                    commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Try Again", "Alert"),
                                                   LocaleFactory.localizedString("Network Diagnostics", "Alert"));
                }
                else if (type == FailureDiagnostics.Type.quota)
                {
                    commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Try Again", "Alert"),
                                                   LocaleFactory.localizedString("Help", "Main"));
                }
                else
                {
                    commandButtons = String.Format("{0}", LocaleFactory.localizedString("Try Again", "Alert"));
                }
                _controller.WarningBox(title, message, detail, expanded, commandButtons, true, footer,
                                       delegate(int option, bool @checked)
                {
                    switch (option)
                    {
                    case 0:
                        r = true;
                        break;

                    case 1:
                        if (type == FailureDiagnostics.Type.network)
                        {
                            ReachabilityFactory.get().diagnose(host);
                        }
                        if (type == FailureDiagnostics.Type.quota)
                        {
                            BrowserLauncherFactory.get().open(new DefaultProviderHelpService().help(host.getProtocol()));
                        }
                        r = false;
                        break;
                    }
                });
            }, true);
            return(r);
        }
 private void HandleException(Exception ex)
 {
     try
     {
         BackgroundException?.Invoke(this, new UnhandledExceptionEventArgs(ex, false));
     }
     catch
     {
         // double-fault, no-op
     }
 }
Ejemplo n.º 5
0
        public bool alert(Host host, BackgroundException failure, StringBuilder log)
        {
            _notification.alert(host, failure, log);
            bool r = false;

            _controller.Invoke(delegate
            {
                String provider = host.getProtocol().getProvider();
                string footer   = String.Format("{0}/{1}", PreferencesFactory.get().getProperty("website.help"),
                                                provider);
                string title    = LocaleFactory.localizedString("Error");
                string message  = failure.getMessage() ?? LocaleFactory.localizedString("Unknown");
                string detail   = failure.getDetail() ?? LocaleFactory.localizedString("Unknown");
                string expanded = log.length() > 0 ? log.toString() : null;
                string commandButtons;
                if (_diagnostics.determine(failure) == FailureDiagnostics.Type.network)
                {
                    commandButtons = String.Format("{0}|{1}", LocaleFactory.localizedString("Try Again", "Alert"),
                                                   LocaleFactory.localizedString("Network Diagnostics", "Alert"));
                }
                else
                {
                    commandButtons = String.Format("{0}", LocaleFactory.localizedString("Try Again", "Alert"));
                }
                _controller.WarningBox(title, message, detail, expanded, commandButtons, true, footer,
                                       delegate(int option, bool @checked)
                {
                    switch (option)
                    {
                    case 0:
                        r = true;
                        break;

                    case 1:
                        ReachabilityFactory.get().diagnose(host);
                        r = false;
                        break;
                    }
                });
            }, true);
            return(r);
        }
 /// <summary>
 /// Display an alert dialog with a summary of all failed tasks
 /// </summary>
 protected void Alert()
 {
     _controller.Invoke(delegate
     {
         if (this.getExceptions().size() == 1)
         {
             BackgroundException failure =
                 this.getExceptions().get(0) as BackgroundException;
             string footer = Preferences.instance().getProperty("website.help");
             if (null != failure.getPath())
             {
                 footer = Preferences.instance().getProperty("website.help") + "/" +
                          failure.getPath().getSession().getHost().getProtocol().
                          getIdentifier();
             }
             DialogResult result =
                 _controller.WarningBox(failure.getReadableTitle(),
                                        failure.getMessage(),
                                        failure.getDetailedCauseMessage(),
                                        hasTranscript() ? this.getTranscript() : null,
                                        String.Format("{0}", Locale.localizedString("Try Again", "Alert")),
                                        true, footer);
             Callback(result);
         }
         else
         {
             ICollection <BackgroundException> backgroundExceptions =
                 Utils.ConvertFromJavaList <BackgroundException>(getExceptions());
             ErrorController errorController =
                 new ErrorController(ObjectFactory.GetInstance <IErrorView>(),
                                     backgroundExceptions, getTranscript());
             DialogResult result = errorController.View.ShowDialog(_controller.View);
             Callback(result);
         }
     }, true);
 }
 public bool alert(Host host, BackgroundException be, StringBuilder sb)
 {
     return(false);
 }
Ejemplo n.º 8
0
 public override bool alert(BackgroundException failure)
 {
     return(false);
 }
Ejemplo n.º 9
0
 public bool alert(Host host, BackgroundException failure)
 {
     return(alert(host, failure, new StringBuilder()));
 }
Ejemplo n.º 10
0
 private string GetDetailedCauseMessage(BackgroundException e)
 {
     return(e.getDetailedCauseMessage());
 }
Ejemplo n.º 11
0
 private string GetReadableTitle(BackgroundException e)
 {
     return(e.getReadableTitle());
 }