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