Search in sources :

Example 11 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class IncomingRequestCountItem method refresh.

@Override
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);
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Example 12 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class IpItem method refresh.

@Override
public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    String sText = (peer == null) ? "" : peer.getIp();
    if (cell.setText(sText) || !cell.isValid()) {
        String[] sBlocks = sText.split("\\.");
        if (sBlocks.length == 4) {
            try {
                long l = (Long.parseLong(sBlocks[0]) << 24) + (Long.parseLong(sBlocks[1]) << 16) + (Long.parseLong(sBlocks[2]) << 8) + Long.parseLong(sBlocks[3]);
                cell.setSortValue(l);
            } catch (Exception e) {
                e.printStackTrace();
            /* ignore */
            }
        }
    }
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Example 13 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class PiecesItem method dispose.

@Override
public void dispose(TableCell cell) {
    synchronized (this) {
        row_count--;
    }
    // Named infoObj so code can be copied easily to the other PiecesItem
    final List<Image> to_dispose = new ArrayList<>();
    PEPeer infoObj = (PEPeer) cell.getDataSource();
    if (infoObj != null) {
        Image img = (Image) infoObj.getData("PiecesImage");
        if (img != null) {
            to_dispose.add(img);
        }
        infoObj.setData("PiecesImageBuffer", null);
        infoObj.setData("PiecesImage", null);
    }
    Graphic graphic = cell.getGraphic();
    if (graphic instanceof UISWTGraphic) {
        Image img = ((UISWTGraphic) graphic).getImage();
        if (img != null && to_dispose.contains(img)) {
            to_dispose.add(img);
        }
    }
    if (to_dispose.size() > 0) {
        Utils.execSWTThread(new AERunnable() {

            @Override
            public void runSupport() {
                for (Image img : to_dispose) {
                    if (!img.isDisposed()) {
                        img.dispose();
                    }
                }
            }
        });
    }
}
Also used : AERunnable(com.biglybt.core.util.AERunnable) PEPeer(com.biglybt.core.peer.PEPeer) Graphic(com.biglybt.pif.ui.Graphic) UISWTGraphic(com.biglybt.ui.swt.pif.UISWTGraphic) ArrayList(java.util.ArrayList) UISWTGraphic(com.biglybt.ui.swt.pif.UISWTGraphic) Image(org.eclipse.swt.graphics.Image)

Example 14 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class ProtocolItem method refresh.

@Override
public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    String value;
    if (peer == null) {
        value = "";
    } else {
        value = peer.getProtocol();
        String qualifier = peer.getProtocolQualifier();
        if (qualifier != null) {
            value += " (" + qualifier + ")";
        }
    }
    if (!cell.setSortValue(value) && cell.isValid())
        return;
    cell.setText(value);
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Example 15 with PEPeer

use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.

the class TotalDownSpeedItem method refresh.

@Override
public void refresh(TableCell cell) {
    PEPeer peer = (PEPeer) cell.getDataSource();
    long value = (peer == null) ? 0 : peer.getStats().getEstimatedDownloadRateOfPeer();
    if (!cell.setSortValue(value) && cell.isValid())
        return;
    cell.setText(DisplayFormatters.formatByteCountToKiBEtcPerSec(value));
}
Also used : PEPeer(com.biglybt.core.peer.PEPeer)

Aggregations

PEPeer (com.biglybt.core.peer.PEPeer)84 PEPeerManager (com.biglybt.core.peer.PEPeerManager)18 DownloadManager (com.biglybt.core.download.DownloadManager)11 ArrayList (java.util.ArrayList)11 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)5 AERunnable (com.biglybt.core.util.AERunnable)5 PEPiece (com.biglybt.core.peer.PEPiece)4 List (java.util.List)4 Image (org.eclipse.swt.graphics.Image)4 DiskManager (com.biglybt.core.disk.DiskManager)3 GlobalManager (com.biglybt.core.global.GlobalManager)3 PEPeerStats (com.biglybt.core.peer.PEPeerStats)3 PEPeerTransport (com.biglybt.core.peer.impl.PEPeerTransport)3 TOTorrent (com.biglybt.core.torrent.TOTorrent)3 Point (org.eclipse.swt.graphics.Point)3 DiskManagerPiece (com.biglybt.core.disk.DiskManagerPiece)2 DownloadManagerPeerListener (com.biglybt.core.download.DownloadManagerPeerListener)2 PiecePicker (com.biglybt.core.peermanager.piecepicker.PiecePicker)2 BitFlags (com.biglybt.core.peermanager.piecepicker.util.BitFlags)2 Tag (com.biglybt.core.tag.Tag)2