Search in sources :

Example 1 with TransferCollectionBackgroundAction

use of ch.cyberduck.core.threading.TransferCollectionBackgroundAction in project cyberduck by iterate-ch.

the class TransferController method start.

/**
 * @param transfer Transfer
 */
public void start(final Transfer transfer, final TransferOptions options, final TransferCallback callback) {
    final ProgressController progress = transferTableModel.getController(transfer);
    final Cache<Path> cache = new PathCache(preferences.getInteger("transfer.cache.size"));
    final Host source = transfer.getSource();
    final Host destination = transfer.getDestination();
    final TransferBackgroundAction action = new TransferCollectionBackgroundAction(this, null == source ? SessionPool.DISCONNECTED : SessionPoolFactory.create(this, source, progress), null == destination ? SessionPool.DISCONNECTED : SessionPoolFactory.create(this, destination, progress), this, progress, transfer, options) {

        @Override
        public void init() {
            super.init();
            if (preferences.getBoolean("queue.window.open.transfer.start")) {
                window.makeKeyAndOrderFront(null);
            }
        }

        @Override
        public void finish() {
            super.finish();
            if (transfer.isComplete()) {
                callback.complete(transfer);
            }
        }

        @Override
        public void cleanup() {
            super.cleanup();
            if (transfer.isReset() && transfer.isComplete()) {
                if (preferences.getBoolean("queue.window.open.transfer.stop")) {
                    if (!(collection.numberOfRunningTransfers() > 0)) {
                        window.orderOut(null);
                    }
                }
            }
        }
    };
    if (!collection.contains(transfer)) {
        this.add(transfer, action);
    } else {
        this.background(action);
    }
}
Also used : Path(ch.cyberduck.core.Path) PathCache(ch.cyberduck.core.PathCache) Host(ch.cyberduck.core.Host) TransferCollectionBackgroundAction(ch.cyberduck.core.threading.TransferCollectionBackgroundAction) TransferBackgroundAction(ch.cyberduck.core.threading.TransferBackgroundAction)

Aggregations

Host (ch.cyberduck.core.Host)1 Path (ch.cyberduck.core.Path)1 PathCache (ch.cyberduck.core.PathCache)1 TransferBackgroundAction (ch.cyberduck.core.threading.TransferBackgroundAction)1 TransferCollectionBackgroundAction (ch.cyberduck.core.threading.TransferCollectionBackgroundAction)1