Search in sources :

Example 11 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class StatsWriterImpl method writeSupport.

protected void writeSupport() {
    writeLineRaw("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    boolean export_peer_stats = COConfigurationManager.getBooleanParameter("Stats Export Peer Details");
    boolean export_file_stats = COConfigurationManager.getBooleanParameter("Stats Export File Details");
    String xsl = COConfigurationManager.getStringParameter("Stats XSL File");
    if (xsl.length() > 0) {
        writeLineRaw("<?xml-stylesheet type=\"text/xsl\" href=\"" + xsl + "\"?>");
    }
    writeLineRaw("<STATS>");
    GlobalManager global = core.getGlobalManager();
    try {
        indent();
        writeTag("AZUREUS_VERSION", Constants.AZUREUS_VERSION);
        writeLineRaw("<GLOBAL>");
        try {
            indent();
            GlobalManagerStats gm_stats = global.getStats();
            writeRawCookedAverageTag("DOWNLOAD_SPEED", gm_stats.getDataReceiveRate() + gm_stats.getProtocolReceiveRate());
            writeRawCookedAverageTag("UPLOAD_SPEED", gm_stats.getDataSendRate() + gm_stats.getProtocolSendRate());
        } finally {
            exdent();
        }
        writeLineRaw("</GLOBAL>");
        writeLineRaw("<DOWNLOADS>");
        try {
            indent();
            List _dms = global.getDownloadManagers();
            DownloadManager[] dms = new DownloadManager[_dms.size()];
            // sort by position, downloads then seeders
            _dms.toArray(dms);
            Arrays.sort(dms, new Comparator() {

                @Override
                public int compare(Object o1, Object o2) {
                    DownloadManager d1 = (DownloadManager) o1;
                    DownloadManager d2 = (DownloadManager) o2;
                    int d1_index = d1.getPosition();
                    int d2_index = d2.getPosition();
                    if (d1.isDownloadComplete(false)) {
                        d1_index += 1000000;
                    }
                    if (d2.isDownloadComplete(false)) {
                        d2_index += 1000000;
                    }
                    return (d1_index - d2_index);
                }
            });
            for (int i = 0; i < dms.length; i++) {
                DownloadManager dm = (DownloadManager) dms[i];
                DownloadManagerStats dm_stats = dm.getStats();
                writeLineRaw("<DOWNLOAD>");
                try {
                    indent();
                    writeLineRaw("<TORRENT>");
                    // torrent can be null if broken torrent!
                    TOTorrent torrent = dm.getTorrent();
                    try {
                        indent();
                        writeTag("NAME", dm.getDisplayName());
                        writeTag("TORRENT_FILE", dm.getTorrentFileName());
                        if (torrent != null) {
                            writeTag("HASH", TorrentUtils.nicePrintTorrentHash(torrent, true));
                            writeRawCookedTag("SIZE", torrent.getSize());
                            writeTag("PIECE_LENGTH", torrent.getPieceLength());
                            writeTag("PIECE_COUNT", torrent.getNumberOfPieces());
                            writeTag("FILE_COUNT", torrent.getFiles().length);
                            writeTag("COMMENT", dm.getTorrentComment());
                            writeTag("CREATED_BY", dm.getTorrentCreatedBy());
                            writeTag("CREATION_DATE", torrent.getCreationDate());
                        }
                    } finally {
                        exdent();
                    }
                    writeLineRaw("</TORRENT>");
                    writeTag("DOWNLOAD_STATUS", DisplayFormatters.formatDownloadStatusDefaultLocale(dm));
                    writeTag("DOWNLOAD_DIR", dm.getSaveLocation().toString());
                    if (torrent != null) {
                        if (torrent.isSimpleTorrent()) {
                            writeTag("TARGET_FILE", dm.getSaveLocation().toString());
                        } else {
                            writeTag("TARGET_DIR", dm.getSaveLocation().toString());
                        }
                    }
                    writeTag("TRACKER_STATUS", dm.getTrackerStatus());
                    writeTag("COMPLETED", dm_stats.getCompleted());
                    writeTag("NON_DND_COMPLETED", dm.isDownloadComplete(false));
                    writeRawCookedTag("DOWNLOADED", dm_stats.getTotalDataBytesReceived());
                    writeRawCookedTag("UPLOADED", dm_stats.getTotalDataBytesSent());
                    writeRawCookedTag("DISCARDED", dm_stats.getDiscarded());
                    writeRawCookedAverageTag("DOWNLOAD_SPEED", dm_stats.getDataReceiveRate());
                    writeRawCookedAverageTag("UPLOAD_SPEED", dm_stats.getDataSendRate());
                    writeRawCookedAverageTag("TOTAL_SPEED", dm_stats.getTotalAverage());
                    writeRawCookedAverageTag("DOWNLOAD_SPEED_SMOOTH", dm_stats.getSmoothedDataReceiveRate());
                    writeRawCookedAverageTag("UPLOAD_SPEED_SMOOTH", dm_stats.getSmoothedDataSendRate());
                    writeTag("ELAPSED", dm_stats.getElapsedTime());
                    writeTag("ETA", DisplayFormatters.formatETA(dm_stats.getSmoothedETA()));
                    writeTag("HASH_FAILS", dm_stats.getHashFailCount());
                    writeTag("SHARE_RATIO", dm_stats.getShareRatio());
                    writeTag("TOTAL_SEEDS", dm.getNbSeeds());
                    writeTag("TOTAL_LEECHERS", dm.getNbPeers());
                    if (export_file_stats) {
                        try {
                            writeLineRaw("<FILES>");
                            indent();
                            DiskManagerFileInfo[] files = dm.getDiskManagerFileInfo();
                            for (int j = 0; j < files.length; j++) {
                                DiskManagerFileInfo file = files[j];
                                try {
                                    writeLineRaw("<FILE>");
                                    indent();
                                    writeTag("NAME", file.getTorrentFile().getRelativePath());
                                    writeTag("DND", file.isSkipped());
                                    writeRawCookedTag("SIZE", file.getLength());
                                    writeRawCookedTag("DOWNLOADED", file.getDownloaded());
                                } finally {
                                    exdent();
                                    writeLineRaw("</FILE>");
                                }
                            }
                        } finally {
                            exdent();
                            writeLineRaw("</FILES>");
                        }
                    }
                    if (export_peer_stats) {
                        try {
                            writeLineRaw("<PEERS>");
                            indent();
                            PEPeerManager pm = dm.getPeerManager();
                            if (pm != null) {
                                List peers = pm.getPeers();
                                for (int j = 0; j < peers.size(); j++) {
                                    PEPeer peer = (PEPeer) peers.get(j);
                                    PEPeerStats peer_stats = peer.getStats();
                                    byte[] id = peer.getId();
                                    if (id == null) {
                                        continue;
                                    }
                                    try {
                                        String peer_id = PeerClassifier.getPrintablePeerID(id);
                                        peer_id = escapeXML(peer_id);
                                        String type = escapeXML(peer.getClient());
                                        writeLineRaw("<PEER hex_id=\"" + ByteFormatter.encodeString(id) + "\" printable_id=\"" + peer_id + "\" type=\"" + type + "\">");
                                        indent();
                                        writeTag("IP", peer.getIp());
                                        writeTag("IS_SEED", peer.isSeed());
                                        writeRawCookedTag("DOWNLOADED", peer_stats.getTotalDataBytesReceived());
                                        writeRawCookedTag("UPLOADED", peer_stats.getTotalDataBytesSent());
                                        writeRawCookedAverageTag("DOWNLOAD_SPEED", peer_stats.getDataReceiveRate());
                                        writeRawCookedAverageTag("UPLOAD_SPEED", peer_stats.getDataSendRate());
                                    } catch (Throwable e) {
                                        Debug.printStackTrace(e);
                                    } finally {
                                        exdent();
                                        writeLineRaw("</PEER>");
                                    }
                                }
                            }
                        } finally {
                            exdent();
                            writeLineRaw("</PEERS>");
                        }
                    }
                } finally {
                    exdent();
                }
                writeLineRaw("</DOWNLOAD>");
            }
        } finally {
            exdent();
        }
        writeLineRaw("</DOWNLOADS>");
    } finally {
        exdent();
    }
    writeLineRaw("</STATS>");
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) PEPeer(com.biglybt.core.peer.PEPeer) GlobalManagerStats(com.biglybt.core.global.GlobalManagerStats) PEPeerStats(com.biglybt.core.peer.PEPeerStats) DownloadManager(com.biglybt.core.download.DownloadManager) Comparator(java.util.Comparator) GlobalManager(com.biglybt.core.global.GlobalManager) TOTorrent(com.biglybt.core.torrent.TOTorrent) List(java.util.List) PEPeerManager(com.biglybt.core.peer.PEPeerManager) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats)

