Search in sources :

Example 6 with TrackerPeerSource

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);
}
Also used : TrackerPeerSource(com.biglybt.core.tracker.TrackerPeerSource)

Example 7 with TrackerPeerSource

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);
}
Also used : TrackerPeerSource(com.biglybt.core.tracker.TrackerPeerSource)

Example 8 with TrackerPeerSource

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));
        }
    }
}
Also used : TrackerPeerSource(com.biglybt.core.tracker.TrackerPeerSource)

Example 9 with TrackerPeerSource

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);
    }
}
Also used : TrackerPeerSource(com.biglybt.core.tracker.TrackerPeerSource)

Example 10 with TrackerPeerSource

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);
        }
    });
}
Also used : TrackerPeerSource(com.biglybt.core.tracker.TrackerPeerSource) MessageBoxShell(com.biglybt.ui.swt.shells.MessageBoxShell)

Aggregations

TrackerPeerSource (com.biglybt.core.tracker.TrackerPeerSource)22 URL (java.net.URL)3 TrackerPeerSourceAdapter (com.biglybt.core.tracker.TrackerPeerSourceAdapter)2 TRTrackerScraperResponse (com.biglybt.core.tracker.client.TRTrackerScraperResponse)2 TOTorrent (com.biglybt.core.torrent.TOTorrent)1 TRTrackerAnnouncer (com.biglybt.core.tracker.client.TRTrackerAnnouncer)1 AERunnable (com.biglybt.core.util.AERunnable)1 PluginInterface (com.biglybt.pif.PluginInterface)1 Download (com.biglybt.pif.download.Download)1 DownloadImpl (com.biglybt.pifimpl.local.download.DownloadImpl)1 DHTPluginContact (com.biglybt.plugin.dht.DHTPluginContact)1 DHTPluginOperationListener (com.biglybt.plugin.dht.DHTPluginOperationListener)1 DHTPluginValue (com.biglybt.plugin.dht.DHTPluginValue)1 ExternalSeedPlugin (com.biglybt.plugin.extseed.ExternalSeedPlugin)1 SelectedContent (com.biglybt.ui.selectedcontent.SelectedContent)1 MultiTrackerEditor (com.biglybt.ui.swt.maketorrent.MultiTrackerEditor)1 TrackerEditorListener (com.biglybt.ui.swt.maketorrent.TrackerEditorListener)1 MessageBoxShell (com.biglybt.ui.swt.shells.MessageBoxShell)1 TableSelectedRowsListener (com.biglybt.ui.swt.views.table.TableSelectedRowsListener)1 InetSocketAddress (java.net.InetSocketAddress)1