use of com.biglybt.core.tracker.TrackerPeerSource in project BiglyBT by BiglySoftware.
the class ReportedUpItem method refresh.
@Override
public void refresh(TableCell cell) {
TrackerPeerSource ps = (TrackerPeerSource) cell.getDataSource();
long[] stats = (ps == null) ? null : ps.getReportedStats();
long sort;
String str;
if (stats != null) {
long gu = stats[0];
long uu = stats[2];
long su = stats[4];
sort = gu != 0 ? gu : (uu != 0 ? uu : su);
if (sort == 0) {
str = "";
} else {
if (uu > 0) {
str = DisplayFormatters.formatByteCountToKiBEtc(uu);
} else {
str = "";
}
if (gu != 0 && gu != uu) {
str = DisplayFormatters.formatByteCountToKiBEtc(gu) + (str.isEmpty() ? "" : ("/" + str));
}
if (su > 0) {
str += " (" + DisplayFormatters.formatByteCountToKiBEtc(su) + ")";
}
}
} else {
sort = -1;
str = "";
}
if (!cell.setSortValue(sort) && cell.isValid()) {
return;
}
cell.setText(str);
}
use of com.biglybt.core.tracker.TrackerPeerSource in project BiglyBT by BiglySoftware.
the class StatusItem method refresh.
@Override
public void refresh(TableCell cell) {
TrackerPeerSource ps = (TrackerPeerSource) cell.getDataSource();
int status;
if (ps == null) {
status = TrackerPeerSource.ST_UNKNOWN;
} else {
if (ps.isUpdating()) {
status = TrackerPeerSource.ST_UPDATING;
} else {
status = ps.getStatus();
}
}
String str = js_resources[status];
String extra = ps == null ? "" : ps.getStatusString();
if (status == TrackerPeerSource.ST_ONLINE) {
if (extra != null) {
int pos = extra.indexOf(" (");
if (pos != -1) {
str += extra.substring(pos);
}
}
} else if (status == TrackerPeerSource.ST_ERROR || status == TrackerPeerSource.ST_DISABLED || status == TrackerPeerSource.ST_STOPPED || status == TrackerPeerSource.ST_QUEUED) {
if (extra != null) {
str += ": " + extra;
}
}
if (!cell.setSortValue(str) && cell.isValid()) {
return;
}
cell.setText(str);
}
use of com.biglybt.core.tracker.TrackerPeerSource in project BiglyBT by BiglySoftware.
the class UpdateInItem method refresh.
@Override
public void refresh(TableCell cell) {
TrackerPeerSource ps = (TrackerPeerSource) cell.getDataSource();
boolean show_blank = false;
int secs;
if (ps == null) {
secs = -1;
} else {
int state = ps.getStatus();
if (state != TrackerPeerSource.ST_DISABLED && !ps.isUpdating()) {
secs = ps.getSecondsToUpdate();
if (secs == Integer.MIN_VALUE) {
show_blank = true;
}
} else {
secs = -1;
show_blank = true;
}
}
if (!cell.setSortValue(secs) && cell.isValid()) {
return;
}
if (show_blank) {
cell.setForeground(null);
cell.setText("");
} else {
if (secs >= -1) {
cell.setForeground(null);
// negative value render as blank, leave as 0
cell.setText(TimeFormatter.formatColon(secs < 0 ? 0 : secs));
} else {
// things are lagging, timer should have run already
cell.setForeground(secs < -5 ? Utils.colorToIntArray(Colors.colorWarning) : null);
cell.setText("-" + TimeFormatter.formatColon(-secs));
}
}
}
use of com.biglybt.core.tracker.TrackerPeerSource in project BiglyBT by BiglySoftware.
the class TrackerView method defaultSelected.
public void defaultSelected(TableRowCore[] rows, int stateMask) {
if (rows.length == 1) {
TrackerPeerSource source = (TrackerPeerSource) rows[0].getDataSource();
showInAllTrackers(source);
}
}
use of com.biglybt.core.tracker.TrackerPeerSource in project BiglyBT by BiglySoftware.
the class TrackerView method removeTrackerPeerSources.
private static void removeTrackerPeerSources(List<TrackerPeerSource> list) {
int numLeft = list.size();
if (numLeft == 0) {
return;
}
TrackerPeerSource toRemove = list.get(0);
if (toRemove == null) {
return;
}
MessageBoxShell mb = new MessageBoxShell(MessageText.getString("message.confirm.delete.title"), MessageText.getString("message.confirm.delete.text", new String[] { toRemove.getName() }), new String[] { MessageText.getString("Button.yes"), MessageText.getString("Button.no") }, 1);
if (numLeft > 1) {
String sDeleteAll = MessageText.getString("v3.deleteContent.applyToAll", new String[] { "" + numLeft });
mb.addCheckBox("!" + sDeleteAll + "!", Parameter.MODE_BEGINNER, false);
}
mb.setRememberOnlyIfButton(0);
mb.setRemember("removeTracker", false, MessageText.getString("MessageBoxWindow.nomoreprompting"));
mb.open(result -> {
if (result == -1) {
// cancel
return;
}
boolean remove = result == 0;
boolean doAll = mb.getCheckBoxEnabled();
if (doAll) {
if (remove) {
for (TrackerPeerSource tps : list) {
if (tps.canDelete()) {
tps.delete();
}
}
}
} else {
if (remove) {
toRemove.delete();
}
// Loop with remaining tags to be removed
list.remove(0);
removeTrackerPeerSources(list);
}
});
}
Aggregations