use of ch.cyberduck.core.threading.RegistryBackgroundAction in project cyberduck by iterate-ch.
the class CommandController method sendButtonClicked.
@Action
public void sendButtonClicked(final NSButton sender) {
final String command = this.inputField.stringValue();
if (StringUtils.isNotBlank(command)) {
progress.startAnimation(null);
sender.setEnabled(false);
parent.background(new RegistryBackgroundAction<Void>(this, session) {
@Override
public boolean alert(final BackgroundException e) {
return false;
}
@Override
public Void run(final Session<?> session) throws BackgroundException {
final Command feature = session.getFeature(Command.class);
feature.send(command, parent, CommandController.this);
return null;
}
@Override
public void cleanup() {
super.cleanup();
progress.stopAnimation(null);
sender.setEnabled(true);
}
@Override
public String getActivity() {
return command;
}
});
}
}
use of ch.cyberduck.core.threading.RegistryBackgroundAction 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);
}
});
}
});
}
}
use of ch.cyberduck.core.threading.RegistryBackgroundAction in project cyberduck by iterate-ch.
the class ArchiveController method archive.
public void archive(final Archive format, final List<Path> selected) {
new OverwriteController(parent).overwrite(Collections.singletonList(format.getArchive(selected)), 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.archive(format, parent.workdir(), selected, parent, parent);
return true;
}
@Override
public void cleanup() {
super.cleanup();
// Update Selection
parent.reload(parent.workdir(), selected, Collections.singletonList(format.getArchive(selected)));
}
@Override
public String getActivity() {
return format.getCompressCommand(parent.workdir(), selected);
}
});
}
});
}
Aggregations