public void cellHover(TableCell cell) { super.cellHover(cell); long lConnectedPeers = 0; DownloadManager dm = (DownloadManager) cell.getDataSource(); if (dm != null) { lConnectedPeers = dm.getNbPeers(); } String sToolTip = lConnectedPeers + " " + MessageText.getString("GeneralView.label.connected") + "\n"; if (lTotalPeers != -1) { sToolTip += lTotalPeers + " " + MessageText.getString("GeneralView.label.in_swarm"); } else { TRTrackerScraperResponse response = dm.getTrackerScrapeResponse(); sToolTip += "?? " + MessageText.getString("GeneralView.label.in_swarm"); if (response != null) sToolTip += "(" + response.getStatusString() + ")"; } int activationCount = dm == null ? 0 : dm.getActivationCount(); if (activationCount > 0) { sToolTip += "\n" + MessageText.getString( "PeerColumn.activationCount", new String[] {"" + activationCount}); } cell.setToolTip(sToolTip); }
public void refresh(TableCell cell) { super.refresh(cell); long lConnectedPeers = 0; if (dm != null) { lConnectedPeers = dm.getNbPeers(); if (lTotalPeers == -1) { TRTrackerScraperResponse response = dm.getTrackerScrapeResponse(); if (response != null && response.isValid()) { lTotalPeers = response.getPeers(); } } } long totalPeers = lTotalPeers; if (totalPeers <= 0) { DownloadManager dm = (DownloadManager) cell.getDataSource(); if (dm != null) { totalPeers = dm.getActivationCount(); } } long value = lConnectedPeers * 10000000; if (totalPeers > 0) value = value + totalPeers; if (!cell.setSortValue(value) && cell.isValid()) return; String tmp = String.valueOf(lConnectedPeers); if (totalPeers != -1) tmp += " (" + totalPeers + ")"; cell.setText(tmp); }
public void refresh(TableCell cell) { DownloadManager dm = (DownloadManager) cell.getDataSource(); long value = (dm == null) ? 0 : dm.getStats().getSecondsDownloading(); if (!cell.setSortValue(value) && cell.isValid()) return; cell.setText(TimeFormatter.format(value)); }
public void refresh(TableCell cell) { PEPeer peer = (PEPeer) cell.getDataSource(); long value = (peer == null) ? 0 : peer.getIncomingRequestCount(); if (!cell.setSortValue(value) && cell.isValid()) return; cell.setText("" + value); }
public void refresh(TableCell cell) { ClientStatsDataSource ds = (ClientStatsDataSource) cell.getDataSource(); if (ds == null) { return; } float val = ds.count * 1000f / ds.overall.count; if (cell.setSortValue(val) || !cell.isValid()) { cell.setText(DisplayFormatters.formatPercentFromThousands((int) val)); } }
// @see // org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener#refresh(org.gudy.azureus2.plugins.ui.tables.TableCell) public void refresh(TableCell cell) { VuzeActivitiesEntry entry = (VuzeActivitiesEntry) cell.getDataSource(); if (entry instanceof VuzeActivitiesEntryBuddy) { VuzeBuddy buddy = ((VuzeActivitiesEntryBuddy) entry).getBuddy(); cell.setSortValue(buddy == null ? null : buddy.getDisplayName()); } else { cell.setSortValue(null); } }
public void refresh(TableCell cell) { TRHostTorrent item = (TRHostTorrent) cell.getDataSource(); long value = (item == null) ? 0 : item.getAnnounceCount(); if (!cell.setSortValue(value) && cell.isValid()) { return; } cell.setText("" + value); }
public void refresh(TableCell cell) { PEPeer peer = (PEPeer) cell.getDataSource(); String addr = peer == null ? "" : peer.getIPHostName(); if (cell.setText(addr) && !addr.equals(peer.getIp())) { String[] l = addr.split("\\."); StringBuffer buf = new StringBuffer(); for (int i = l.length - 1; i >= 0; i--) { buf.append(l[i]); buf.append('.'); } cell.setSortValue(buf.toString()); } }
public void refresh(TableCell cell) { DownloadManager dm = (DownloadManager) cell.getDataSource(); long value = (dm == null) ? 0 : dm.getEffectiveUploadRateLimitBytesPerSecond(); if (!cell.setSortValue(value) && cell.isValid()) return; if (value == -1) { cell.setText(MessageText.getString("MyTorrents.items.UpSpeedLimit.disabled")); } else if (value == 0) { cell.setText(Constants.INFINITY_STRING); } else { cell.setText(DisplayFormatters.formatByteCountToKiBEtcPerSec(value)); } }
// @see // org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener#refresh(org.gudy.azureus2.plugins.ui.tables.TableCell) public void refresh(TableCell cell) { TableColumnCore column = (TableColumnCore) cell.getDataSource(); int colPos = column.getPosition(); // colPos can have gaps in numbers if (!cell.setSortValue(colPos) && cell.isValid()) { return; } String key = column.getTitleLanguageKey(); String s = MessageText.getString(key, column.getName()); // s = column.getPosition() + "] " + s; cell.setText(s); cell.setToolTip(""); }
public void refresh(TableCell cell) { DeviceOfflineDownload od = (DeviceOfflineDownload) cell.getDataSource(); if (od == null) { return; } String text = od.getDownload().getName(); if (text == null || text.length() == 0) { return; } cell.setText(text); }
// @see // org.gudy.azureus2.plugins.ui.tables.TableCellRefreshListener#refresh(org.gudy.azureus2.plugins.ui.tables.TableCell) public void refresh(TableCell cell) { VuzeActivitiesEntry entry = (VuzeActivitiesEntry) cell.getDataSource(); if (entry == null) return; if (!cell.setSortValue(entry.getTypeID()) && cell.isValid()) { return; } DownloadManager dm = entry.getDownloadManger(); boolean canPlay = PlayUtils.canPlayDS(entry, -1, false); boolean canDL = dm == null && entry.getDownloadManger() == null && (entry.getTorrent() != null || entry.getAssetHash() != null); boolean canRun = !canPlay && dm != null; if (canRun && dm != null && !dm.getAssumedComplete()) { canRun = false; } StringBuffer sb = new StringBuffer(); if (canDL) { if (sb.length() > 0) { sb.append(" | "); } sb.append("<A HREF=\"download\">Download</A>"); } if (canPlay) { if (sb.length() > 0) { sb.append(" | "); } sb.append("<A HREF=\"play\">Play</A>"); } if (canRun) { if (sb.length() > 0) { sb.append(", "); } sb.append("<A HREF=\"launch\">Launch</A>"); } cell.getTableRow().setData("text", sb.toString()); }
public void refresh(TableCell cell) { int average = -1; DownloadManager dm = (DownloadManager) cell.getDataSource(); if (dm != null) { PEPeerManager pm = dm.getPeerManager(); if (pm != null) { average = pm.getAverageCompletionInThousandNotation(); } } if (!cell.setSortValue(average) && cell.isValid()) { return; } if (average < 0) { cell.setText(""); } else { cell.setText(DisplayFormatters.formatPercentFromThousands(average)); } }
public void refresh(TableCell cell) { String sText = ""; DownloadManager dm = (DownloadManager) cell.getDataSource(); if (dm == null) return; PEPeerManager pm = dm.getPeerManager(); if (pm != null) { float f = pm.getAvgAvail(); if (!cell.setSortValue((long) (f * 1000)) && cell.isValid()) return; sText = String.valueOf((int) (f * iTimesBy)); if (numZeros - sText.length() > 0) sText = zeros.substring(0, numZeros - sText.length()) + sText; sText = sText.substring(0, sText.length() - numZeros + 1) + "." + sText.substring(sText.length() - numZeros + 1); } else { cell.setSortValue(0); } cell.setText(sText); }
public void refresh(TableCell cell, boolean sortOnly) { final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource(); int percentDone = 0; if (fileInfo != null && fileInfo.getLength() != 0) percentDone = (int) ((1000 * fileInfo.getDownloaded()) / fileInfo.getLength()); cell.setSortValue(percentDone); if (sortOnly) { dispose(cell); return; } // Compute bounds ... int newWidth = cell.getWidth(); if (newWidth <= 0) return; final int newHeight = cell.getHeight(); final int x1 = newWidth - borderWidth - 1; final int y1 = newHeight - borderWidth - 1; if (x1 < 10 || y1 < 3) return; final DiskManager manager = fileInfo.getDiskManager(); // we want to run through the image part once one the transition from with a disk manager // (running) // to without a disk manager (stopped) in order to clear the pieces view boolean running = manager != null; boolean hasGraphic = false; Graphic graphic = cell.getGraphic(); if (graphic instanceof UISWTGraphic) { Image img = ((UISWTGraphic) graphic).getImage(); hasGraphic = img != null && !img.isDisposed(); } final boolean bImageBufferValid = (lastPercentDone == percentDone) && cell.isValid() && bNoRed && running == was_running && hasGraphic; if (bImageBufferValid) return; was_running = running; lastPercentDone = percentDone; Image piecesImage = null; if (graphic instanceof UISWTGraphic) piecesImage = ((UISWTGraphic) graphic).getImage(); if (piecesImage != null && !piecesImage.isDisposed()) piecesImage.dispose(); if (!running) { cell.setGraphic(null); return; } piecesImage = new Image(SWTThread.getInstance().getDisplay(), newWidth, newHeight); final GC gcImage = new GC(piecesImage); // dm may be null if this is a skeleton file view DownloadManager download_manager = fileInfo.getDownloadManager(); PEPeerManager peer_manager = download_manager == null ? null : download_manager.getPeerManager(); PEPiece[] pe_pieces = peer_manager == null ? null : peer_manager.getPieces(); final long now = SystemTime.getCurrentTime(); if (fileInfo != null && manager != null) { if (percentDone == 1000) { gcImage.setForeground(Colors.blues[Colors.BLUES_DARKEST]); gcImage.setBackground(Colors.blues[Colors.BLUES_DARKEST]); gcImage.fillRectangle(1, 1, newWidth - 2, newHeight - 2); } else { final int firstPiece = fileInfo.getFirstPieceNumber(); final int nbPieces = fileInfo.getNbPieces(); final DiskManagerPiece[] dm_pieces = manager.getPieces(); bNoRed = true; for (int i = 0; i < newWidth; i++) { final int a0 = (i * nbPieces) / newWidth; int a1 = ((i + 1) * nbPieces) / newWidth; if (a1 == a0) a1++; if (a1 > nbPieces && nbPieces != 0) a1 = nbPieces; int nbAvailable = 0; boolean written = false; boolean partially_written = false; if (firstPiece >= 0) for (int j = a0; j < a1; j++) { final int this_index = j + firstPiece; final DiskManagerPiece dm_piece = dm_pieces[this_index]; if (dm_piece.isDone()) nbAvailable++; if (written) continue; if (pe_pieces != null) { PEPiece pe_piece = pe_pieces[this_index]; if (pe_piece != null) written = written || (pe_piece.getLastDownloadTime(now) + 500) > last_draw_time; } if ((!written) && (!partially_written)) { final boolean[] blocks = dm_piece.getWritten(); if (blocks != null) for (int k = 0; k < blocks.length; k++) if (blocks[k]) { partially_written = true; break; } } } // for j else nbAvailable = 1; gcImage.setBackground( written ? Colors.red : partially_written ? Colors.grey : Colors.blues[(nbAvailable * Colors.BLUES_DARKEST) / (a1 - a0)]); gcImage.fillRectangle(i, 1, 1, newHeight - 2); if (written) bNoRed = false; } gcImage.setForeground(Colors.grey); } } else gcImage.setForeground(Colors.grey); if (manager != null) gcImage.drawRectangle(0, 0, newWidth - 1, newHeight - 1); gcImage.dispose(); last_draw_time = now; if (cell instanceof TableCellSWT) ((TableCellSWT) cell).setGraphic(piecesImage); else cell.setGraphic(new UISWTGraphicImpl(piecesImage)); }