use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class NameItem method refresh.
@Override
public void refresh(TableCell cell, boolean sortOnlyRefresh) {
final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
String name = (fileInfo == null) ? "" : fileInfo.getFile(true).getName();
if (name == null)
name = "";
cell.setSortValue(name);
}
use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class PathItem method refresh.
@Override
public void refresh(TableCell cell) {
DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
cell.setText(determinePath(fileInfo, show_full_path));
}
use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class PathNameItem method refresh.
@Override
public void refresh(TableCell cell, boolean sortOnlyRefresh) {
final DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) cell.getDataSource();
String file_name = (fileInfo == null) ? "" : fileInfo.getFile(true).getName();
if (file_name == null)
file_name = "";
String file_path = PathItem.determinePath(fileInfo, show_full_path);
if (!file_path.isEmpty()) {
if (!file_path.endsWith(File.separator)) {
file_path += File.separator;
}
file_name = file_path + file_name;
}
// setText returns true only if the text is updated
if (cell.setText(file_name) || !cell.isValid()) {
if (bShowIcon && !sortOnlyRefresh) {
Image icon = null;
final TableCellSWT _cell = (TableCellSWT) cell;
if (fileInfo == null) {
icon = null;
} else {
if (Utils.isSWTThread()) {
icon = ImageRepository.getPathIcon(fileInfo.getFile(true).getPath(), cell.getHeight() > 32, false);
} else {
// happens rarely (seen of filtering of file-view rows
// when a new row is added )
Utils.execSWTThread(new Runnable() {
@Override
public void run() {
Image icon = ImageRepository.getPathIcon(fileInfo.getFile(true).getPath(), _cell.getHeight() > 32, false);
_cell.setIcon(icon);
_cell.redraw();
}
});
}
}
if (icon != null) {
_cell.setIcon(icon);
}
}
}
}
use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class AlertsItem method refresh.
@Override
public void refresh(TableCell cell) {
UISWTGraphic icon = null;
int sort = 0;
Object ds = cell.getDataSource();
if (ds instanceof DownloadManager) {
DownloadManager dm = (DownloadManager) ds;
Map<String, String> map = dm.getDownloadState().getMapAttribute(DownloadManagerState.AT_DL_FILE_ALERTS);
if (map != null && map.size() > 0) {
for (String k : map.keySet()) {
if (k.length() > 0) {
if (Character.isDigit(k.charAt(0))) {
icon = gray_tick_icon;
sort = 1;
} else {
icon = black_tick_icon;
sort = 2;
break;
}
}
}
}
} else if (ds instanceof DiskManagerFileInfo) {
DiskManagerFileInfo fi = (DiskManagerFileInfo) ds;
DownloadManager dm = fi.getDownloadManager();
if (dm != null) {
Map<String, String> map = dm.getDownloadState().getMapAttribute(DownloadManagerState.AT_DL_FILE_ALERTS);
if (map != null && map.size() > 0) {
String prefix = fi.getIndex() + ".";
for (String k : map.keySet()) {
if (k.startsWith(prefix)) {
icon = black_tick_icon;
sort = 2;
break;
}
}
}
}
}
cell.setSortValue(sort);
if (cell.getGraphic() != icon) {
cell.setGraphic(icon);
}
}
use of com.biglybt.core.disk.DiskManagerFileInfo in project BiglyBT by BiglySoftware.
the class FileExtensionItem method refresh.
@Override
public void refresh(TableCell cell) {
Object ds = cell.getDataSource();
String text = "";
DownloadManager dm;
if (ds instanceof DownloadManager) {
dm = (DownloadManager) ds;
DiskManagerFileInfo prim = dm.getDownloadState().getPrimaryFile();
text = prim == null ? "" : prim.getFile(true).getName();
} else if (ds instanceof DiskManagerFileInfo) {
DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
dm = fileInfo.getDownloadManager();
text = fileInfo.getFile(true).getName();
} else {
return;
}
String incomp_suffix = dm == null ? null : dm.getDownloadState().getAttribute(DownloadManagerState.AT_INCOMP_FILE_SUFFIX);
if (incomp_suffix != null && text.endsWith(incomp_suffix)) {
text = text.substring(0, text.length() - incomp_suffix.length());
}
int pos = text.lastIndexOf(".");
if (pos >= 0) {
text = text.substring(pos + 1);
} else {
text = "";
}
cell.setText(text);
}
Aggregations