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);
}
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);
}
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);
}
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));
}
}
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);
}
Aggregations