Fix transcript in transfer window.
[cyberduck.git] / source / ch / cyberduck / ui / cocoa / delegate / RendezvousMenuDelegate.java
blobbc3e1dd6e820eb4140e482d483547a4097a26110
1 package ch.cyberduck.ui.cocoa.delegate;
3 /*
4 * Copyright (c) 2006 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.binding.application.NSImage;
22 import ch.cyberduck.binding.application.NSMenu;
23 import ch.cyberduck.binding.application.NSMenuItem;
24 import ch.cyberduck.core.BookmarkNameProvider;
25 import ch.cyberduck.core.Host;
26 import ch.cyberduck.core.LocaleFactory;
27 import ch.cyberduck.core.bonjour.RendezvousCollection;
28 import ch.cyberduck.core.resources.IconCacheFactory;
29 import ch.cyberduck.ui.cocoa.BrowserController;
30 import ch.cyberduck.ui.cocoa.MainController;
32 import org.apache.log4j.Logger;
33 import org.rococoa.Foundation;
34 import org.rococoa.Selector;
35 import org.rococoa.cocoa.foundation.NSInteger;
37 /**
38 * @version $Id$
40 public abstract class RendezvousMenuDelegate extends CollectionMenuDelegate<Host> {
41 private static final Logger log = Logger.getLogger(RendezvousMenuDelegate.class);
43 private RendezvousCollection collection;
45 public RendezvousMenuDelegate() {
46 super(RendezvousCollection.defaultCollection());
47 collection = RendezvousCollection.defaultCollection();
50 @Override
51 public boolean menuUpdateItemAtIndex(NSMenu menu, NSMenuItem item, NSInteger index, boolean cancel) {
52 if(collection.size() == 0) {
53 item.setTitle(LocaleFactory.localizedString("No Bonjour services available"));
54 item.setTarget(null);
55 item.setAction(null);
56 item.setImage(null);
57 item.setEnabled(false);
59 else {
60 final Host h = collection.get(index.intValue());
61 item.setTitle(BookmarkNameProvider.toString(h));
62 item.setTarget(this.id());
63 item.setEnabled(true);
64 item.setImage(IconCacheFactory.<NSImage>get().iconNamed(h.getProtocol().icon(), 16));
65 item.setAction(this.getDefaultAction());
66 item.setRepresentedObject(h.getUuid());
68 return super.menuUpdateItemAtIndex(menu, item, index, cancel);
71 public void rendezvousMenuClicked(NSMenuItem sender) {
72 log.debug("rendezvousMenuClicked:" + sender);
73 BrowserController controller = MainController.newDocument();
74 controller.mount(collection.lookup(sender.representedObject()));
77 @Override
78 protected Selector getDefaultAction() {
79 return Foundation.selector("rendezvousMenuClicked:");