Fix transcript in transfer window.
[cyberduck.git] / source / ch / cyberduck / ui / cocoa / TaskController.java
blob58fc35d7613614c7f8e875a003028e0172d21a29
1 package ch.cyberduck.ui.cocoa;
3 /*
4 * Copyright (c) 2008 David Kocher. All rights reserved.
5 * http://cyberduck.ch/
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;
33 /**
34 * @version $Id$
36 public class TaskController extends BundleController {
38 private BackgroundAction task;
40 @Outlet
41 private NSTextField name;
43 public void setName(NSTextField name) {
44 this.name = name;
45 this.name.setStringValue(task.getName());
48 @Outlet
49 private NSTextField text;
51 public void setText(NSTextField text) {
52 this.text = text;
53 this.text.setStringValue(task.getActivity());
56 @Outlet
57 private NSProgressIndicator progress;
59 public void setProgress(NSProgressIndicator progress) {
60 this.progress = progress;
61 this.progress.setDisplayedWhenStopped(false);
62 this.progress.setIndeterminate(true);
65 @Outlet
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) {
75 task.cancel();
78 @Outlet
79 private NSView view;
81 public void setView(NSView view) {
82 this.view = view;
85 @Override
86 public NSView view() {
87 return view;
90 public TaskController(final BackgroundAction task) {
91 this.task = task;
92 this.loadBundle();
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);
110 @Override
111 public boolean alert(final Host host, final BackgroundException failure,
112 final StringBuilder transcript) {
113 return false;
118 @Override
119 protected String getBundleName() {
120 return "Task";