Search in sources :

Example 86 with DiskManagerFileInfo

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

the class DoneItem 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.getDownloaded();
    if (!cell.setSortValue(value) && cell.isValid()) {
        return;
    }
    // value < 0 -> unknown skeleton value
    String text;
    if (value < 0) {
        text = "";
    } else {
        text = DisplayFormatters.formatByteCountToKiBEtc(value);
        if (internal) {
        // text = "(" + text + ")";
        }
    }
    cell.setText(text);
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) FilesView(com.biglybt.ui.swt.views.FilesView)

Example 87 with DiskManagerFileInfo

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

the class FileAvailabilityItem method refresh.

@Override
public void refresh(TableCell cell) {
    String sText = "";
    DiskManagerFileInfo file = (DiskManagerFileInfo) cell.getDataSource();
    if (file == null)
        return;
    if (file.getLength() == 0) {
        sText = "-";
        cell.setSortValue(Long.MAX_VALUE);
    } else {
        DownloadManager dm = file.getDownloadManager();
        PEPeerManager pm = dm == null ? null : dm.getPeerManager();
        if (pm != null) {
            int index = file.getIndex();
            if (index >= 0) {
                float f = pm.getMinAvailability(index);
                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);
            }
        } else {
            cell.setSortValue(0);
        }
    }
    cell.setText(sText);
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) PEPeerManager(com.biglybt.core.peer.PEPeerManager) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 88 with DiskManagerFileInfo

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

the class FileHashItemBase method cellMouseTrigger.

@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
    DiskManagerFileInfo file = (DiskManagerFileInfo) event.cell.getDataSource();
    if (file == null) {
        return;
    }
    TableCellCore core_cell = (TableCellCore) event.cell;
    if (!event.cell.getText().startsWith("<")) {
        core_cell.setCursorID(SWT.CURSOR_ARROW);
        core_cell.setToolTip(null);
        return;
    }
    if (event.eventType == TableRowMouseEvent.EVENT_MOUSEENTER) {
        core_cell.setCursorID(SWT.CURSOR_HAND);
        core_cell.setToolTip(MessageText.getString("FilesView.click.info"));
    } else if (event.eventType == TableRowMouseEvent.EVENT_MOUSEEXIT) {
        core_cell.setCursorID(SWT.CURSOR_ARROW);
        core_cell.setToolTip(null);
    }
    if (event.eventType != TableCellMouseEvent.EVENT_MOUSEUP) {
        return;
    }
    if (event.button != 1) {
        return;
    }
    event.skipCoreFunctionality = true;
    updateHash(hash_type, file);
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) TableCellCore(com.biglybt.ui.common.table.TableCellCore)

Example 89 with DiskManagerFileInfo

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

the class FileIndexItem method refresh.

@Override
public void refresh(TableCell cell) {
    DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    int index = fileInfo == null ? -1 : fileInfo.getIndex();
    if (cell.setSortValue(index)) {
        cell.setText(index == -1 ? "" : String.valueOf(index));
    }
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo)

Example 90 with DiskManagerFileInfo

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

the class NameItem method cellPaintName.

private void cellPaintName(TableCell cell, GC gc, Rectangle cellBounds, int textX, int originalBoundxsX) {
    final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
    String name = (fileInfo == null) ? "" : fileInfo.getFile(true).getName();
    if (name == null) {
        name = "";
    }
    GCStringPrinter sp = new GCStringPrinter(gc, name, new Rectangle(textX, cellBounds.y, cellBounds.x + cellBounds.width - textX, cellBounds.height), true, true, getTableID().endsWith(".big") ? SWT.WRAP : SWT.NULL);
    boolean fit = sp.printString();
    Point p = sp.getCalculatedPreferredSize();
    int pref = (textX - originalBoundxsX) + p.x + 10;
    TableColumn tableColumn = cell.getTableColumn();
    if (tableColumn != null && tableColumn.getPreferredWidth() < pref) {
        tableColumn.setPreferredWidth(pref);
    }
    String tooltip = fit ? "" : name;
    cell.setToolTip(tooltip.length() == 0 ? null : tooltip);
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) GCStringPrinter(com.biglybt.ui.swt.shells.GCStringPrinter) Rectangle(org.eclipse.swt.graphics.Rectangle) Point(org.eclipse.swt.graphics.Point) Point(org.eclipse.swt.graphics.Point)

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