use of ch.cyberduck.core.threading.BackgroundAction in project cyberduck by iterate-ch.
the class BrowserController method setStatus.
public void setStatus() {
final BackgroundAction current = registry.getCurrent();
this.message(null != current ? current.getActivity() : null);
}
use of ch.cyberduck.core.threading.BackgroundAction in project cyberduck by iterate-ch.
the class TransferController method bandwidthPopupChanged.
@Action
public void bandwidthPopupChanged(NSMenuItem sender) {
if (null == sender.representedObject()) {
return;
}
final NSIndexSet selected = transferTable.selectedRowIndexes();
final float bandwidth = Float.parseFloat(sender.representedObject());
for (NSUInteger index = selected.firstIndex(); !index.equals(NSIndexSet.NSNotFound); index = selected.indexGreaterThanIndex(index)) {
final Transfer transfer = collection.get(index.intValue());
transfer.setBandwidth(bandwidth);
if (transfer.isRunning()) {
// Find matching background task
for (BackgroundAction action : registry.toArray(new BackgroundAction[registry.size()])) {
if (action instanceof TransferBackgroundAction) {
final TransferBackgroundAction t = (TransferBackgroundAction) action;
if (t.getTransfer().equals(transfer)) {
final TransferSpeedometer meter = t.getMeter();
meter.reset();
}
}
}
}
}
}
use of ch.cyberduck.core.threading.BackgroundAction in project cyberduck by iterate-ch.
the class TransferControllerFactory method applicationShouldTerminate.
/**
* @param app Singleton
* @return NSApplication.TerminateLater or NSApplication.TerminateNow depending if there are
* running transfers to be checked first
*/
public static NSUInteger applicationShouldTerminate(final NSApplication app) {
if (null == shared) {
return NSApplication.NSTerminateNow;
}
// Saving state of transfer window
PreferencesFactory.get().setProperty("queue.window.open.default", shared.isVisible());
if (TransferCollection.defaultCollection().numberOfRunningTransfers() > 0) {
final NSAlert alert = // title
NSAlert.alert(// title
LocaleFactory.localizedString("Transfer in progress"), // message
LocaleFactory.localizedString("There are files currently being transferred. Quit anyway?"), // defaultbutton
LocaleFactory.localizedString("Quit"), // alternative button
LocaleFactory.localizedString("Cancel"), // other button
null);
shared.alert(alert, new SheetCallback() {
@Override
public void callback(int returncode) {
if (returncode == DEFAULT_OPTION) {
// Quit
final BackgroundActionRegistry registry = shared.getRegistry();
for (BackgroundAction action : registry.toArray(new BackgroundAction[registry.size()])) {
action.cancel();
}
app.replyToApplicationShouldTerminate(true);
}
if (returncode == CANCEL_OPTION) {
// Cancel
app.replyToApplicationShouldTerminate(false);
}
}
});
// break
return NSApplication.NSTerminateLater;
}
return NSApplication.NSTerminateNow;
}
use of ch.cyberduck.core.threading.BackgroundAction in project cyberduck by iterate-ch.
the class ActivityController method awakeFromNib.
@Override
public void awakeFromNib() {
super.awakeFromNib();
// Initialize to listen for background tasks
registry.addListener(backgroundActionListener);
// Add already running background actions
final BackgroundAction[] actions = registry.toArray(new BackgroundAction[registry.size()]);
for (final BackgroundAction action : actions) {
tasks.put(action, new TaskController(action));
}
this.reload();
}
Aggregations