public void setDownloadPathPopup(NSPopUpButton downloadPathPopup) { this.downloadPathPopup = downloadPathPopup; this.downloadPathPopup.setTarget(this.id()); final Selector action = Foundation.selector("downloadPathPopupClicked:"); this.downloadPathPopup.setAction(action); this.downloadPathPopup.removeAllItems(); // Default download folder this.addDownloadPath(action, host.getDownloadFolder()); this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem()); this.addDownloadPath( action, LocalFactory.createLocal(Preferences.instance().getProperty("queue.download.folder"))); // Shortcut to the Desktop this.addDownloadPath(action, LocalFactory.createLocal("~/Desktop")); // Shortcut to user home this.addDownloadPath(action, LocalFactory.createLocal("~")); // Shortcut to user downloads for 10.5 this.addDownloadPath(action, LocalFactory.createLocal("~/Downloads")); // Choose another folder // Choose another folder this.downloadPathPopup.menu().addItem(NSMenuItem.separatorItem()); this.downloadPathPopup .menu() .addItemWithTitle_action_keyEquivalent(CHOOSE, action, StringUtils.EMPTY); this.downloadPathPopup.lastItem().setTarget(this.id()); }
public void setFilesPopup(final NSPopUpButton p) { this.filesPopup = p; this.filesPopup.setTarget(this.id()); this.filesPopup.removeAllItems(); for (Path path : transfer.getRoots()) { NSMenuItem item = this.filesPopup .menu() .addItemWithTitle_action_keyEquivalent( path.getName(), Foundation.selector("reveal:"), StringUtils.EMPTY); item.setRepresentedObject(path.getAbsolute()); item.setImage(IconCache.instance().iconForPath(path, 16, false)); } this.filesPopupMenuDelegate = new TransferMenuDelegate(transfer); this.filesPopup.menu().setDelegate(this.filesPopupMenuDelegate.id()); NSNotificationCenter.defaultCenter() .addObserver( this.id(), Foundation.selector("filesPopupWillShow:"), NSPopUpButton.PopUpButtonWillPopUpNotification, this.filesPopup); NSNotificationCenter.defaultCenter() .addObserver( this.id(), Foundation.selector("filesPopupWillHide:"), "NSMenuDidEndTrackingNotification", this.filesPopup.menu()); }
public void setProtocolPopup(NSPopUpButton protocolPopup) { this.protocolPopup = protocolPopup; this.protocolPopup.setEnabled(true); this.protocolPopup.setTarget(this.id()); this.protocolPopup.setAction(Foundation.selector("protocolSelectionChanged:")); this.protocolPopup.removeAllItems(); for (Protocol protocol : ProtocolFactory.getKnownProtocols()) { final String title = protocol.getDescription(); this.protocolPopup.addItemWithTitle(title); final NSMenuItem item = this.protocolPopup.itemWithTitle(title); item.setRepresentedObject(String.valueOf(protocol.hashCode())); item.setImage(IconCache.iconNamed(protocol.icon(), 16)); } }
public void setTransferPopup(NSPopUpButton transferPopup) { this.transferPopup = transferPopup; this.transferPopup.setTarget(this.id()); this.transferPopup.setAction(Foundation.selector("transferPopupClicked:")); this.transferPopup.removeAllItems(); this.transferPopup.addItemWithTitle(DEFAULT); this.transferPopup.menu().addItem(NSMenuItem.separatorItem()); this.transferPopup.addItemWithTitle(TRANSFER_NEWCONNECTION); this.transferPopup.addItemWithTitle(TRANSFER_BROWSERCONNECTION); }
public void setConnectmodePopup(NSPopUpButton connectmodePopup) { this.connectmodePopup = connectmodePopup; this.connectmodePopup.setTarget(this.id()); this.connectmodePopup.setAction(Foundation.selector("connectmodePopupClicked:")); this.connectmodePopup.removeAllItems(); this.connectmodePopup.addItemWithTitle(DEFAULT); this.connectmodePopup.menu().addItem(NSMenuItem.separatorItem()); this.connectmodePopup.addItemWithTitle(CONNECTMODE_ACTIVE); this.connectmodePopup.addItemWithTitle(CONNECTMODE_PASSIVE); }
@Action public void downloadPathPopupClicked(final NSMenuItem sender) { if (sender.title().equals(CHOOSE)) { downloadPathPanel = NSOpenPanel.openPanel(); downloadPathPanel.setCanChooseFiles(false); downloadPathPanel.setCanChooseDirectories(true); downloadPathPanel.setAllowsMultipleSelection(false); downloadPathPanel.setCanCreateDirectories(true); downloadPathPanel.beginSheetForDirectory( null, null, this.window, this.id(), Foundation.selector("downloadPathPanelDidEnd:returnCode:contextInfo:"), null); } else { host.setDownloadFolder(LocalFactory.createLocal(sender.representedObject())); this.itemChanged(); } }
public void setEncodingPopup(NSPopUpButton encodingPopup) { this.encodingPopup = encodingPopup; this.encodingPopup.setEnabled(true); this.encodingPopup.removeAllItems(); this.encodingPopup.addItemWithTitle(DEFAULT); this.encodingPopup.menu().addItem(NSMenuItem.separatorItem()); this.encodingPopup.addItemsWithTitles( NSArray.arrayWithObjects(MainController.availableCharsets())); if (null == host.getEncoding()) { this.encodingPopup.selectItemWithTitle(DEFAULT); } else { this.encodingPopup.selectItemWithTitle(host.getEncoding()); } this.encodingPopup.setTarget(this.id()); final Selector action = Foundation.selector("encodingSelectionChanged:"); this.encodingPopup.setAction(action); }
public void setTimezonePopup(NSPopUpButton timezonePopup) { this.timezonePopup = timezonePopup; this.timezonePopup.setTarget(this.id()); this.timezonePopup.setAction(Foundation.selector("timezonePopupClicked:")); this.timezonePopup.removeAllItems(); final List<String> timezones = Arrays.asList(TimeZone.getAvailableIDs()); 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 int compare(String o1, String o2) { return TimeZone.getTimeZone(o1).getID().compareTo(TimeZone.getTimeZone(o2).getID()); } }); for (String tz : timezones) { if (tz.matches(TIMEZONE_CONTINENT_PREFIXES)) { this.timezonePopup.addItemWithTitle(String.format("%s", tz)); this.timezonePopup.lastItem().setRepresentedObject(tz); } } }