Search in sources :

Example 1 with NSMenuItem

use of ch.cyberduck.binding.application.NSMenuItem in project cyberduck by iterate-ch.

the class MainController method setEncodingMenu.

public void setEncodingMenu(NSMenu encodingMenu) {
    this.encodingMenu = encodingMenu;
    for (String charset : new DefaultCharsetProvider().availableCharsets()) {
        final NSMenuItem item = this.encodingMenu.addItemWithTitle_action_keyEquivalent(charset, Foundation.selector("encodingMenuClicked:"), StringUtils.EMPTY);
        item.setRepresentedObject(charset);
    }
}
Also used : NSAttributedString(ch.cyberduck.binding.foundation.NSAttributedString) NSMenuItem(ch.cyberduck.binding.application.NSMenuItem)

Example 2 with NSMenuItem

use of ch.cyberduck.binding.application.NSMenuItem in project cyberduck by iterate-ch.

the class MainController method setColumnMenu.

public void setColumnMenu(NSMenu columnMenu) {
    this.columnMenu = columnMenu;
    Map<String, String> columns = new HashMap<String, String>();
    columns.put(String.format("browser.column.%s", BrowserColumn.kind.name()), BrowserColumn.kind.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.extension.name()), BrowserColumn.extension.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.size.name()), BrowserColumn.size.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.modified.name()), BrowserColumn.modified.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.owner.name()), BrowserColumn.owner.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.group.name()), BrowserColumn.group.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.permission.name()), BrowserColumn.permission.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.region.name()), BrowserColumn.region.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.version.name()), BrowserColumn.version.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.checksum.name()), BrowserColumn.checksum.toString());
    columns.put(String.format("browser.column.%s", BrowserColumn.storageclass.name()), BrowserColumn.storageclass.toString());
    for (Map.Entry<String, String> entry : columns.entrySet()) {
        NSMenuItem item = this.columnMenu.addItemWithTitle_action_keyEquivalent(entry.getValue(), Foundation.selector("columnMenuClicked:"), StringUtils.EMPTY);
        final String identifier = entry.getKey();
        item.setState(preferences.getBoolean(identifier) ? NSCell.NSOnState : NSCell.NSOffState);
        item.setRepresentedObject(identifier);
    }
}
Also used : HashMap(java.util.HashMap) NSAttributedString(ch.cyberduck.binding.foundation.NSAttributedString) Map(java.util.Map) HashMap(java.util.HashMap) NSMenuItem(ch.cyberduck.binding.application.NSMenuItem)

Example 3 with NSMenuItem

use of ch.cyberduck.binding.application.NSMenuItem in project cyberduck by iterate-ch.

the class ExtendedBookmarkController method downloadPathPanelDidEnd_returnCode_contextInfo.

public void downloadPathPanelDidEnd_returnCode_contextInfo(NSOpenPanel sheet, final int returncode, ID contextInfo) {
    switch(returncode) {
        case SheetCallback.DEFAULT_OPTION:
            final NSObject selected = sheet.URLs().lastObject();
            if (selected != null) {
                bookmark.setDownloadFolder(LocalFactory.get(Rococoa.cast(selected, NSURL.class).path()));
            }
            break;
    }
    final NSMenuItem item = downloadPathPopup.itemAtIndex(new NSInteger(0));
    final Local folder = new DownloadDirectoryFinder().find(bookmark);
    item.setTitle(folder.getDisplayName());
    item.setRepresentedObject(folder.getAbsolute());
    item.setImage(IconCacheFactory.<NSImage>get().fileIcon(folder, 16));
    downloadPathPopup.selectItem(item);
    downloadFolderOpenPanel = null;
    this.update();
}
Also used : NSInteger(org.rococoa.cocoa.foundation.NSInteger) NSObject(ch.cyberduck.binding.foundation.NSObject) NSImage(ch.cyberduck.binding.application.NSImage) NSURL(ch.cyberduck.binding.foundation.NSURL) Local(ch.cyberduck.core.Local) DownloadDirectoryFinder(ch.cyberduck.ui.browser.DownloadDirectoryFinder) NSMenuItem(ch.cyberduck.binding.application.NSMenuItem)

Example 4 with NSMenuItem

use of ch.cyberduck.binding.application.NSMenuItem in project cyberduck by iterate-ch.

the class ProgressController method setMenuHighlighted.

private void setMenuHighlighted(boolean highlighted) {
    for (int i = 0; i < filesPopup.numberOfItems().intValue(); i++) {
        final NSMenuItem item = filesPopup.itemAtIndex(new NSInteger(i));
        item.setAttributedTitle(NSAttributedString.attributedStringWithAttributes(item.title(), highlighted ? HIGHLIGHTED_FONT_ATTRIBUTES : NORMAL_FONT_ATTRIBUTES));
    }
}
Also used : NSInteger(org.rococoa.cocoa.foundation.NSInteger) NSMenuItem(ch.cyberduck.binding.application.NSMenuItem)

