use of ch.cyberduck.core.threading.DefaultMainAction in project cyberduck by iterate-ch.
the class SheetInvoker method beginSheet.
public int beginSheet() {
if (NSThread.isMainThread()) {
// No need to call invoke on main thread
if (controller != null) {
controller.loadBundle();
this.beginSheet(controller.window());
} else {
this.beginSheet(window);
}
} else {
final SheetInvoker invoker = this;
invoke(new DefaultMainAction() {
@Override
public void run() {
// Invoke again on main thread
if (controller != null) {
controller.loadBundle();
invoker.beginSheet(controller.window());
} else {
invoker.beginSheet(window);
}
}
}, true);
if (log.isDebugEnabled()) {
log.debug("Await sheet dismiss");
}
// Synchronize on parent controller. Only display one sheet at once.
Uninterruptibles.awaitUninterruptibly(signal);
// Close window in case signal was count down prior closing window
invoke(new DefaultMainAction() {
@Override
public void run() {
// Invoke again on main thread
if (controller != null) {
controller.window().orderOut(null);
} else {
window.orderOut(null);
}
}
}, true);
}
return returncode;
}
use of ch.cyberduck.core.threading.DefaultMainAction in project cyberduck by iterate-ch.
the class MoveController method rename.
/**
* @param selected A map with the original files as the key and the destination
* files as the value
*/
public void rename(final Map<Path, Path> selected) {
final DefaultMainAction action = new DefaultMainAction() {
@Override
public void run() {
final SessionPool pool = parent.getSession();
final MoveWorker move = new MoveWorker(selected, pool.getHost().getProtocol().getStatefulness() == Protocol.Statefulness.stateful ? SessionPoolFactory.create(parent, pool.getHost()) : pool, cache, parent, LoginCallbackFactory.get(parent)) {
@Override
public void cleanup(final Map<Path, Path> result) {
final List<Path> changed = new ArrayList<>();
changed.addAll(selected.keySet());
changed.addAll(selected.values());
parent.reload(parent.workdir(), changed, new ArrayList<>(selected.values()));
}
};
parent.background(new WorkerBackgroundAction<Map<Path, Path>>(parent, parent.getSession(), move));
}
};
this.rename(selected, action);
}
use of ch.cyberduck.core.threading.DefaultMainAction in project cyberduck by iterate-ch.
the class ProgressController method transferDidProgress.
@Override
public void transferDidProgress(final Transfer transfer, final TransferProgress progress) {
this.setProgress(progress.getProgress());
final double transferred = progress.getTransferred();
final double size = progress.getSize();
invoke(new DefaultMainAction() {
@Override
public void run() {
if (transferred > 0 && size > 0) {
progressBar.setIndeterminate(false);
progressBar.setMaxValue(size);
progressBar.setDoubleValue(transferred);
} else {
progressBar.setIndeterminate(true);
}
}
});
}
use of ch.cyberduck.core.threading.DefaultMainAction in project cyberduck by iterate-ch.
the class TransferController method transferDidStart.
/**
* @param transfer Transfer
*/
public void transferDidStart(final Transfer transfer) {
final ProgressController progress = transferTableModel.getController(transfer);
progress.transferDidStart(transfer);
this.invoke(new DefaultMainAction() {
@Override
public void run() {
toolbar.validateVisibleItems();
}
});
}
use of ch.cyberduck.core.threading.DefaultMainAction in project cyberduck by iterate-ch.
the class ArchiveController method unarchive.
public void unarchive(final List<Path> selected) {
final List<Path> expanded = new ArrayList<Path>();
for (final Path s : selected) {
final Archive archive = Archive.forName(s.getName());
if (null == archive) {
continue;
}
new OverwriteController(parent).overwrite(archive.getExpanded(Collections.singletonList(s)), new DefaultMainAction() {
@Override
public void run() {
parent.background(new RegistryBackgroundAction<Boolean>(parent, parent.getSession()) {
@Override
public Boolean run(final Session<?> session) throws BackgroundException {
final Compress feature = session.getFeature(Compress.class);
feature.unarchive(archive, s, parent, parent);
return true;
}
@Override
public void cleanup() {
super.cleanup();
expanded.addAll(archive.getExpanded(Collections.singletonList(s)));
// Update Selection
parent.reload(parent.workdir(), selected, expanded);
}
@Override
public String getActivity() {
return archive.getDecompressCommand(s);
}
});
}
});
}
}
Aggregations