Example 12 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class ShareRatioProgressItem method refresh.

@Override
public void refresh(TableCell cell, long timestamp) {
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    if (dm == null || existing_sr <= 0) {
        super.refresh(cell, 0);
        return;
    }
    int dm_state = dm.getState();
    long next_eta = -1;
    if (dm_state == DownloadManager.STATE_DOWNLOADING || dm_state == DownloadManager.STATE_SEEDING) {
        DownloadManagerStats stats = dm.getStats();
        long downloaded = stats.getTotalGoodDataBytesReceived();
        long uploaded = stats.getTotalDataBytesSent();
        if (downloaded <= 0) {
            next_eta = -2;
        } else {
            int current_sr = (int) ((1000 * uploaded) / downloaded);
            int mult = current_sr / existing_sr;
            int next_target_sr = (mult + 1) * existing_sr;
            long up_speed = stats.getDataSendRate() == 0 ? 0 : stats.getSmoothedDataSendRate();
            if (up_speed <= 0) {
                next_eta = -2;
            } else {
                if (dm_state == DownloadManager.STATE_SEEDING) {
                    // simple case
                    long target_upload = (next_target_sr * downloaded) / 1000;
                    next_eta = (target_upload - uploaded) / up_speed;
                } else {
                    // more complex when downloading as we have to consider the fact that
                    // at some point the download will complete and therefore download speed will
                    // drop to 0
                    DiskManager disk_man = dm.getDiskManager();
                    if (disk_man != null) {
                        long remaining = disk_man.getRemainingExcludingDND();
                        long down_speed = (dm_state == DownloadManager.STATE_SEEDING || stats.getDataReceiveRate() == 0) ? 0 : stats.getSmoothedDataReceiveRate();
                        if (down_speed <= 0 || remaining <= 0) {
                            // same as if we are just seeding
                            long target_upload = (next_target_sr * downloaded) / 1000;
                            next_eta = (target_upload - uploaded) / up_speed;
                        } else {
                            /*
								 	time T until the target share ration is met is

								  		uploaded + ( T * upload_speed )
										------------------------------          = target_sr
										downloaded + ( T * download_speed )
								*/
                            long time_to_sr = ((next_target_sr * downloaded) / 1000 - uploaded) / (up_speed - (down_speed * next_target_sr) / 1000);
                            long time_to_completion = remaining / down_speed;
                            if (time_to_sr > 0 && time_to_sr <= time_to_completion) {
                                next_eta = time_to_sr;
                            } else {
                                // basic calculation shows eta is > download complete time so we need
                                // to refactor things
                                long uploaded_at_completion = uploaded + (up_speed * time_to_completion);
                                long downloaded_at_completion = downloaded + (down_speed * time_to_completion);
                                // usual seeding calculation for time after completion
                                long target_upload = (next_target_sr * downloaded_at_completion) / 1000;
                                next_eta = time_to_completion + (target_upload - uploaded_at_completion) / up_speed;
                            }
                        }
                    } else {
                        next_eta = -2;
                    }
                }
            }
        }
    }
    long data = dm.getDownloadState().getLongAttribute(DownloadManagerState.AT_SHARE_RATIO_PROGRESS);
    long sr = (int) data;
    String sr_str = DisplayFormatters.formatDecimal((double) sr / 1000, 3);
    timestamp = (data >>> 32) * 1000;
    // feed a bit of share ratio/next eta into sort order for fun and to ensure refresh occurs when they change
    long sort_order = timestamp;
    sort_order += (sr & 0xff) << 8;
    sort_order += (next_eta & 0xff);
    String next_eta_str;
    if (next_eta == -1) {
        next_eta_str = "";
    } else if (next_eta == -2) {
        next_eta_str = Constants.INFINITY_STRING + ": ";
    } else {
        next_eta_str = DisplayFormatters.formatETA(next_eta) + ": ";
    }
    String prefix = next_eta_str + sr_str + (timestamp > 0 ? ": " : "");
    super.refresh(cell, timestamp, sort_order, prefix);
}
Also used : DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats) DiskManager(com.biglybt.core.disk.DiskManager) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 13 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class MyTorrentsView method buildCatAndTag.

