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); } }
private void addProtocol(final Protocol protocol) { final String title = protocol.getDescription(); this.protocolPopup.addItemWithTitle(title); this.protocolPopup.lastItem().setRepresentedObject(String.valueOf(protocol.hashCode())); this.protocolPopup.lastItem().setImage(IconCacheFactory.<NSImage>get().iconNamed(protocol.icon(), 16)); }
private void addProtocol(final Protocol protocol) { final String title = protocol.getDescription(); protocolCombobox.addItemWithTitle(title); protocolCombobox.lastItem().setRepresentedObject(String.valueOf(protocol.hashCode())); protocolCombobox.lastItem().setImage(IconCacheFactory.<NSImage>get().iconNamed(protocol.icon(), 16)); }
public void setDefaultStorageClassPopup(NSPopUpButton b) { this.defaultStorageClassPopup = b; this.defaultStorageClassPopup.setAutoenablesItems(false); this.defaultStorageClassPopup.removeAllItems(); this.defaultStorageClassPopup.addItemWithTitle(LocaleFactory.localizedString(S3Object.STORAGE_CLASS_STANDARD, "S3")); this.defaultStorageClassPopup.lastItem().setRepresentedObject(S3Object.STORAGE_CLASS_STANDARD); this.defaultStorageClassPopup.addItemWithTitle(LocaleFactory.localizedString(S3Object.STORAGE_CLASS_INFREQUENT_ACCESS, "S3")); this.defaultStorageClassPopup.lastItem().setRepresentedObject(S3Object.STORAGE_CLASS_INFREQUENT_ACCESS); this.defaultStorageClassPopup.addItemWithTitle(LocaleFactory.localizedString("ONEZONE_IA", "S3")); this.defaultStorageClassPopup.lastItem().setRepresentedObject("ONEZONE_IA"); this.defaultStorageClassPopup.addItemWithTitle(LocaleFactory.localizedString(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY, "S3")); this.defaultStorageClassPopup.lastItem().setRepresentedObject(S3Object.STORAGE_CLASS_REDUCED_REDUNDANCY); this.defaultStorageClassPopup.setTarget(this.id()); this.defaultStorageClassPopup.setAction(Foundation.selector("defaultStorageClassPopupClicked:")); this.defaultStorageClassPopup.selectItemWithTitle(LocaleFactory.localizedString(preferences.getProperty("s3.storage.class"), "S3")); }
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 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))); } }
public void setLifecycleDeletePopup(final NSPopUpButton b) { this.lifecycleDeletePopup = b; for(String option : preferences.getList("s3.lifecycle.delete.options")) { this.lifecycleDeletePopup.addItemWithTitle(MessageFormat.format(LocaleFactory.localizedString("after {0} Days", "S3"), option)); this.lifecycleDeletePopup.lastItem().setAction(Foundation.selector("lifecyclePopupClicked:")); this.lifecycleDeletePopup.lastItem().setTarget(this.id()); this.lifecycleDeletePopup.lastItem().setRepresentedObject(option); } }
@Override public boolean menuUpdateItemAtIndex(NSMenu menu, NSMenuItem item, NSInteger index, boolean cancel) { final Archive archive = Archive.getKnownArchives()[index.intValue()]; item.setRepresentedObject(archive.getIdentifier()); item.setTitle(archive.getIdentifier()); item.setAction(this.getDefaultAction()); return super.menuUpdateItemAtIndex(menu, item, index, cancel); }
public void setLifecycleTransitionPopup(final NSPopUpButton b) { this.lifecycleTransitionPopup = b; this.lifecycleTransitionPopup.setTarget(this.id()); for(String option : preferences.getList("s3.lifecycle.transition.options")) { this.lifecycleTransitionPopup.addItemWithTitle(MessageFormat.format(LocaleFactory.localizedString("after {0} Days", "S3"), option)); this.lifecycleTransitionPopup.lastItem().setAction(Foundation.selector("lifecyclePopupClicked:")); this.lifecycleTransitionPopup.lastItem().setTarget(this.id()); this.lifecycleTransitionPopup.lastItem().setRepresentedObject(option); } }
public void setDefaultEncryptionPopup(NSPopUpButton b) { this.defaultEncryptionPopup = b; this.defaultEncryptionPopup.setAutoenablesItems(false); this.defaultEncryptionPopup.removeAllItems(); this.defaultEncryptionPopup.addItemWithTitle(LocaleFactory.localizedString("None")); this.defaultEncryptionPopup.lastItem().setRepresentedObject(S3EncryptionFeature.Algorithm.NONE.toString()); this.defaultEncryptionPopup.addItemWithTitle(LocaleFactory.localizedString(S3EncryptionFeature.SSE_AES256.getDescription(), "S3")); this.defaultEncryptionPopup.lastItem().setRepresentedObject(S3EncryptionFeature.SSE_AES256.toString()); this.defaultEncryptionPopup.addItemWithTitle(LocaleFactory.localizedString(KMSEncryptionFeature.SSE_KMS_DEFAULT.getDescription(), "S3")); this.defaultEncryptionPopup.lastItem().setRepresentedObject(KMSEncryptionFeature.SSE_KMS_DEFAULT.toString()); this.defaultEncryptionPopup.setTarget(this.id()); this.defaultEncryptionPopup.setAction(Foundation.selector("defaultEncryptionPopupClicked:")); if(StringUtils.isEmpty(preferences.getProperty("s3.encryption.algorithm"))) { this.defaultEncryptionPopup.selectItemWithTitle(LocaleFactory.localizedString("None")); } else { this.defaultEncryptionPopup.selectItemAtIndex(this.defaultEncryptionPopup.indexOfItemWithRepresentedObject(preferences.getProperty("s3.encryption.algorithm"))); } }
private void addDownloadPath(final Local f) { this.downloadPathPopup.addItemWithTitle(f.getDisplayName()); this.downloadPathPopup.lastItem().setImage( IconCacheFactory.<NSImage>get().fileIcon(f, 16) ); this.downloadPathPopup.lastItem().setRepresentedObject(f.getAbbreviatedPath()); if(DEFAULT_DOWNLOAD_FOLDER.equals(f)) { this.downloadPathPopup.selectItem(this.downloadPathPopup.lastItem()); } }
public void downloadPathPanelDidEnd_returnCode_contextInfo(NSOpenPanel sheet, final int returncode, ID contextInfo) { switch(returncode) { case SheetCallback.DEFAULT_OPTION: final NSObject selected = sheet.filenames().lastObject(); if(selected != null) { bookmark.setDownloadFolder(LocalFactory.get(selected.toString())); } 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(); }
private void addNavigation(final Path p) { pathPopupButton.addItemWithTitle(p.getAbsolute()); pathPopupButton.lastItem().setRepresentedObject(p.getAbsolute()); if(p.isVolume()) { pathPopupButton.lastItem().setImage(IconCacheFactory.<NSImage>get().volumeIcon(pool.getHost().getProtocol(), 16)); } else { pathPopupButton.lastItem().setImage(IconCacheFactory.<NSImage>get().fileIcon(p, 16)); } }
public void downloadPathPanelDidEnd_returnCode_contextInfo(NSOpenPanel sheet, int returncode, ID contextInfo) { if(returncode == SheetCallback.DEFAULT_OPTION) { NSArray selected = sheet.filenames(); String filename; if((filename = selected.lastObject().toString()) != null) { final Local folder = LocalFactory.get(filename); preferences.setProperty("queue.download.folder", folder.getAbbreviatedPath()); preferences.setProperty("queue.download.folder.bookmark", folder.getBookmark()); } } final Local custom = LocalFactory.get(preferences.getProperty("queue.download.folder")); final NSMenuItem item = downloadPathPopup.itemAtIndex(new NSInteger(0)); item.setTitle(custom.getDisplayName()); item.setRepresentedObject(custom.getAbsolute()); item.setImage(IconCacheFactory.<NSImage>get().fileIcon(custom, 16)); downloadPathPopup.selectItem(item); downloadPathPanel = null; }
public void setTransferPopup(NSPopUpButton b) { this.transferPopup = b; this.transferPopup.setTarget(this.id()); this.transferPopup.setAction(Foundation.selector("transferPopupClicked:")); this.transferPopup.removeAllItems(); for(String name : preferences.getList("queue.transfer.type.enabled")) { final Host.TransferType t = Host.TransferType.valueOf(name); this.transferPopup.addItemWithTitle(t.toString()); this.transferPopup.lastItem().setRepresentedObject(t.name()); } this.transferPopup.selectItemAtIndex(this.transferPopup.indexOfItemWithRepresentedObject( preferences.getProperty("queue.transfer.type") )); }
public void setDefaultBucketLocation(NSPopUpButton b) { this.defaultBucketLocation = b; this.defaultBucketLocation.setAutoenablesItems(false); this.defaultBucketLocation.removeAllItems(); for(Location.Name location : new S3Protocol().getRegions()) { this.defaultBucketLocation.addItemWithTitle(location.toString()); this.defaultBucketLocation.lastItem().setRepresentedObject(location.getIdentifier()); } this.defaultBucketLocation.setTarget(this.id()); this.defaultBucketLocation.setAction(Foundation.selector("defaultBucketLocationClicked:")); this.defaultBucketLocation.selectItemWithTitle(LocaleFactory.localizedString(preferences.getProperty("s3.location"), "S3")); }
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()); } } }
public NSView getAccessoryView(final NSAlert alert) { view = NSView.create(new NSRect(alert.window().frame().size.width.doubleValue(), 0)); regionPopup = NSPopUpButton.buttonWithFrame(new NSRect(alert.window().frame().size.width.doubleValue(), 26)); regionPopup.setFrameOrigin(new NSPoint(0, 0)); for(Location.Name region : regions) { regionPopup.addItemWithTitle(region.toString()); regionPopup.itemWithTitle(region.toString()).setRepresentedObject(region.getIdentifier()); if(region.getIdentifier().equals(PreferencesFactory.get().getProperty("s3.location"))) { regionPopup.selectItem(regionPopup.lastItem()); } } // Override accessory view with location menu added view.addSubview(regionPopup); return view; }
@Override public void change(final Host bookmark) { privateKeyPopup.setEnabled(options.publickey); if(credentials.isPublicKeyAuthentication()) { privateKeyPopup.selectItemAtIndex(privateKeyPopup.indexOfItemWithRepresentedObject(credentials.getIdentity().getAbsolute())); } else { privateKeyPopup.selectItemWithTitle(LocaleFactory.localizedString("None")); } if(credentials.isPublicKeyAuthentication()) { final Local key = credentials.getIdentity(); if(-1 == privateKeyPopup.indexOfItemWithRepresentedObject(key.getAbsolute()).intValue()) { final NSInteger index = new NSInteger(0); privateKeyPopup.insertItemWithTitle_atIndex(key.getAbbreviatedPath(), index); privateKeyPopup.itemAtIndex(index).setRepresentedObject(key.getAbsolute()); } } } });
public void setActionPopup(final NSPopUpButton actionPopup) { this.actionPopup = actionPopup; this.actionPopup.removeAllItems(); this.actionPopup.setAutoenablesItems(false); final TransferAction defaultAction = TransferAction.forName(preferences.getProperty(String.format("queue.prompt.%s.action.default", transfer.getType().name()))); for(TransferAction action : TransferAction.forTransfer(transfer.getType())) { this.actionPopup.addItemWithTitle(action.getTitle()); this.actionPopup.lastItem().setRepresentedObject(action.name()); if(action.equals(defaultAction)) { this.actionPopup.selectItem(actionPopup.lastItem()); } this.actionPopup.addItemWithTitle(action.getDescription()); this.actionPopup.lastItem().setAttributedTitle(NSAttributedString.attributedStringWithAttributes(action.getDescription(), MENU_HELP_FONT_ATTRIBUTES)); this.actionPopup.lastItem().setEnabled(false); } this.actionPopup.setTarget(this.id()); this.actionPopup.setAction(Foundation.selector("actionPopupClicked:")); }