@Override public String getTooltip(final Path file) { return sizeFormatter.format(file.attributes().getSize(), true); } }
final StringBuilder b = new StringBuilder( MessageFormat.format(LocaleFactory.localizedString("{0} of {1}"), sizeFormatter.format(transferred, running), sizeFormatter.format(size)) ); if(running && transferred > 0) { 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 synchronized TransferProgress getProgress() { long size = 0; for(Transfer t : this) { if(t.isRunning()) { size += t.getSize(); } } long transferred = 0; for(Transfer t : this) { if(t.isRunning()) { transferred += t.getTransferred(); } } return new TransferProgress(size, transferred, MessageFormat.format(LocaleFactory.localizedString("{0} of {1}"), sizeFormatter.format(transferred), sizeFormatter.format(size)), -1d); } }
/** * Resets both the progress and status field */ @Override public void awakeFromNib() { this.setProgress(MessageFormat.format(LocaleFactory.localizedString("{0} of {1}"), sizeFormatter.format(transfer.getTransferred()), sizeFormatter.format(transfer.getSize()))); this.setMessage(StringUtils.EMPTY); this.setStatus(LocaleFactory.localizedString(transfer.isComplete() ? String.format("%s complete", StringUtils.capitalize(transfer.getType().name())) : "Transfer incomplete", "Status")); super.awakeFromNib(); }
@Override public void run() { progressBar.stopAnimation(null); progressBar.setIndeterminate(true); progressBar.setHidden(true); setMessage(StringUtils.EMPTY); setProgress(MessageFormat.format(LocaleFactory.localizedString("{0} of {1}"), sizeFormatter.format(transfer.getTransferred()), sizeFormatter.format(transfer.getSize()))); setStatus(LocaleFactory.localizedString(LocaleFactory.localizedString(transfer.isComplete() ? String.format("%s complete", StringUtils.capitalize(transfer.getType().name())) : "Transfer incomplete", "Status"), "Status")); statusIconView.setImage(transfer.isComplete() ? GREEN_ICON : RED_ICON); } });
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)); }
sizeFormatter.format(item.attributes().getSize()), TableCellAttributes.browserFontRightAlignment());
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);