/**
 * @since 3.1.1.1
 */
private void buildCatAndTag(List<Tag> tags) {
    if (tags.size() == 0 || cCategoriesAndTags.isDisposed()) {
        return;
    }
    int iFontPixelsHeight = Utils.adjustPXForDPI(10);
    int iFontPointHeight = (iFontPixelsHeight * 72) / Utils.getDPIRaw(cCategoriesAndTags.getDisplay()).y;
    Label spacer = null;
    int max_rd_height = 0;
    allTags = tags;
    if (buttonListener == null) {
        buttonListener = new Listener() {

            boolean bDownPressed;

            private TimerEvent timerEvent;

            @Override
            public void handleEvent(Event event) {
                Button curButton = (Button) event.widget;
                if (event.type == SWT.MouseDown) {
                    if (timerEvent == null) {
                        timerEvent = SimpleTimer.addEvent("MouseHold", SystemTime.getOffsetTime(1000), new TimerEventPerformer() {

                            @Override
                            public void perform(TimerEvent te) {
                                timerEvent = null;
                                if (!bDownPressed) {
                                    return;
                                }
                                bDownPressed = false;
                                // held
                                Utils.execSWTThread(new Runnable() {

                                    public void run() {
                                        Object[] ds = tv.getSelectedDataSources().toArray();
                                        Tag tag = (Tag) curButton.getData("Tag");
                                        if (tag instanceof Category) {
                                            TorrentUtil.assignToCategory(ds, (Category) tag);
                                            return;
                                        }
                                        boolean doAdd = false;
                                        for (Object obj : ds) {
                                            if (obj instanceof DownloadManager) {
                                                DownloadManager dm = (DownloadManager) obj;
                                                if (!tag.hasTaggable(dm)) {
                                                    doAdd = true;
                                                    break;
                                                }
                                            }
                                        }
                                        for (Object obj : ds) {
                                            if (obj instanceof DownloadManager) {
                                                DownloadManager dm = (DownloadManager) obj;
                                                if (doAdd) {
                                                    tag.addTaggable(dm);
                                                } else {
                                                    tag.removeTaggable(dm);
                                                }
                                            }
                                        }
                                        setSelection(curButton.getParent());
                                        curButton.setEnabled(false);
                                        SimpleTimer.addEvent("ButtonEnable", SystemTime.getOffsetTime(10), new TimerEventPerformer() {

                                            @Override
                                            public void perform(TimerEvent te) {
                                                Utils.execSWTThread(new Runnable() {

                                                    public void run() {
                                                        curButton.setEnabled(true);
                                                    }
                                                });
                                            }
                                        });
                                    }
                                });
                            }
                        });
                    }
                    bDownPressed = true;
                    return;
                } else {
                    if (timerEvent != null) {
                        timerEvent.cancel();
                        timerEvent = null;
                    }
                    if (!bDownPressed) {
                        setSelection(curButton.getParent());
                        return;
                    }
                }
                bDownPressed = false;
                boolean add = (event.stateMask & SWT.MOD1) != 0;
                boolean isEnabled = curButton.getSelection();
                Tag tag = (Tag) curButton.getData("Tag");
                if (!isEnabled) {
                    removeTagFromCurrent(tag);
                } else {
                    if (add) {
                        Category catAll = CategoryManager.getCategory(Category.TYPE_ALL);
                        if (tag.equals(catAll)) {
                            setCurrentTags(new Tag[] { catAll });
                        } else {
                            Tag[] newTags = new Tag[currentTags.length + 1];
                            System.arraycopy(currentTags, 0, newTags, 0, currentTags.length);
                            newTags[currentTags.length] = tag;
                            newTags = (Tag[]) removeFromArray(newTags, catAll);
                            setCurrentTags(newTags);
                        }
                    } else {
                        setCurrentTags(new Tag[] { (Tag) curButton.getData("Tag") });
                    }
                }
                setSelection(curButton.getParent());
            }

            private void setSelection(Composite parent) {
                Control[] controls = parent.getChildren();
                for (int i = 0; i < controls.length; i++) {
                    if (!(controls[i] instanceof Button)) {
                        continue;
                    }
                    Button b = (Button) controls[i];
                    Tag btag = (Tag) b.getData("Tag");
                    b.setSelection(isCurrent(btag));
                }
            }
        };
        buttonHoverListener = new Listener() {

            @Override
            public void handleEvent(Event event) {
                Button curButton = (Button) event.widget;
                Tag tag = (Tag) curButton.getData("Tag");
                if (!(tag instanceof Category)) {
                    curButton.setToolTipText(TagUIUtils.getTagTooltip(tag, true));
                    return;
                }
                Category category = (Category) tag;
                List<DownloadManager> dms = category.getDownloadManagers(globalManager.getDownloadManagers());
                long ttlActive = 0;
                long ttlSize = 0;
                long ttlRSpeed = 0;
                long ttlSSpeed = 0;
                int count = 0;
                for (DownloadManager dm : dms) {
                    if (!category.hasTaggable(dm)) {
                        continue;
                    }
                    count++;
                    if (dm.getState() == DownloadManager.STATE_DOWNLOADING || dm.getState() == DownloadManager.STATE_SEEDING) {
                        ttlActive++;
                    }
                    DownloadManagerStats stats = dm.getStats();
                    ttlSize += stats.getSizeExcludingDND();
                    ttlRSpeed += stats.getDataReceiveRate();
                    ttlSSpeed += stats.getDataSendRate();
                }
                String up_details = "";
                String down_details = "";
                if (category.getType() != Category.TYPE_ALL) {
                    String up_str = MessageText.getString("GeneralView.label.maxuploadspeed");
                    String down_str = MessageText.getString("GeneralView.label.maxdownloadspeed");
                    String unlimited_str = MessageText.getString("MyTorrentsView.menu.setSpeed.unlimited");
                    int up_speed = category.getUploadSpeed();
                    int down_speed = category.getDownloadSpeed();
                    up_details = up_str + ": " + (up_speed == 0 ? unlimited_str : DisplayFormatters.formatByteCountToKiBEtc(up_speed));
                    down_details = down_str + ": " + (down_speed == 0 ? unlimited_str : DisplayFormatters.formatByteCountToKiBEtc(down_speed));
                }
                if (count == 0) {
                    curButton.setToolTipText(down_details + "\n" + up_details + "\nTotal: 0");
                    return;
                }
                curButton.setToolTipText((up_details.length() == 0 ? "" : (down_details + "\n" + up_details + "\n")) + "Total: " + count + "\n" + "Downloading/Seeding: " + ttlActive + "\n" + "\n" + "Total Speed: " + DisplayFormatters.formatByteCountToKiBEtcPerSec(ttlRSpeed) + " / " + DisplayFormatters.formatByteCountToKiBEtcPerSec(ttlSSpeed) + "\n" + "Average Speed: " + DisplayFormatters.formatByteCountToKiBEtcPerSec(ttlRSpeed / (ttlActive == 0 ? 1 : ttlActive)) + " / " + DisplayFormatters.formatByteCountToKiBEtcPerSec(ttlSSpeed / (ttlActive == 0 ? 1 : ttlActive)) + "\n" + "Size: " + DisplayFormatters.formatByteCountToKiBEtc(ttlSize));
            }
        };
        buttonDropTargetListener = new DropTargetAdapter() {

            @Override
            public void dragOver(DropTargetEvent e) {
                if (drag_drop_line_start >= 0) {
                    boolean doAdd = false;
                    Control curButton = ((DropTarget) e.widget).getControl();
                    Tag tag = (Tag) curButton.getData("Tag");
                    Object[] ds = tv.getSelectedDataSources().toArray();
                    if (tag != null) {
                        for (Object obj : ds) {
                            if (obj instanceof DownloadManager) {
                                DownloadManager dm = (DownloadManager) obj;
                                if (!tag.hasTaggable(dm)) {
                                    doAdd = true;
                                    break;
                                }
                            }
                        }
                    }
                    e.detail = doAdd ? DND.DROP_COPY : DND.DROP_MOVE;
                } else {
                    e.detail = DND.DROP_NONE;
                }
            }

            @Override
            public void drop(DropTargetEvent e) {
                e.detail = DND.DROP_NONE;
                if (drag_drop_line_start >= 0) {
                    drag_drop_line_start = -1;
                    drag_drop_rows = null;
                    Object[] ds = tv.getSelectedDataSources().toArray();
                    Control curButton = ((DropTarget) e.widget).getControl();
                    Tag tag = (Tag) curButton.getData("Tag");
                    if (tag instanceof Category) {
                        TorrentUtil.assignToCategory(ds, (Category) tag);
                        return;
                    }
                    boolean doAdd = false;
                    for (Object obj : ds) {
                        if (obj instanceof DownloadManager) {
                            DownloadManager dm = (DownloadManager) obj;
                            if (!tag.hasTaggable(dm)) {
                                doAdd = true;
                                break;
                            }
                        }
                    }
                    for (Object obj : ds) {
                        if (obj instanceof DownloadManager) {
                            DownloadManager dm = (DownloadManager) obj;
                            if (doAdd) {
                                tag.addTaggable(dm);
                            } else {
                                tag.removeTaggable(dm);
                            }
                        }
                    }
                }
            }
        };
    }
    for (final Tag tag : tags) {
        boolean isCat = (tag instanceof Category);
        final Button button = new Button(cCategoriesAndTags, SWT.TOGGLE);
        if (isCat) {
            if (spacer == null) {
                spacer = new Label(cCategoriesAndTags, SWT.NONE);
                RowData rd = new RowData();
                rd.width = 8;
                spacer.setLayoutData(rd);
                spacer.moveAbove(null);
            }
            button.moveAbove(spacer);
        }
        button.addKeyListener(this);
        if (fontButton == null) {
            Font f = button.getFont();
            FontData fd = f.getFontData()[0];
            fd.setHeight(iFontPointHeight);
            fontButton = new Font(cCategoriesAndTags.getDisplay(), fd);
        }
        button.setText("|");
        button.setFont(fontButton);
        button.pack(true);
        if (button.computeSize(100, SWT.DEFAULT).y > 0) {
            RowData rd = new RowData();
            int rd_height = button.computeSize(100, SWT.DEFAULT).y - 2 + button.getBorderWidth() * 2;
            rd.height = rd_height;
            max_rd_height = Math.max(max_rd_height, rd_height);
            button.setLayoutData(rd);
        }
        String tag_name = tag.getTagName(true);
        button.setText(tag_name);
        button.setData("Tag", tag);
        if (isCurrent(tag)) {
            button.setSelection(true);
        }
        button.addListener(SWT.MouseUp, buttonListener);
        button.addListener(SWT.MouseDown, buttonListener);
        button.addListener(SWT.MouseHover, buttonHoverListener);
        final DropTarget tabDropTarget = new DropTarget(button, DND.DROP_DEFAULT | DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK);
        Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
        tabDropTarget.setTransfer(types);
        tabDropTarget.addDropListener(buttonDropTargetListener);
        button.addDisposeListener(new DisposeListener() {

            @Override
            public void widgetDisposed(DisposeEvent e) {
                if (!tabDropTarget.isDisposed()) {
                    tabDropTarget.dispose();
                }
            }
        });
        Menu menu = new Menu(button);
        button.setMenu(menu);
        if (isCat) {
            CategoryUIUtils.setupCategoryMenu(menu, (Category) tag);
        } else {
            TagUIUtils.createSideBarMenuItems(menu, tag);
        }
    }
    if (max_rd_height > 0) {
        RowLayout layout = (RowLayout) cCategoriesAndTags.getLayout();
        int top_margin = (24 - max_rd_height + 1) / 2;
        if (top_margin > 0) {
            layout.marginTop = top_margin;
        }
    }
    cCategoriesAndTags.getParent().layout(true, true);
}
Also used : ParameterListener(com.biglybt.core.config.ParameterListener) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) DownloadManagerListener(com.biglybt.core.download.DownloadManagerListener) UIToolBarActivationListener(com.biglybt.pif.ui.toolbar.UIToolBarActivationListener) GlobalManagerListener(com.biglybt.core.global.GlobalManagerListener) TableRowRefreshListener(com.biglybt.pif.ui.tables.TableRowRefreshListener) GlobalManagerEventListener(com.biglybt.core.global.GlobalManagerEventListener) Category(com.biglybt.core.category.Category) DownloadManager(com.biglybt.core.download.DownloadManager) RowData(org.eclipse.swt.layout.RowData) RowLayout(org.eclipse.swt.layout.RowLayout) List(java.util.List) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats) SWTRunnable(com.biglybt.ui.swt.utils.SWTRunnable) FixedURLTransfer(com.biglybt.ui.swt.FixedURLTransfer) GlobalManagerEvent(com.biglybt.core.global.GlobalManagerEvent) UISWTViewEvent(com.biglybt.ui.swt.pif.UISWTViewEvent) LogEvent(com.biglybt.core.logging.LogEvent)

