public void setLanguagePopup(NSPopUpButton b) { this.languagePopup = b; this.languagePopup.removeAllItems(); this.languagePopup.setTarget(this.id()); this.languagePopup.setAction(Foundation.selector("languagePopupClicked:")); this.languagePopup.addItemWithTitle(LocaleFactory.localizedString("Default")); this.languagePopup.menu().addItem(NSMenuItem.separatorItem()); String custom = null; if(preferences.systemLocales().size() > 1) { // No user default application scope single value of AppleLanguages property is set but a list // of preferred languages from system preferences is returned. this.languagePopup.selectItemWithTitle(LocaleFactory.localizedString("Default")); } else { // Custom language set for this application identifier custom = preferences.locale(); } for(String identifier : preferences.applicationLocales()) { this.languagePopup.addItemWithTitle(preferences.getDisplayName(identifier)); this.languagePopup.lastItem().setRepresentedObject(identifier); if(identifier.equals(custom)) { this.languagePopup.selectItem(this.languagePopup.lastItem()); } } }
public void setEncodingCombobox(NSPopUpButton b) { this.encodingCombobox = b; this.encodingCombobox.setTarget(this.id()); this.encodingCombobox.setAction(Foundation.selector("encodingComboboxClicked:")); this.encodingCombobox.removeAllItems(); this.encodingCombobox.addItemsWithTitles(NSArray.arrayWithObjects(new DefaultCharsetProvider().availableCharsets())); this.encodingCombobox.selectItemWithTitle(preferences.getProperty("browser.charset.encoding")); }
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"))); } }
@Override public void change(final Host bookmark) { protocolPopup.selectItemAtIndex(protocolPopup.indexOfItemWithRepresentedObject(String.valueOf(bookmark.getProtocol().hashCode()))); } });
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")); }
@Override public void change(final Host bookmark) { certificatePopup.setEnabled(options.certificate); certificatePopup.removeAllItems(); certificatePopup.addItemWithTitle(LocaleFactory.localizedString("None")); if(options.certificate) { certificatePopup.menu().addItem(NSMenuItem.separatorItem()); for(String certificate : new KeychainX509KeyManager(bookmark).list()) { certificatePopup.addItemWithTitle(certificate); certificatePopup.lastItem().setRepresentedObject(certificate); } } if(credentials.isCertificateAuthentication()) { certificatePopup.selectItemAtIndex(certificatePopup.indexOfItemWithRepresentedObject(credentials.getCertificate())); } else { certificatePopup.selectItemWithTitle(LocaleFactory.localizedString("None")); } } });
bucketLoggingButton.setState(logging.isEnabled() ? NSCell.NSOnState : NSCell.NSOffState); if(!logging.getContainers().isEmpty()) { bucketLoggingPopup.removeAllItems(); bucketLoggingPopup.addItemWithTitle(c.getName()); bucketLoggingPopup.lastItem().setRepresentedObject(c.getName()); bucketLoggingPopup.selectItemWithTitle(logging.getLoggingTarget()); bucketLoggingPopup.selectItemAtIndex(bucketLoggingPopup.indexOfItemWithRepresentedObject(containerService.getContainer(file).getName())); encryptionPopup.addItemWithTitle(LocaleFactory.localizedString(algorithm.getDescription(), "S3")); encryptionPopup.lastItem().setRepresentedObject(algorithm.toString()); encryptionPopup.selectItemAtIndex(new NSInteger(-1)); if(-1 != encryptionPopup.indexOfItemWithTitle(LocaleFactory.localizedString("Unknown")).intValue()) { encryptionPopup.removeItemWithTitle(LocaleFactory.localizedString("Unknown")); encryptionPopup.selectItemAtIndex(encryptionPopup.indexOfItemWithRepresentedObject(algorithm.toString())); encryptionPopup.itemAtIndex(encryptionPopup.indexOfItemWithRepresentedObject(algorithm.toString())) .setState(selectedEncryptionKeys.size() == 1 ? NSCell.NSOnState : NSCell.NSMixedState); storageClassPopup.selectItemAtIndex(new NSInteger(-1)); if(-1 != storageClassPopup.indexOfItemWithTitle(LocaleFactory.localizedString("Unknown")).intValue()) { storageClassPopup.removeItemWithTitle(LocaleFactory.localizedString("Unknown")); storageClassPopup.selectItemAtIndex(storageClassPopup.indexOfItemWithRepresentedObject(storageClass));
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 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") )); }
final String selected = distributionDeliveryPopup.titleOfSelectedItem(); distributionDeliveryPopup.removeAllItems(); distributionDeliveryPopup.addItemWithTitle(LocaleFactory.localizedString("None")); distributionDefaultRootPopup.removeAllItems(); distributionDefaultRootPopup.addItemWithTitle(LocaleFactory.localizedString("None")); distributionDefaultRootPopup.menu().addItem(NSMenuItem.separatorItem()); distributionEnableButton.setTitle(MessageFormat.format(LocaleFactory.localizedString("Enable {0} Distribution", "Status"), cdn.getName())); distributionDeliveryPopup.removeItemWithTitle(LocaleFactory.localizedString("None")); for(Distribution.Method method : cdn.getMethods(file)) { distributionDeliveryPopup.addItemWithTitle(method.toString()); distributionDeliveryPopup.itemWithTitle(method.toString()).setRepresentedObject(method.toString()); distributionDeliveryPopup.selectItemWithTitle(selected); if(null == distributionDeliveryPopup.selectedItem()) { distributionDeliveryPopup.selectItemWithTitle(method.toString()); distributionLoggingPopup.removeAllItems(); distributionLoggingPopup.addItemWithTitle(LocaleFactory.localizedString("None")); distributionLoggingPopup.itemWithTitle(LocaleFactory.localizedString("None")).setEnabled(false);
return false; final NSPopUpButton bookmarksPopup = NSPopUpButton.buttonWithFrame(new NSRect(0, 26)); bookmarksPopup.setToolTip(LocaleFactory.localizedString("Bookmarks", "Browser")); for(Host b : bookmarks) { String title = BookmarkNameProvider.toString(b); int i = 1; while(bookmarksPopup.itemWithTitle(title) != null) { title = BookmarkNameProvider.toString(b) + "-" + i; i++; bookmarksPopup.addItemWithTitle(title); bookmarksPopup.lastItem().setImage(IconCacheFactory.<NSImage>get().iconNamed(b.getProtocol().icon(), 16)); bookmarksPopup.lastItem().setRepresentedObject(b.getUuid()); if(b.equals(open)) { bookmarksPopup.selectItemAtIndex(bookmarksPopup.indexOfItem(bookmarksPopup.lastItem())); bookmarksPopup.selectItemAtIndex(new NSInteger(i)); found = true; break; if(-1 == bookmarksPopup.indexOfSelectedItem().intValue()) { bookmarksPopup.selectItemAtIndex(new NSInteger(0));
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:")); }
final NSPopUpButton button = NSPopUpButton.buttonWithFrame(new NSRect(52, 26)); button.setImage(bandwidth.image()); button.setMenu(bandwidthMenu); button.setTarget(controller.id()); button.setAction(bandwidth.action()); item.setView(button); item.setMaxSize(new NSSize(button.frame().size.width.doubleValue(), button.frame().size.height.doubleValue())); return item; final NSPopUpButton button = NSPopUpButton.buttonWithFrame(new NSRect(52, 26)); button.setImage(connections.image()); button.setMenu(connectionsMenu); button.setTarget(controller.id()); button.setAction(connections.action()); button.selectItemAtIndex(button.indexOfItemWithRepresentedObject(preferences.getProperty("queue.connections.limit"))); item.setView(button); item.setMaxSize(new NSSize(button.frame().size.width.doubleValue(), button.frame().size.height.doubleValue())); return item;
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; }
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); } }
@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 setProtocolCombobox(NSPopUpButton b) { this.protocolCombobox = b; this.protocolCombobox.setTarget(this.id()); this.protocolCombobox.setAction(Foundation.selector("protocolComboboxClicked:")); this.protocolCombobox.removeAllItems(); final ProtocolFactory protocols = ProtocolFactory.get(); for(Protocol protocol : protocols.find(new DefaultProtocolPredicate( 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); this.protocolCombobox.selectItemAtIndex(this.protocolCombobox.indexOfItemWithRepresentedObject(String.valueOf(defaultProtocol.hashCode())));
final List<Path> containers = distribution.getContainers(); if(!containers.isEmpty()) { distributionLoggingPopup.removeAllItems(); distributionLoggingPopup.addItemWithTitle(c.getName()); distributionLoggingPopup.lastItem().setRepresentedObject(c.getName()); distributionLoggingPopup.selectItemWithTitle(distribution.getLoggingContainer()); if(distributionLoggingPopup.itemWithTitle(containerService.getContainer(file).getName()) != null) { distributionLoggingPopup.selectItemWithTitle(containerService.getContainer(file).getName()); if(null == distributionLoggingPopup.selectedItem()) { distributionLoggingPopup.selectItemWithTitle(LocaleFactory.localizedString("None")); for(Path next : distribution.getRootDocuments()) { if(next.isFile()) { distributionDefaultRootPopup.addItemWithTitle(next.getName()); distributionDefaultRootPopup.lastItem().setRepresentedObject(next.getName()); if(null == distributionDefaultRootPopup.itemWithTitle(distribution.getIndexDocument())) { distributionDefaultRootPopup.addItemWithTitle(distribution.getIndexDocument()); distributionDefaultRootPopup.selectItemWithTitle(distribution.getIndexDocument()); distributionDefaultRootPopup.selectItemWithTitle(LocaleFactory.localizedString("None"));
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()); }
@Override public void change(final Host bookmark) { encodingPopup.setEnabled(bookmark.getProtocol().isEncodingConfigurable()); if(!bookmark.getProtocol().isEncodingConfigurable()) { encodingPopup.selectItemWithTitle(DEFAULT); } else { if(null == bookmark.getEncoding()) { encodingPopup.selectItemWithTitle(DEFAULT); } else { encodingPopup.selectItemAtIndex(encodingPopup.indexOfItemWithRepresentedObject(bookmark.getEncoding())); } } } });