use of ch.cyberduck.core.pool.SessionPool in project cyberduck by iterate-ch.
the class MainController method setUrlMenu.
public void setUrlMenu(NSMenu urlMenu) {
this.urlMenu = urlMenu;
this.urlMenuDelegate = new CopyURLMenuDelegate() {
@Override
protected SessionPool getSession() {
final List<BrowserController> b = MainController.getBrowsers();
for (BrowserController controller : b) {
if (controller.window().isKeyWindow()) {
if (controller.isMounted()) {
return controller.getSession();
}
}
}
return null;
}
@Override
protected List<Path> getSelected() {
final List<BrowserController> b = MainController.getBrowsers();
for (BrowserController controller : b) {
if (controller.window().isKeyWindow()) {
final List<Path> selected = controller.getSelectedPaths();
if (selected.isEmpty()) {
if (controller.isMounted()) {
return Collections.singletonList(controller.workdir());
}
}
return selected;
}
}
return Collections.emptyList();
}
};
this.urlMenu.setDelegate(urlMenuDelegate.id());
}
use of ch.cyberduck.core.pool.SessionPool 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.pool.SessionPool in project cyberduck by iterate-ch.
the class BrowserController method setUrlMenu.
@Action
public void setUrlMenu(NSMenu urlMenu) {
this.urlMenu = urlMenu;
this.urlMenuDelegate = new CopyURLMenuDelegate() {
@Override
protected SessionPool getSession() {
return pool;
}
@Override
protected List<Path> getSelected() {
final List<Path> s = BrowserController.this.getSelectedPaths();
if (s.isEmpty()) {
if (BrowserController.this.isMounted()) {
return Collections.singletonList(workdir);
}
}
return s;
}
};
this.urlMenu.setDelegate(urlMenuDelegate.id());
}
use of ch.cyberduck.core.pool.SessionPool in project cyberduck by iterate-ch.
the class BrowserController method setOpenUrlMenu.
@Action
public void setOpenUrlMenu(NSMenu openUrlMenu) {
this.openUrlMenu = openUrlMenu;
this.openUrlMenuDelegate = new OpenURLMenuDelegate() {
@Override
protected SessionPool getSession() {
return pool;
}
@Override
protected List<Path> getSelected() {
final List<Path> s = BrowserController.this.getSelectedPaths();
if (s.isEmpty()) {
if (BrowserController.this.isMounted()) {
return Collections.singletonList(workdir);
}
}
return s;
}
};
this.openUrlMenu.setDelegate(openUrlMenuDelegate.id());
}
use of ch.cyberduck.core.pool.SessionPool in project cyberduck by iterate-ch.
the class OpenURLMenuDelegate method getURLs.
@Override
protected List<DescriptiveUrl> getURLs(final Path selected) {
final ArrayList<DescriptiveUrl> list = new ArrayList<DescriptiveUrl>();
final SessionPool pool = this.getSession();
final UrlProvider provider = pool.getFeature(UrlProvider.class);
if (provider != null) {
list.addAll(provider.toUrl(selected).filter(DescriptiveUrl.Type.http, DescriptiveUrl.Type.cname, DescriptiveUrl.Type.cdn, DescriptiveUrl.Type.signed, DescriptiveUrl.Type.authenticated));
}
return list;
}
Aggregations