this.timezonePopup.addItemWithTitle(UTC.getID()); this.timezonePopup.lastItem().setRepresentedObject(UTC.getID()); this.timezonePopup.menu().addItem(NSMenuItem.separatorItem()); Collections.sort(timezones, new Comparator<String>() { @Override
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()); 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); } }
public void setFilesPopup(final NSPopUpButton p) { this.filesPopup = p; this.filesPopup.setTarget(this.id()); this.filesPopup.removeAllItems(); final List<TransferItem> items = transfer.getRoots(); for(int i = 0; i < items.size(); i++) { final TransferItem entry = items.get(i); this.filesPopup.addItemWithTitle(i == 0 && items.size() > 1 ? String.format("%s (%d more)", entry.remote.getName(), items.size() - 1) : entry.remote.getName()); } this.filesPopupMenuDelegate = new TransferMenuDelegate(transfer); this.filesPopup.menu().setDelegate(this.filesPopupMenuDelegate.id()); notificationCenter.addObserver(this.id(), Foundation.selector("filesPopupWillShow:"), NSPopUpButton.PopUpButtonWillPopUpNotification, this.filesPopup.id()); notificationCenter.addObserver(this.id(), Foundation.selector("filesPopupWillHide:"), "NSMenuDidEndTrackingNotification", this.filesPopup.menu().id()); }
/** * Set name of key in menu item */ protected void updateLicenseMenu() { final License key = LicenseFactory.find(); if(key.isReceipt()) { this.applicationMenu.removeItemAtIndex(new NSInteger(5)); this.applicationMenu.removeItemAtIndex(new NSInteger(4)); } else { this.applicationMenu.itemAtIndex(new NSInteger(5)).setAttributedTitle( NSAttributedString.attributedStringWithAttributes(key.toString(), MENU_HELP_FONT_ATTRIBUTES) ); } }
NSMenu bandwidthMenu = NSMenu.menu(); bandwidthMenu.setAutoenablesItems(true); bandwidthMenu.setDelegate(controller.getBandwidthMenuDelegate().id()); final NSMenuItem unlimited = bandwidthMenu.addItemWithTitle_action_keyEquivalent(LocaleFactory.localizedString("Unlimited Bandwidth", "Transfer"), bandwidth.action(), StringUtils.EMPTY); unlimited.setImage(bandwidth.image()); unlimited.setRepresentedObject(String.valueOf(BandwidthThrottle.UNLIMITED)); bandwidthMenu.addItem(NSMenuItem.separatorItem()); final StringTokenizer options = new StringTokenizer(preferences.getProperty("queue.bandwidth.options"), ","); while(options.hasMoreTokens()) { final String bytes = options.nextToken(); final NSMenuItem m = bandwidthMenu.addItemWithTitle_action_keyEquivalent(SizeFormatterFactory.get().format(Integer.parseInt(bytes)) + "/s", bandwidth.action(), StringUtils.EMPTY); NSMenu connectionsMenu = NSMenu.menu(); connectionsMenu.setAutoenablesItems(true); final StringTokenizer options = new StringTokenizer(preferences.getProperty("queue.connections.options"), ","); while(options.hasMoreTokens()) { final String n = options.nextToken(); final NSMenuItem m = connectionsMenu.addItemWithTitle_action_keyEquivalent( MessageFormat.format(LocaleFactory.localizedString("{0} Connections", "Transfer"), n), TransferToolbarItem.connections.action(), StringUtils.EMPTY);
button.setAction(browserview.action()); button.setSelectedSegment(preferences.getInteger("browser.view")); NSMenu menu = NSMenu.menu(); menu.addItemWithTitle_action_keyEquivalent(LocaleFactory.localizedString("List"), Foundation.selector("browserSwitchMenuClicked:"), StringUtils.EMPTY); menu.itemWithTitle(LocaleFactory.localizedString("List")).setTag(BrowserController.BrowserSwitchSegement.list.ordinal()); menu.addItemWithTitle_action_keyEquivalent(LocaleFactory.localizedString("Outline"), Foundation.selector("browserSwitchMenuClicked:"), StringUtils.EMPTY); menu.itemWithTitle(LocaleFactory.localizedString("Outline")).setTag(BrowserController.BrowserSwitchSegement.outline.ordinal()); toolbarMenu.setSubmenu(menu); item.setView(button); encoding.action(), StringUtils.EMPTY); final String[] charsets = new DefaultCharsetProvider().availableCharsets(); NSMenu charsetMenu = NSMenu.menu(); for(String charset : charsets) { final NSMenuItem m = charsetMenu.addItemWithTitle_action_keyEquivalent(charset, encoding.action(), StringUtils.EMPTY); m.setRepresentedObject(charset); NSMenu editMenu = NSMenu.menu(); editMenu.setAutoenablesItems(true); editMenu.setDelegate(controller.getEditMenuDelegate().id()); toolbarMenu.setSubmenu(editMenu); final NSButton button = NSButton.buttonWithFrame(new NSRect(0, 0));
menu.removeItemAtIndex(row); menu.insertItem_atIndex(this.seperator(), row);
public void setDefaultDownloadThrottleCombobox(NSPopUpButton b) { this.defaultDownloadThrottleCombobox = b; this.defaultDownloadThrottleCombobox.setTarget(this.id()); this.defaultDownloadThrottleCombobox.setAction(Foundation.selector("defaultDownloadThrottleComboboxClicked:")); int bandwidth = (int) preferences.getDouble("queue.download.bandwidth.bytes"); final StringTokenizer options = new StringTokenizer(preferences.getProperty("queue.bandwidth.options"), ","); while(options.hasMoreTokens()) { final String bytes = options.nextToken(); this.defaultDownloadThrottleCombobox.addItemWithTitle(SizeFormatterFactory.get().format(Integer.parseInt(bytes)) + "/s"); this.defaultDownloadThrottleCombobox.lastItem().setRepresentedObject(bytes); } if(-1 == bandwidth) { this.defaultDownloadThrottleCombobox.selectItemWithTag(new NSInteger(-1)); } else { this.defaultDownloadThrottleCombobox.selectItemAtIndex( this.defaultDownloadThrottleCombobox.menu().indexOfItemWithRepresentedObject(String.valueOf(bandwidth))); } }
public static NSMenu menu() { return CLASS.alloc().init(); }
public static NSMenu menuWithTitle(String title) { return CLASS.alloc().initWithTitle(title); }
@Action public void menuItemClicked(final NSMenuItem item) { this.handle(this.getURLs(item.menu().indexOfItem(item), this.getSelected())); }
private void addDownloadPath(final Local f) { if(downloadPathPopup.menu().itemWithTitle(f.getDisplayName()) == null) { downloadPathPopup.addItemWithTitle(f.getDisplayName()); downloadPathPopup.lastItem().setImage(IconCacheFactory.<NSImage>get().fileIcon(f, 16)); downloadPathPopup.lastItem().setRepresentedObject(f.getAbsolute()); if(new DownloadDirectoryFinder().find(bookmark).equals(f)) { downloadPathPopup.selectItem(downloadPathPopup.lastItem()); } } }
@Override public boolean menuUpdateItemAtIndex(NSMenu menu, NSMenuItem item, NSInteger row, boolean cancel) { if(row.intValue() == index) { item.setEnabled(true); item.setTitle(LocaleFactory.get().localize("History", "Localizable")); item.setImage(IconCacheFactory.<NSImage>get().iconNamed("history.tiff", 16)); item.setTarget(this.id()); item.setAction(Foundation.selector("historyMenuClicked:")); item.setSubmenu(historyMenu); } if(row.intValue() == index + 1) { item.setEnabled(true); item.setTitle(LocaleFactory.get().localize("Bonjour", "Main")); item.setImage(IconCacheFactory.<NSImage>get().iconNamed("rendezvous.tiff", 16)); item.setSubmenu(rendezvousMenu); } if(row.intValue() == index + 2) { menu.removeItemAtIndex(row); menu.insertItem_atIndex(this.seperator(), row); } if(row.intValue() > index + 2) { Host h = this.itemForIndex(row); item.setTitle(BookmarkNameProvider.toString(h)); item.setTarget(this.id()); item.setImage(IconCacheFactory.<NSImage>get().iconNamed(h.getProtocol().icon(), preferences.getInteger("bookmark.menu.icon.size"))); item.setAction(this.getDefaultAction()); item.setRepresentedObject(h.getUuid()); } return super.menuUpdateItemAtIndex(menu, item, row, cancel); }
public void setDefaultUploadThrottleCombobox(NSPopUpButton b) { this.defaultUploadThrottleCombobox = b; this.defaultUploadThrottleCombobox.setTarget(this.id()); this.defaultUploadThrottleCombobox.setAction(Foundation.selector("defaultUploadThrottleComboboxClicked:")); int bandwidth = (int) preferences.getDouble("queue.upload.bandwidth.bytes"); final StringTokenizer options = new StringTokenizer(preferences.getProperty("queue.bandwidth.options"), ","); while(options.hasMoreTokens()) { final String bytes = options.nextToken(); this.defaultUploadThrottleCombobox.addItemWithTitle(SizeFormatterFactory.get().format(Integer.parseInt(bytes)) + "/s"); this.defaultUploadThrottleCombobox.lastItem().setRepresentedObject(bytes); } if(-1 == bandwidth) { this.defaultUploadThrottleCombobox.selectItemWithTag(new NSInteger(-1)); } else { this.defaultUploadThrottleCombobox.selectItemAtIndex( this.defaultUploadThrottleCombobox.menu().indexOfItemWithRepresentedObject(String.valueOf(bandwidth))); } }
this.addProtocol(protocol); this.protocolCombobox.menu().addItem(NSMenuItem.separatorItem()); for(Protocol protocol : protocols.find(new DefaultProtocolPredicate( EnumSet.of(Protocol.Type.s3, Protocol.Type.swift, Protocol.Type.azure, Protocol.Type.b2, Protocol.Type.dracoon, Protocol.Type.googlestorage)))) { this.addProtocol(protocol); this.protocolCombobox.menu().addItem(NSMenuItem.separatorItem()); for(Protocol protocol : protocols.find(new DefaultProtocolPredicate( EnumSet.of(Protocol.Type.dropbox, Protocol.Type.onedrive, Protocol.Type.googledrive)))) { this.addProtocol(protocol); this.protocolCombobox.menu().addItem(NSMenuItem.separatorItem()); for(Protocol protocol : protocols.find(new DefaultProtocolPredicate( EnumSet.of(Protocol.Type.file)))) { this.addProtocol(protocol); this.protocolCombobox.menu().addItem(NSMenuItem.separatorItem()); for(Protocol protocol : protocols.find(new ProfileProtocolPredicate())) { this.addProtocol(protocol);
public void setUpdateFeedPopup(NSPopUpButton b) { this.updateFeedPopup = b; this.updateFeedPopup.removeAllItems(); this.updateFeedPopup.setAction(Foundation.selector("updateFeedPopupClicked:")); this.updateFeedPopup.addItemWithTitle(LocaleFactory.localizedString("Release")); this.updateFeedPopup.lastItem().setRepresentedObject(preferences.getProperty("update.feed.release")); this.updateFeedPopup.addItemWithTitle(LocaleFactory.localizedString("Beta")); this.updateFeedPopup.lastItem().setRepresentedObject(preferences.getProperty("update.feed.beta")); this.updateFeedPopup.addItemWithTitle(LocaleFactory.localizedString("Snapshot Builds")); this.updateFeedPopup.lastItem().setRepresentedObject(preferences.getProperty("update.feed.nightly")); final String feed = preferences.getProperty(Updater.PROPERTY_FEED_URL); NSInteger selected = this.updateFeedPopup.menu().indexOfItemWithRepresentedObject(feed); if(-1 == selected.intValue()) { log.warn(String.format("Invalid feed setting:%s", feed)); this.updateFeedPopup.selectItemAtIndex(this.updateFeedPopup.menu().indexOfItemWithRepresentedObject( preferences.getProperty("update.feed.release"))); } else { this.updateFeedPopup.selectItemAtIndex(selected); } }
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); } }
this.addProtocol(protocol); this.protocolPopup.menu().addItem(NSMenuItem.separatorItem()); for(Protocol protocol : protocols.find(new DefaultProtocolPredicate( EnumSet.of(Protocol.Type.s3, Protocol.Type.swift, Protocol.Type.azure, Protocol.Type.b2, Protocol.Type.dracoon, Protocol.Type.googlestorage)))) { this.addProtocol(protocol); this.protocolPopup.menu().addItem(NSMenuItem.separatorItem()); for(Protocol protocol : protocols.find(new DefaultProtocolPredicate( EnumSet.of(Protocol.Type.dropbox, Protocol.Type.onedrive, Protocol.Type.googledrive)))) { this.addProtocol(protocol); this.protocolPopup.menu().addItem(NSMenuItem.separatorItem()); for(Protocol protocol : protocols.find(new DefaultProtocolPredicate( EnumSet.of(Protocol.Type.file)))) { this.addProtocol(protocol); this.protocolPopup.menu().addItem(NSMenuItem.separatorItem()); for(Protocol protocol : protocols.find(new ProfileProtocolPredicate())) { this.addProtocol(protocol);
public void setDownloadPathPopup(NSPopUpButton b) { this.downloadPathPopup = b; this.downloadPathPopup.setTarget(this.id()); this.downloadPathPopup.setAction(Foundation.selector("downloadPathPopupClicked:")); this.downloadPathPopup.removeAllItems(); // Default download folder this.addDownloadPath(DEFAULT_DOWNLOAD_FOLDER); this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem()); // Shortcut to the Desktop this.addDownloadPath(LocalFactory.get("~/Desktop")); // Shortcut to user home this.addDownloadPath(LocalFactory.get("~")); // Shortcut to user downloads for 10.5 this.addDownloadPath(LocalFactory.get("~/Downloads")); // Choose another folder this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem()); this.downloadPathPopup.addItemWithTitle(String.format("%s…", LocaleFactory.localizedString("Choose"))); }
public void setDownloadPathPopup(final NSPopUpButton button) { this.downloadPathPopup = button; this.downloadPathPopup.setTarget(this.id()); this.downloadPathPopup.setAction(Foundation.selector("downloadPathPopupClicked:")); this.downloadPathPopup.removeAllItems(); // Default download folder this.addDownloadPath(new DownloadDirectoryFinder().find(bookmark)); this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem()); this.addDownloadPath(LocalFactory.get(preferences.getProperty("queue.download.folder"))); // Shortcut to the Desktop this.addDownloadPath(LocalFactory.get("~/Desktop")); // Shortcut to user home this.addDownloadPath(LocalFactory.get("~")); // Shortcut to user downloads for 10.5 this.addDownloadPath(LocalFactory.get("~/Downloads")); // Choose another folder // Choose another folder this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem()); this.downloadPathPopup.addItemWithTitle(String.format("%s…", LocaleFactory.localizedString("Choose"))); }