Example 5 with NSMenuItem

use of ch.cyberduck.binding.application.NSMenuItem in project cyberduck by iterate-ch.

the class BookmarkMenuDelegate method menuNeedsUpdate.

public void menuNeedsUpdate(final NSMenu menu) {
    if (!this.isPopulated()) {
        if (log.isTraceEnabled()) {
            log.trace(String.format("Build menu %s", menu));
        }
        for (int i = menu.numberOfItems().intValue() - 1; i >= BOOKMARKS_INDEX; i--) {
            menu.removeItemAtIndex(new NSInteger(i));
        }
        {
            final NSMenuItem item = NSMenuItem.itemWithTitle(LocaleFactory.get().localize("History", "Localizable"), null, StringUtils.EMPTY);
            item.setEnabled(true);
            item.setImage(IconCacheFactory.<NSImage>get().iconNamed("history.tiff", 16));
            item.setTarget(this.id());
            item.setAction(Foundation.selector("historyMenuClicked:"));
            historyMenu.setSupermenu(null);
            item.setSubmenu(historyMenu);
            menu.addItem(item);
        }
        {
            final NSMenuItem item = NSMenuItem.itemWithTitle(LocaleFactory.get().localize("Bonjour", "Main"), null, StringUtils.EMPTY);
            item.setEnabled(true);
            item.setImage(IconCacheFactory.<NSImage>get().iconNamed("rendezvous.tiff", 16));
            rendezvousMenu.setSupermenu(null);
            item.setSubmenu(rendezvousMenu);
            menu.addItem(item);
        }
        menu.addItem(NSMenuItem.separatorItem());
        bookmarks.groups(HostFilter.NONE).forEach((label, bookmarks) -> {
            final NSMenu submenu;
            if (StringUtils.isNotBlank(label)) {
                final NSMenuItem group = NSMenuItem.itemWithTitle(label, null, StringUtils.EMPTY);
                final NSMutableAttributedString title = NSMutableAttributedString.create(label);
                title.appendAttributedString(NSAttributedString.attributedStringWithAttributes(String.format("\n%s", MessageFormat.format(LocaleFactory.localizedString("{0} Bookmarks", "Localizable"), bookmarks.size())), BundleController.MENU_HELP_FONT_ATTRIBUTES));
                group.setAttributedTitle(title);
                switch(preferences.getInteger("bookmark.menu.icon.size")) {
                    default:
                        group.setImage(IconCacheFactory.<NSImage>get().iconNamed("NSFolder", CollectionMenuDelegate.SMALL_ICON_SIZE));
                        break;
                    case BookmarkCell.MEDIUM_BOOKMARK_SIZE:
                        group.setImage(IconCacheFactory.<NSImage>get().iconNamed("NSFolder", CollectionMenuDelegate.MEDIUM_ICON_SIZE));
                        break;
                    case BookmarkCell.LARGE_BOOKMARK_SIZE:
                        group.setImage(IconCacheFactory.<NSImage>get().iconNamed("NSFolder", CollectionMenuDelegate.LARGE_ICON_SIZE));
                        break;
                }
                submenu = NSMenu.menu();
                group.setSubmenu(submenu);
                menu.addItem(group);
            } else {
                submenu = menu;
            }
            for (Host h : bookmarks) {
                submenu.addItem(build(h));
            }
        });
    }
}
Also used : NSInteger(org.rococoa.cocoa.foundation.NSInteger) NSMenu(ch.cyberduck.binding.application.NSMenu) NSImage(ch.cyberduck.binding.application.NSImage) Host(ch.cyberduck.core.Host) NSMutableAttributedString(ch.cyberduck.binding.foundation.NSMutableAttributedString) NSMenuItem(ch.cyberduck.binding.application.NSMenuItem)

Aggregations

NSMenuItem (ch.cyberduck.binding.application.NSMenuItem)6 NSImage (ch.cyberduck.binding.application.NSImage)3 NSInteger (org.rococoa.cocoa.foundation.NSInteger)3 NSAttributedString (ch.cyberduck.binding.foundation.NSAttributedString)2 NSMutableAttributedString (ch.cyberduck.binding.foundation.NSMutableAttributedString)2 NSMenu (ch.cyberduck.binding.application.NSMenu)1 NSObject (ch.cyberduck.binding.foundation.NSObject)1 NSURL (ch.cyberduck.binding.foundation.NSURL)1 Host (ch.cyberduck.core.Host)1 Local (ch.cyberduck.core.Local)1 DownloadDirectoryFinder (ch.cyberduck.ui.browser.DownloadDirectoryFinder)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1