Merge pull request #64 in ITERATE/cyberduck from feature/windows/9074 to master
[cyberduck.git] / source / ch / cyberduck / ui / cocoa / delegate / OpenURLMenuDelegate.java
blob1d6c56119d2abddf7a48330f35c6be4da9b2dd85
1 package ch.cyberduck.ui.cocoa.delegate;
3 /*
4 * Copyright (c) 2012 David Kocher. All rights reserved.
5 * http://cyberduck.ch/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * dkocher@cyberduck.ch
21 import ch.cyberduck.core.DescriptiveUrl;
22 import ch.cyberduck.core.Path;
23 import ch.cyberduck.core.UrlProvider;
24 import ch.cyberduck.core.cdn.DistributionConfiguration;
25 import ch.cyberduck.core.local.BrowserLauncherFactory;
26 import ch.cyberduck.binding.application.NSEvent;
28 import java.util.ArrayList;
29 import java.util.List;
31 /**
32 * @version $Id:$
34 public abstract class OpenURLMenuDelegate extends URLMenuDelegate {
36 @Override
37 protected String getKeyEquivalent() {
38 return "b";
41 @Override
42 protected int getModifierMask() {
43 return NSEvent.NSCommandKeyMask | NSEvent.NSShiftKeyMask;
46 @Override
47 protected List<DescriptiveUrl> getURLs(Path selected) {
48 final ArrayList<DescriptiveUrl> list = new ArrayList<DescriptiveUrl>();
49 final UrlProvider provider = this.getSession().getFeature(UrlProvider.class);
50 if(provider != null) {
51 list.addAll(provider.toUrl(selected).filter(
52 DescriptiveUrl.Type.http, DescriptiveUrl.Type.cname, DescriptiveUrl.Type.cdn,
53 DescriptiveUrl.Type.signed, DescriptiveUrl.Type.authenticated, DescriptiveUrl.Type.torrent));
55 final DistributionConfiguration feature = this.getSession().getFeature(DistributionConfiguration.class);
56 if(feature != null) {
57 list.addAll(feature.toUrl(selected));
59 return list;
62 @Override
63 public void handle(final List<DescriptiveUrl> selected) {
64 for(DescriptiveUrl url : selected) {
65 BrowserLauncherFactory.get().open(url.getUrl());