public Speedometer(final long timestamp, final boolean decimal) { this.timestamp = timestamp; this.sizeFormatter = SizeFormatterFactory.get(decimal); }
public SizeTooltipService() { this(SizeFormatterFactory.get()); }
public static SizeFormatter get() { return SizeFormatterFactory.get(PreferencesFactory.get().getBoolean("browser.filesize.decimal")); }
b.append(", "); b.append(SizeFormatterFactory.get(true).format( new BigDecimal(speed * 1000).setScale(0, RoundingMode.UP).longValue())); b.append("/sec");
private void setSize(final Long size) { sizeField.setAttributedStringValue(NSAttributedString.attributedStringWithAttributes( SizeFormatterFactory.get().format(size, true), TRUNCATE_MIDDLE_ATTRIBUTES)); }
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))); } }
protected NSObject objectValueForItem(final TransferItem file, final String identifier) { final TransferStatus status = this.getStatus(file); if(identifier.equals(Column.include.name())) { if(status.isRejected()) { return NSNumber.numberWithBoolean(false); } return NSNumber.numberWithBoolean(this.isSelected(file)); } if(identifier.equals(Column.filename.name())) { return NSAttributedString.attributedStringWithAttributes(file.remote.getName(), TableCellAttributes.browserFontLeftAlignment()); } if(identifier.equals(Column.size.name())) { return NSAttributedString.attributedStringWithAttributes( SizeFormatterFactory.get().format(status.getLength()), TableCellAttributes.browserFontRightAlignment()); } if(identifier.equals(Column.warning.name())) { if(file.remote.isFile()) { if(status.getLength() == 0) { return IconCacheFactory.<NSImage>get().iconNamed("alert.tiff"); } } return null; } throw new IllegalArgumentException(String.format("Unknown identifier %s", identifier)); }
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);