Search in sources :

Example 41 with DownloadManager

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

the class TrackerNameItem method refresh.

@Override
public void refresh(TableCell cell) {
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    String name = "";
    if (dm != null && dm.getTorrent() != null) {
        TOTorrent torrent = dm.getTorrent();
        name = getTrackerName(torrent);
    }
    if (cell.setText(name) || !cell.isValid()) {
        TrackerCellUtils.updateColor(cell, dm, false);
    }
}
Also used : TOTorrent(com.biglybt.core.torrent.TOTorrent) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 42 with DownloadManager

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

the class TrackerNextAccessItem method cellHover.

@Override
public void cellHover(TableCell cell) {
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    cell.setToolTip(TrackerCellUtils.getTooltipText(cell, dm, false));
}
Also used : DownloadManager(com.biglybt.core.download.DownloadManager)

Example 43 with DownloadManager

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

the class TrackerStatusItem method cellHover.

@Override
public void cellHover(TableCell cell) {
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    cell.setToolTip(TrackerCellUtils.getTooltipText(cell, dm, true));
}
Also used : DownloadManager(com.biglybt.core.download.DownloadManager)

Example 44 with DownloadManager

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

the class UpSpeedLimitItem method refresh.

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

Example 45 with DownloadManager

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

the class StatusItem method refresh.

@Override
public void refresh(TableCell cell) {
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    if (dm == null) {
        return;
    }
    int state = dm.getState();
    long sort_value;
    String text;
    String tooltip = null;
    if (showTrackerErrors && dm.isUnauthorisedOnTracker() && state != DownloadManager.STATE_ERROR) {
        text = dm.getTrackerStatus();
        sort_value = 1100;
    } else {
        text = DisplayFormatters.formatDownloadStatus(dm);
        if (dm.isForceStart() && (state == DownloadManager.STATE_DOWNLOADING || state == DownloadManager.STATE_SEEDING)) {
            sort_value = 1000;
        } else {
            switch(state) {
                case DownloadManager.STATE_SEEDING:
                    {
                        sort_value = 900;
                        break;
                    }
                case DownloadManager.STATE_DOWNLOADING:
                    {
                        sort_value = 800;
                        break;
                    }
                case DownloadManager.STATE_QUEUED:
                    {
                        sort_value = 700;
                        tooltip = MessageText.getString("ManagerItem.queued.tooltip");
                        break;
                    }
                case DownloadManager.STATE_STOPPED:
                    {
                        if (dm.isPaused()) {
                            sort_value = 600;
                        } else {
                            sort_value = 500;
                        }
                        break;
                    }
                default:
                    {
                        sort_value = 0;
                    }
            }
        }
    }
    sort_value += state;
    sort_value <<= 32;
    if (dm.isDownloadComplete(false)) {
        Download dl = PluginCoreUtils.wrap(dm);
        if (dl != null) {
            sort_value += dl.getSeedingRank();
        }
    } else {
        sort_value -= dm.getPosition();
    }
    boolean update;
    if (priority_sort) {
        update = cell.setSortValue(sort_value);
        if (!update) {
            if (!cell.getText().equals(text)) {
                update = true;
            }
        }
    } else {
        update = cell.setSortValue(text);
    }
    if (update || !cell.isValid()) {
        cell.setText(text);
        cell.setToolTip(tooltip);
        boolean clickable = false;
        if (cell instanceof TableCellSWT) {
            int cursor_id;
            if (!text.contains("http://")) {
                dm.setUserData(CLICK_KEY, null);
                cursor_id = SWT.CURSOR_ARROW;
            } else {
                dm.setUserData(CLICK_KEY, text);
                cursor_id = SWT.CURSOR_HAND;
                clickable = true;
            }
            ((TableCellSWT) cell).setCursorID(cursor_id);
        }
        if (!changeCellFG && !changeRowFG) {
            // clickable, make it blue whatever
            cell.setForeground(clickable ? BLUE : null);
            return;
        }
        TableRow row = cell.getTableRow();
        if (row != null) {
            Color color = null;
            if (state == DownloadManager.STATE_SEEDING) {
                color = Colors.blues[Colors.BLUES_MIDDARK];
            } else if (state == DownloadManager.STATE_ERROR) {
                color = Colors.colorError;
            } else {
                color = null;
            }
            if (changeRowFG) {
                row.setForeground(Utils.colorToIntArray(color));
            } else if (changeCellFG) {
                cell.setForeground(Utils.colorToIntArray(color));
            }
            if (clickable) {
                cell.setForeground(Utils.colorToIntArray(Colors.blue));
            }
        }
    }
}
Also used : TableCellSWT(com.biglybt.ui.swt.views.table.TableCellSWT) Color(org.eclipse.swt.graphics.Color) DownloadManager(com.biglybt.core.download.DownloadManager) Download(com.biglybt.pif.download.Download)

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