public void update() { try { if (download.getFd() == null) { if (download.getNConnections() == 0) { name = download.getAuxInfoFilename(); } else { name = download.getAuxInfoFilename() + " - starting..."; } size = "?"; } else { name = download.getFd().getSubpath(); size = TextUtils.formatByteSize(download.getFd().getSize()); } percentComplete = download.getPercentComplete(); numberOfConnections = download.getNConnections(); speed = download.getBandwidth().getCPSHumanReadable(); complete = download.isComplete(); state = download.getState(); if (download.getBandwidth().hasGoodAverage()) { eta = formatETA(download.getETAInMinutes()); } else { eta = "?"; } } catch (IOException e) { if (T.t) { T.error("Exception while updating downloadwrapper: " + e); } } }
private void share(ArrayList<String> params) throws IOException { printer.println("All complete files: "); // ArrayList<Hash> al = new // ArrayList<Hash>(core.getFileManager().getFileDatabase().getAllHashes()); // for (Hash h : al) { // FileDescriptor fd = core.getFileManager().getFileDatabase().getFd(h); // // printer.println(" " + fd); // } printer.println(""); printer.println("Incomplete files in cache: "); for (Hash h : core.getFileManager().getCache().rootHashes()) { BlockFile bf = core.getFileManager().getCache().getBlockFile(h); printer.println(" " + bf); } printer.println(""); printer.println("Incomplete files in downloads: "); for (Hash h : core.getFileManager().getDownloadStorage().rootHashes()) { BlockFile bf = core.getFileManager().getDownloadStorage().getBlockFile(h); printer.println(" " + bf); } printer.println(""); printer.println( "Sharing " + TextUtils.formatByteSize(core.getShareManager().getFileDatabase().getShareSize()) + " in " + core.getShareManager().getFileDatabase().getNumberOfShares() + " files."); printer.println(""); }
@Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, int rowIndex, int vColIndex) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, rowIndex, vColIndex); setText(TextUtils.formatByteSize((Long) value)); setToolTipText(String.valueOf(value)); return this; }
private void showTotalBytesReceived() { status.setText( "Total bytes received: " + TextUtils.formatByteSize( ui.getCore().getNetworkManager().getBandwidthIn().getTotalBytes())); }