1 package ch
.cyberduck
.ui
.cocoa
;
4 * Copyright (c) 2008 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 * dkocher@cyberduck.ch
21 import ch
.cyberduck
.core
.Host
;
22 import ch
.cyberduck
.core
.exception
.BackgroundException
;
23 import ch
.cyberduck
.core
.threading
.BackgroundAction
;
24 import ch
.cyberduck
.core
.threading
.BackgroundActionListener
;
25 import ch
.cyberduck
.binding
.application
.NSButton
;
26 import ch
.cyberduck
.binding
.application
.NSProgressIndicator
;
27 import ch
.cyberduck
.binding
.application
.NSTextField
;
28 import ch
.cyberduck
.binding
.application
.NSView
;
30 import org
.rococoa
.Foundation
;
31 import org
.rococoa
.ID
;
36 public class TaskController
extends BundleController
{
38 private BackgroundAction task
;
41 private NSTextField name
;
43 public void setName(NSTextField name
) {
45 this.name
.setStringValue(task
.getName());
49 private NSTextField text
;
51 public void setText(NSTextField text
) {
53 this.text
.setStringValue(task
.getActivity());
57 private NSProgressIndicator progress
;
59 public void setProgress(NSProgressIndicator progress
) {
60 this.progress
= progress
;
61 this.progress
.setDisplayedWhenStopped(false);
62 this.progress
.setIndeterminate(true);
66 private NSButton stopButton
;
68 public void setStopButton(NSButton stopButton
) {
69 this.stopButton
= stopButton
;
70 this.stopButton
.setTarget(this.id());
71 this.stopButton
.setAction(Foundation
.selector("stopButtonClicked:"));
74 public void stopButtonClicked(final ID sender
) {
81 public void setView(NSView view
) {
86 public NSView
view() {
90 public TaskController(final BackgroundAction task
) {
93 if(this.task
.isRunning()) {
94 progress
.startAnimation(null);
96 this.task
.addListener(new BackgroundActionListener() {
97 public void start(BackgroundAction action
) {
98 progress
.startAnimation(null);
101 public void cancel(BackgroundAction action
) {
102 progress
.stopAnimation(null);
105 public void stop(BackgroundAction action
) {
106 progress
.stopAnimation(null);
107 action
.removeListener(this);
111 public boolean alert(final Host host
, final BackgroundException failure
,
112 final StringBuilder transcript
) {
119 protected String
getBundleName() {