1 package ch
.cyberduck
.ui
.cocoa
.threading
;
4 * Copyright (c) 2002-2013 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * feedback@cyberduck.ch
21 import ch
.cyberduck
.binding
.application
.NSAlert
;
22 import ch
.cyberduck
.binding
.application
.NSCell
;
23 import ch
.cyberduck
.binding
.application
.SheetCallback
;
24 import ch
.cyberduck
.core
.LocaleFactory
;
25 import ch
.cyberduck
.core
.exception
.BackgroundException
;
26 import ch
.cyberduck
.core
.transfer
.TransferErrorCallback
;
27 import ch
.cyberduck
.ui
.cocoa
.AlertController
;
28 import ch
.cyberduck
.ui
.cocoa
.WindowController
;
30 import java
.util
.concurrent
.atomic
.AtomicBoolean
;
35 public class AlertTransferErrorCallback
implements TransferErrorCallback
{
37 private final WindowController controller
;
39 private boolean suppressed
;
41 private boolean option
;
43 public AlertTransferErrorCallback(final WindowController controller
) {
44 this.controller
= controller
;
48 public boolean prompt(final BackgroundException failure
) {
52 if(controller
.isVisible()) {
53 final AtomicBoolean c
= new AtomicBoolean(true);
54 final NSAlert alert
= NSAlert
.alert(
55 null == failure
.getMessage() ? LocaleFactory
.localizedString("Unknown") : failure
.getMessage(),
56 null == failure
.getDetail() ? LocaleFactory
.localizedString("Unknown") : failure
.getDetail(),
57 LocaleFactory
.localizedString("Cancel"), // default button
59 LocaleFactory
.localizedString("Continue", "Credentials") // alternate button
61 alert
.setShowsSuppressionButton(true);
62 alert
.suppressionButton().setTitle(LocaleFactory
.localizedString("Always"));
63 final AlertController controller
= new AlertController(AlertTransferErrorCallback
.this.controller
, alert
) {
65 public void callback(final int returncode
) {
66 if(returncode
== SheetCallback
.DEFAULT_OPTION
) {
69 if(alert
.suppressionButton().state() == NSCell
.NSOnState
) {
75 controller
.beginSheet();