Example 14 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class ColumnDoneWithDND method refresh.

@Override
public void refresh(TableCell cell) {
    int value;
    Object ds = cell.getDataSource();
    if (ds instanceof DownloadManager) {
        // show amount completed of non-dnd files as makes more sense
        DownloadManager dm = (DownloadManager) ds;
        DownloadManagerStats stats = dm.getStats();
        value = stats.getDownloadCompleted(true);
    } else if (ds instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
        long length = fileInfo.getLength();
        if (length == 0) {
            value = 1000;
        } else {
            value = (int) (fileInfo.getDownloaded() * 1000 / length);
        }
    } else {
        return;
    }
    if (!cell.setSortValue(value) && cell.isValid())
        return;
    cell.setText(DisplayFormatters.formatPercentFromThousands(value));
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 15 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class DoneItem method refresh.

@Override
public void refresh(TableCell cell) {
    int value;
    Object ds = cell.getDataSource();
    if (ds instanceof DownloadManager) {
        // show amount completed of non-dnd files as makes more sense
        DownloadManager dm = (DownloadManager) ds;
        DownloadManagerStats stats = dm.getStats();
        value = stats.getPercentDoneExcludingDND();
    } else if (ds instanceof DiskManagerFileInfo) {
        DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
        long length = fileInfo.getLength();
        if (length == 0) {
            value = 1000;
        } else {
            value = (int) (fileInfo.getDownloaded() * 1000 / length);
        }
    } else {
        return;
    }
    if (!cell.setSortValue(value) && cell.isValid())
        return;
    cell.setText(DisplayFormatters.formatPercentFromThousands(value));
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats) DownloadManager(com.biglybt.core.download.DownloadManager)

Aggregations

DownloadManagerStats (com.biglybt.core.download.DownloadManagerStats)17 DownloadManager (com.biglybt.core.download.DownloadManager)12 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)4 List (java.util.List)4 PEPeerManager (com.biglybt.core.peer.PEPeerManager)3 ArrayList (java.util.ArrayList)3 Category (com.biglybt.core.category.Category)2 DiskManager (com.biglybt.core.disk.DiskManager)2 DownloadManagerStatsImpl (com.biglybt.core.download.impl.DownloadManagerStatsImpl)2 GlobalManager (com.biglybt.core.global.GlobalManager)2 GlobalManagerStats (com.biglybt.core.global.GlobalManagerStats)2 TOTorrent (com.biglybt.core.torrent.TOTorrent)2 Core (com.biglybt.core.Core)1 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 ParameterListener (com.biglybt.core.config.ParameterListener)1 DownloadManagerListener (com.biglybt.core.download.DownloadManagerListener)1 DownloadManagerOptionsHandler (com.biglybt.core.download.DownloadManagerOptionsHandler)1 GlobalManagerEvent (com.biglybt.core.global.GlobalManagerEvent)1 GlobalManagerEventListener (com.biglybt.core.global.GlobalManagerEventListener)1 GlobalManagerListener (com.biglybt.core.global.GlobalManagerListener)1