public void configureRendererComponent(AbstractNode value, boolean isSelected, boolean hasFocus, int row, int column) { if (value instanceof DownloadLink) { DownloadLink dlLink = (DownloadLink) value; DownloadInterface dli = dlLink.getDownloadInstance(); SingleDownloadController sdc = dlLink.getDownloadLinkController(); int index = 0; if (dlLink.isSkipped()) { labels[index].setIcon(skipped); labels[index].setVisible(true); index++; } if (dlWatchdog.isLinkForced(dlLink)) { labels[index].setIcon(forced); labels[index].setVisible(true); index++; } if (dlLink.isResumeable()) { labels[index].setIcon(resumeIndicator); labels[index].setVisible(true); index++; } if (dli != null && sdc != null) { HTTPProxy proxy = sdc.getCurrentProxy(); if (proxy != null && proxy.isRemote()) { labels[index].setIcon(proxyConnection); labels[index].setVisible(true); } else { labels[index].setIcon(directConnection); labels[index].setVisible(true); } index++; if (sdc.getAccount() != null) { labels[index].setIcon(accountInUse); labels[index].setVisible(true); index++; } labels[index].setText("" + dli.getManagedConnetionHandler().size()); labels[index].setIcon(connections); labels[index].setVisible(true); } } }
public ConnectionTooltip(DownloadLink link) { JLabel lbl; this.panel = new TooltipPanel("ins 3,wrap 1", "[grow,fill]", "[grow,fill]"); DownloadInterface dli = link.getDownloadInstance(); SingleDownloadController sdc = link.getDownloadLinkController(); { if (dlWatchdog.isLinkForced(link)) { panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_DownloadIsForced(), forced, JLabel.LEADING)); SwingUtils.setOpaque(lbl, false); lbl.setForeground(new Color(this.getConfig().getForegroundColor())); } if (link.isSkipped()) { panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_DownloadIsSkipped(), skipped, JLabel.LEADING)); SwingUtils.setOpaque(lbl, false); lbl.setForeground(new Color(this.getConfig().getForegroundColor())); } /* is the Link resumeable */ if (link.isResumeable()) { panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_DownloadIsResumeable(), resumeIndicator, JLabel.LEADING)); SwingUtils.setOpaque(lbl, false); lbl.setForeground(new Color(this.getConfig().getForegroundColor())); } } if (sdc != null) { { /* connection? */ HTTPProxy proxy = sdc.getCurrentProxy(); if (proxy == null) proxy = HTTPProxy.NONE; panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_getStringValue_connection(proxy), proxy.isRemote() ? proxyConnection : directConnection, JLabel.LEADING)); SwingUtils.setOpaque(lbl, false); lbl.setForeground(new Color(this.getConfig().getForegroundColor())); } if (sdc.getAccount() != null) { /* account in use? */ panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_DownloadUsesAccount(sdc.getAccount().getUser()), accountInUse, JLabel.LEADING)); SwingUtils.setOpaque(lbl, false); lbl.setForeground(new Color(this.getConfig().getForegroundColor())); } } if (dli != null) { panel.add(lbl = new JLabel(_GUI._.ConnectionColumn_getStringValue_chunks(dli.getManagedConnetionHandler().size()), connections, JLabel.LEADING)); SwingUtils.setOpaque(lbl, false); lbl.setForeground(new Color(this.getConfig().getForegroundColor())); } this.panel.setOpaque(false); if (panel.getComponentCount() > 0) add(panel); }
public AggregatedNumbers(SelectionInfo<FilePackage, DownloadLink> selection) { totalBytes = 0l; disabledTotalBytes = 0l; disabledLoadedBytes = 0l; loadedBytes = 0l; downloadSpeed = 0l; running = 0l; connections = 0l; packageCount = selection.getPackageViews().size(); linkCount = selection.getChildren().size(); downloadsFinished = 0l; downloadsFailed = 0l; downloadsSkipped = 0l; disabledDownloadsFinished = 0l; disabledDownloadsFailed = 0l; disabledDownloadsSkipped = 0l; for (DownloadLink dl : selection.getChildren()) { if (dl == null) continue; if (dl.isEnabled()) { FinalLinkState state = dl.getFinalLinkState(); if (state == null) { if (dl.isSkipped()) { downloadsSkipped++; } } else { if (state.isFailed()) { downloadsFailed++; } else if (state.isFinished()) { downloadsFinished++; } } totalBytes += dl.getView().getBytesTotalEstimated(); loadedBytes += dl.getView().getBytesLoaded(); } else { FinalLinkState state = dl.getFinalLinkState(); if (state == null) { if (dl.isSkipped()) { disabledDownloadsSkipped++; } } else { if (state.isFailed()) { disabledDownloadsFailed++; } else if (state.isFinished()) { disabledDownloadsFinished++; } } disabledTotalBytes += dl.getView().getBytesTotalEstimated(); disabledLoadedBytes += dl.getView().getBytesLoaded(); } downloadSpeed += dl.getView().getSpeedBps(); SingleDownloadController sdc = dl.getDownloadLinkController(); if (sdc != null) { running++; DownloadInterface conInst = sdc.getDownloadInstance(); if (conInst != null) { ManagedThrottledConnectionHandler handlerP = conInst.getManagedConnetionHandler(); if (handlerP != null) { connections += handlerP.size(); } } } } eta = downloadSpeed == 0 ? 0 : (totalBytes - loadedBytes) / downloadSpeed; }