Search in sources :

Example 26 with DownloadManager

use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.

the class AlertsItem method refresh.

@Override
public void refresh(TableCell cell) {
    UISWTGraphic icon = null;
    int sort = 0;
    Object ds = cell.getDataSource();
    if (ds instanceof DownloadManager) {
        DownloadManager dm = (DownloadManager) ds;
        Map<String, String> map = dm.getDownloadState().getMapAttribute(DownloadManagerState.AT_DL_FILE_ALERTS);
        if (map != null && map.size() > 0) {
            for (String k : map.keySet()) {
                if (k.length() > 0) {
                    if (Character.isDigit(k.charAt(0))) {
                        icon = gray_tick_icon;
                        sort = 1;
                    } else {
                        icon = black_tick_icon;
                        sort = 2;
                        break;
                    }
                }
            }
        }
    } else if (ds instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo fi = (DiskManagerFileInfo) ds;
        DownloadManager dm = fi.getDownloadManager();
        if (dm != null) {
            Map<String, String> map = dm.getDownloadState().getMapAttribute(DownloadManagerState.AT_DL_FILE_ALERTS);
            if (map != null && map.size() > 0) {
                String prefix = fi.getIndex() + ".";
                for (String k : map.keySet()) {
                    if (k.startsWith(prefix)) {
                        icon = black_tick_icon;
                        sort = 2;
                        break;
                    }
                }
            }
        }
    }
    cell.setSortValue(sort);
    if (cell.getGraphic() != icon) {
        cell.setGraphic(icon);
    }
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) UISWTGraphic(com.biglybt.ui.swt.pif.UISWTGraphic) DownloadManager(com.biglybt.core.download.DownloadManager) Map(java.util.Map)

Example 27 with DownloadManager

use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.

the class AvgAvailItem method refresh.

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

Example 28 with DownloadManager

use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.

the class BadAvailTimeItem method refresh.

@Override
public void refresh(TableCell cell, long timestamp) {
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    long value = dm == null ? -1 : dm.getStats().getAvailWentBadTime();
    int seeds = 0;
    if (value == 0) {
        // zero means no recorded last bad availability time (bad=transition from >=1 -> < 1)
        PEPeerManager pm = dm.getPeerManager();
        if (pm == null || pm.getMinAvailability() < 1.0) {
            long stopped = dm.getDownloadState().getLongAttribute(DownloadManagerState.AT_TIME_STOPPED);
            if (stopped > 0) {
                value = stopped;
            } else {
                value = -1;
            }
        } else {
            seeds = pm.getNbSeeds();
            value = -2;
        }
    }
    if (value > 0) {
        super.refresh(cell, value);
    } else {
        String text;
        if (value == -2) {
            if (dm.isDownloadComplete(false)) {
                text = now_string;
                value = Long.MAX_VALUE;
            } else {
                text = now_string + " " + seeds;
                value = Long.MAX_VALUE - 1000000 + seeds;
            }
        } else {
            text = "";
        }
        if (!cell.setSortValue(value) && cell.isValid()) {
            return;
        }
        cell.setText(text);
    }
}
Also used : PEPeerManager(com.biglybt.core.peer.PEPeerManager) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 29 with DownloadManager

use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.

the class DateLastActiveItem method refresh.

@Override
public void refresh(TableCell cell, long timestamp) {
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    if (dm == null) {
        timestamp = 0;
    } else {
        timestamp = dm.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_LAST_ACTIVE_TIME);
        if (timestamp == 0) {
            timestamp = dm.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_COMPLETED_TIME);
        }
        if (timestamp == 0) {
            timestamp = dm.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME);
        }
    }
    super.refresh(cell, timestamp);
}
Also used : DownloadManager(com.biglybt.core.download.DownloadManager)

Example 30 with DownloadManager

use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.

the class DescriptionItem method cellMouseTrigger.

@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
    DownloadManager dm = (DownloadManager) event.cell.getDataSource();
    if (dm == null) {
        return;
    }
    if (event.eventType != TableCellMouseEvent.EVENT_MOUSEUP) {
        return;
    }
    // Only activate on LMB.
    if (event.button != 1) {
        return;
    }
    event.skipCoreFunctionality = true;
    TorrentUtil.promptUserForDescription(new DownloadManager[] { dm });
    refresh(event.cell);
}
Also used : DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

DownloadManager (com.biglybt.core.download.DownloadManager)307 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)54 TOTorrent (com.biglybt.core.torrent.TOTorrent)35 GlobalManager (com.biglybt.core.global.GlobalManager)33 PEPeerManager (com.biglybt.core.peer.PEPeerManager)29 File (java.io.File)29 List (java.util.List)21 Core (com.biglybt.core.Core)17 Download (com.biglybt.pif.download.Download)17 Point (org.eclipse.swt.graphics.Point)17 UIFunctions (com.biglybt.ui.UIFunctions)16 Tag (com.biglybt.core.tag.Tag)15 UIInputReceiverListener (com.biglybt.pif.ui.UIInputReceiverListener)14 TOTorrentException (com.biglybt.core.torrent.TOTorrentException)13 ArrayList (java.util.ArrayList)13 DiskManager (com.biglybt.core.disk.DiskManager)12 DownloadManagerStats (com.biglybt.core.download.DownloadManagerStats)12 CoreRunningListener (com.biglybt.core.CoreRunningListener)11 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)11 PEPeer (com.biglybt.core.peer.PEPeer)11