Fix transcript in transfer window.
[cyberduck.git] / source / ch / cyberduck / ui / cocoa / delegate / ArchiveMenuDelegate.java
blob960ed46c222a08a307968b5d99d53e0e6d950d7b
1 package ch.cyberduck.ui.cocoa.delegate;
3 /*
4 * Copyright (c) 2008 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.Archive;
22 import ch.cyberduck.binding.application.NSMenu;
23 import ch.cyberduck.binding.application.NSMenuItem;
25 import org.rococoa.Foundation;
26 import org.rococoa.Selector;
27 import org.rococoa.cocoa.foundation.NSInteger;
29 /**
30 * @version $Id$
32 public class ArchiveMenuDelegate extends AbstractMenuDelegate {
34 @Override
35 public NSInteger numberOfItemsInMenu(NSMenu menu) {
36 if(this.isPopulated()) {
37 // If you return a negative value, the number of items is left unchanged
38 // and menu:updateItem:atIndex:shouldCancel: is not called.
39 return new NSInteger(-1);
41 return new NSInteger(Archive.getKnownArchives().length);
44 @Override
45 public boolean menuUpdateItemAtIndex(NSMenu menu, NSMenuItem item, NSInteger index, boolean cancel) {
46 final Archive archive = Archive.getKnownArchives()[index.intValue()];
47 item.setRepresentedObject(archive.getIdentifier());
48 item.setTitle(archive.getIdentifier());
49 item.setAction(this.getDefaultAction());
50 return super.menuUpdateItemAtIndex(menu, item, index, cancel);
53 @Override
54 protected Selector getDefaultAction() {
55 return Foundation.selector("archiveMenuClicked:");