use of com.biglybt.core.download.DownloadManager 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.download.DownloadManager in project BiglyBT by BiglySoftware.
the class AvgAvailItem method refresh.
@Override
public void refresh(TableCell cell) {
String sText = "";
DownloadManager dm = (DownloadManager) cell.getDataSource();
if (dm == null)
return;
PEPeerManager pm = dm.getPeerManager();
if (pm != null) {
float f = pm.getAvgAvail();
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);
}
cell.setText(sText);
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class BadAvailTimeItem method refresh.
@Override
public void refresh(TableCell cell, long timestamp) {
DownloadManager dm = (DownloadManager) cell.getDataSource();
long value = dm == null ? -1 : dm.getStats().getAvailWentBadTime();
int seeds = 0;
if (value == 0) {
// zero means no recorded last bad availability time (bad=transition from >=1 -> < 1)
PEPeerManager pm = dm.getPeerManager();
if (pm == null || pm.getMinAvailability() < 1.0) {
long stopped = dm.getDownloadState().getLongAttribute(DownloadManagerState.AT_TIME_STOPPED);
if (stopped > 0) {
value = stopped;
} else {
value = -1;
}
} else {
seeds = pm.getNbSeeds();
value = -2;
}
}
if (value > 0) {
super.refresh(cell, value);
} else {
String text;
if (value == -2) {
if (dm.isDownloadComplete(false)) {
text = now_string;
value = Long.MAX_VALUE;
} else {
text = now_string + " " + seeds;
value = Long.MAX_VALUE - 1000000 + seeds;
}
} else {
text = "";
}
if (!cell.setSortValue(value) && cell.isValid()) {
return;
}
cell.setText(text);
}
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class DateLastActiveItem method refresh.
@Override
public void refresh(TableCell cell, long timestamp) {
DownloadManager dm = (DownloadManager) cell.getDataSource();
if (dm == null) {
timestamp = 0;
} else {
timestamp = dm.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_LAST_ACTIVE_TIME);
if (timestamp == 0) {
timestamp = dm.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_COMPLETED_TIME);
}
if (timestamp == 0) {
timestamp = dm.getDownloadState().getLongParameter(DownloadManagerState.PARAM_DOWNLOAD_ADDED_TIME);
}
}
super.refresh(cell, timestamp);
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class DescriptionItem method cellMouseTrigger.
@Override
public void cellMouseTrigger(TableCellMouseEvent event) {
DownloadManager dm = (DownloadManager) event.cell.getDataSource();
if (dm == null) {
return;
}
if (event.eventType != TableCellMouseEvent.EVENT_MOUSEUP) {
return;
}
// Only activate on LMB.
if (event.button != 1) {
return;
}
event.skipCoreFunctionality = true;
TorrentUtil.promptUserForDescription(new DownloadManager[] { dm });
refresh(event.cell);
}
Aggregations