Search in sources :

Example 1 with SessionPool

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());
}
Also used : SessionPool(ch.cyberduck.core.pool.SessionPool) ArrayList(java.util.ArrayList) List(java.util.List) CopyURLMenuDelegate(ch.cyberduck.ui.cocoa.delegate.CopyURLMenuDelegate)

Example 2 with SessionPool

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);
}
Also used : Path(ch.cyberduck.core.Path) SessionPool(ch.cyberduck.core.pool.SessionPool) MoveWorker(ch.cyberduck.core.worker.MoveWorker) DefaultMainAction(ch.cyberduck.core.threading.DefaultMainAction) ArrayList(java.util.ArrayList) Map(java.util.Map)

Example 3 with SessionPool

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());
}
Also used : SessionPool(ch.cyberduck.core.pool.SessionPool) ArrayList(java.util.ArrayList) List(java.util.List) CopyURLMenuDelegate(ch.cyberduck.ui.cocoa.delegate.CopyURLMenuDelegate) WindowMainAction(ch.cyberduck.core.threading.WindowMainAction) BackgroundAction(ch.cyberduck.core.threading.BackgroundAction) DisconnectBackgroundAction(ch.cyberduck.core.threading.DisconnectBackgroundAction) TransferAction(ch.cyberduck.core.transfer.TransferAction) Action(ch.cyberduck.binding.Action) DefaultMainAction(ch.cyberduck.core.threading.DefaultMainAction) WorkerBackgroundAction(ch.cyberduck.core.threading.WorkerBackgroundAction) BrowserTransferBackgroundAction(ch.cyberduck.core.threading.BrowserTransferBackgroundAction)

Example 4 with SessionPool

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());
}
Also used : SessionPool(ch.cyberduck.core.pool.SessionPool) ArrayList(java.util.ArrayList) List(java.util.List) OpenURLMenuDelegate(ch.cyberduck.ui.cocoa.delegate.OpenURLMenuDelegate) WindowMainAction(ch.cyberduck.core.threading.WindowMainAction) BackgroundAction(ch.cyberduck.core.threading.BackgroundAction) DisconnectBackgroundAction(ch.cyberduck.core.threading.DisconnectBackgroundAction) TransferAction(ch.cyberduck.core.transfer.TransferAction) Action(ch.cyberduck.binding.Action) DefaultMainAction(ch.cyberduck.core.threading.DefaultMainAction) WorkerBackgroundAction(ch.cyberduck.core.threading.WorkerBackgroundAction) BrowserTransferBackgroundAction(ch.cyberduck.core.threading.BrowserTransferBackgroundAction)

Example 5 with SessionPool

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;
}
Also used : UrlProvider(ch.cyberduck.core.UrlProvider) SessionPool(ch.cyberduck.core.pool.SessionPool) DescriptiveUrl(ch.cyberduck.core.DescriptiveUrl) ArrayList(java.util.ArrayList)

Aggregations

SessionPool (ch.cyberduck.core.pool.SessionPool)10 ArrayList (java.util.ArrayList)9 DefaultMainAction (ch.cyberduck.core.threading.DefaultMainAction)4 List (java.util.List)4 Action (ch.cyberduck.binding.Action)2 DescriptiveUrl (ch.cyberduck.core.DescriptiveUrl)2 Path (ch.cyberduck.core.Path)2 UrlProvider (ch.cyberduck.core.UrlProvider)2 BackgroundAction (ch.cyberduck.core.threading.BackgroundAction)2 BrowserTransferBackgroundAction (ch.cyberduck.core.threading.BrowserTransferBackgroundAction)2 DisconnectBackgroundAction (ch.cyberduck.core.threading.DisconnectBackgroundAction)2 WindowMainAction (ch.cyberduck.core.threading.WindowMainAction)2 WorkerBackgroundAction (ch.cyberduck.core.threading.WorkerBackgroundAction)2 TransferAction (ch.cyberduck.core.transfer.TransferAction)2 CopyURLMenuDelegate (ch.cyberduck.ui.cocoa.delegate.CopyURLMenuDelegate)2 OpenURLMenuDelegate (ch.cyberduck.ui.cocoa.delegate.OpenURLMenuDelegate)2 Map (java.util.Map)2 NSMutableDictionary (ch.cyberduck.binding.foundation.NSMutableDictionary)1 AccessDeniedException (ch.cyberduck.core.exception.AccessDeniedException)1 BackgroundException (ch.cyberduck.core.exception.BackgroundException)1