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);
}
}
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);
}
}
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();
}
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));
}
}
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));
}
});
}
}
Aggregations