/** * Remove software update menu item if no update feed available */ private void updateUpdateMenu() { if(!updater.hasUpdatePrivileges()) { this.applicationMenu.removeItemAtIndex(new NSInteger(1)); } }
/** * 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) ); } }
menu.removeItemAtIndex(row); menu.insertItem_atIndex(this.seperator(), row);
@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); }