Search in sources :

Example 11 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class PriorityItem method refresh.

@Override
public void refresh(TableCell cell) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    String tmp;
    int sortval = 0;
    if (fileInfo == null) {
        tmp = "";
    } else {
        int st = fileInfo.getStorageType();
        if (st < 0) {
            tmp = "";
            sortval = Integer.MIN_VALUE;
        } else if ((st == DiskManagerFileInfo.ST_COMPACT || st == DiskManagerFileInfo.ST_REORDER_COMPACT) && fileInfo.isSkipped()) {
            tmp = MessageText.getString("FileItem.delete");
            sortval = Integer.MIN_VALUE + 1;
        } else if (fileInfo.isSkipped()) {
            tmp = MessageText.getString("FileItem.donotdownload");
            sortval = Integer.MIN_VALUE + 2;
        } else {
            int pri = fileInfo.getPriority();
            sortval = pri;
            if (pri > 0) {
                tmp = MessageText.getString("FileItem.high");
                if (pri > 1) {
                    tmp += " (" + pri + ")";
                }
            } else if (pri < 0) {
                tmp = MessageText.getString("FileItem.low");
                if (pri < -1) {
                    tmp += " (" + pri + ")";
                }
            } else {
                tmp = MessageText.getString("FileItem.normal");
            }
        }
    }
    cell.setText(tmp);
    cell.setSortValue(sortval);
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo)

Example 12 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class RelocatedItem method refresh.

@Override
public void refresh(TableCell cell) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    boolean relocated;
    if (fileInfo == null) {
        relocated = false;
    } else {
        File source = fileInfo.getFile(false);
        int index = fileInfo.getIndex();
        if (index < 0) {
            relocated = false;
        } else {
            File target = fileInfo.getDownloadManager().getDownloadState().getFileLink(index, source);
            if (target == null) {
                relocated = false;
            } else {
                if (target == source) {
                    relocated = false;
                } else {
                    relocated = !target.equals(source);
                }
            }
        }
    }
    if (!cell.setSortValue(relocated ? 1 : 0) && cell.isValid()) {
        return;
    }
    String text = relocated ? "*" : "";
    cell.setText(text);
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) File(java.io.File)

Example 13 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class RemainingPiecesItem method refresh.

@Override
public void refresh(TableCell cell) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    // dm may be null if this is a skeleton file view
    DiskManager dm = fileInfo == null ? null : fileInfo.getDiskManager();
    int remaining = 0;
    if (fileInfo != null && dm != null) {
        if (fileInfo instanceof FilesView.FilesViewTreeNode && !((FilesView.FilesViewTreeNode) fileInfo).isLeaf()) {
            remaining = -1;
        } else {
            int start = fileInfo.getFirstPieceNumber();
            int end = start + fileInfo.getNbPieces();
            DiskManagerPiece[] pieces = dm.getPieces();
            for (int i = start; i < end; i++) {
                if (!pieces[i].isDone())
                    remaining++;
            }
        }
    } else {
        // unknown
        remaining = -1;
    }
    if (!cell.setSortValue(remaining) && cell.isValid()) {
        return;
    }
    cell.setText("" + (remaining < 0 ? "" : ("" + remaining)));
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) FilesView(com.biglybt.ui.swt.views.FilesView) DiskManagerPiece(com.biglybt.core.disk.DiskManagerPiece) DiskManager(com.biglybt.core.disk.DiskManager)

Example 14 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class SizeItem method refresh.

@Override
public void refresh(TableCell cell) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    boolean internal = fileInfo instanceof FilesView.FilesViewTreeNode && !((FilesView.FilesViewTreeNode) fileInfo).isLeaf();
    long value = (fileInfo == null) ? 0 : fileInfo.getLength();
    if (!cell.setSortValue(value) && cell.isValid()) {
        return;
    }
    String text;
    if (value < 0) {
        text = "";
    } else {
        text = DisplayFormatters.formatByteCountToKiBEtc(value);
        if (internal) {
        // text = "(" + text + ")";
        }
    }
    cell.setText(text);
    if (Utils.getUserMode() > 0 && (cell instanceof TableCellSWT)) {
        if (value >= 0x40000000l) {
            ((TableCellSWT) cell).setTextAlpha(200 | 0x100);
        } else if (value < 0x100000) {
            ((TableCellSWT) cell).setTextAlpha(180);
        } else {
            ((TableCellSWT) cell).setTextAlpha(255);
        }
    }
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) TableCellSWT(com.biglybt.ui.swt.views.table.TableCellSWT) FilesView(com.biglybt.ui.swt.views.FilesView)

Example 15 with DiskManagerFileInfo

use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.

the class TorrentRelativePathItem method refresh.

@Override
public void refresh(TableCell cell) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    TOTorrentFile torrentFile = fileInfo == null ? null : fileInfo.getTorrentFile();
    cell.setText(torrentFile == null ? "" : torrentFile.getRelativePath());
}
Also used : TOTorrentFile(com.biglybt.core.torrent.TOTorrentFile) DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo)

Aggregations

DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)107 DownloadManager (com.biglybt.core.download.DownloadManager)54 File (java.io.File)16 TOTorrent (com.biglybt.core.torrent.TOTorrent)15 PEPeerManager (com.biglybt.core.peer.PEPeerManager)9 DiskManagerFileInfoSet (com.biglybt.core.disk.DiskManagerFileInfoSet)8 TableRowCore (com.biglybt.ui.common.table.TableRowCore)8 DiskManager (com.biglybt.core.disk.DiskManager)7 IOException (java.io.IOException)7 Point (org.eclipse.swt.graphics.Point)7 DownloadManagerState (com.biglybt.core.download.DownloadManagerState)6 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)6 FilesView (com.biglybt.ui.swt.views.FilesView)6 List (java.util.List)6 Image (org.eclipse.swt.graphics.Image)6 DiskManagerPiece (com.biglybt.core.disk.DiskManagerPiece)5 PEPeer (com.biglybt.core.peer.PEPeer)5 TOTorrentException (com.biglybt.core.torrent.TOTorrentException)5 UIFunctions (com.biglybt.ui.UIFunctions)5 ISelectedContent (com.biglybt.ui.selectedcontent.ISelectedContent)5