use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class SystemTraySWT method updateUI.
// @see UIUpdatable#updateUI()
@Override
public void updateUI(boolean is_visible) {
if (interval++ % 10 > 0) {
return;
}
if (trayItem.isDisposed()) {
uiFunctions.getUIUpdater().removeUpdater(this);
return;
}
if (core == null || !core.isStarted()) {
return;
}
if (enableTooltip) {
GlobalManagerStats stats = gm.getStats();
StringBuilder toolTip = new StringBuilder();
int seeding = 0;
int downloading = 0;
DownloadManager next_download = null;
long next_download_eta = Long.MAX_VALUE;
TagManager tm = TagManagerFactory.getTagManager();
if (tm != null && tm.isEnabled()) {
TagType tt = tm.getTagType(TagType.TT_DOWNLOAD_STATE);
if (tt != null) {
TagDownload dl_tag = (TagDownload) tt.getTag(1);
downloading = dl_tag.getTaggedCount();
seeding = tt.getTag(2).getTaggedCount();
if (enableTooltipNextETA && downloading > 0) {
for (DownloadManager dl : dl_tag.getTaggedDownloads()) {
DownloadManagerStats dl_stats = dl.getStats();
long eta = dl_stats.getSmoothedETA();
if (eta < next_download_eta) {
next_download_eta = eta;
next_download = dl;
}
}
}
}
} else {
// OMG this must be slow on 10k lists
/*
List<?> managers = gm.getDownloadManagers();
for (int i = 0; i < managers.size(); i++) {
DownloadManager manager = (DownloadManager) managers.get(i);
int state = manager.getState();
if (state == DownloadManager.STATE_DOWNLOADING)
downloading++;
if (state == DownloadManager.STATE_SEEDING)
seeding++;
}
*/
}
String seeding_text = seedingKeyVal.replaceAll("%1", "" + seeding);
String downloading_text = downloadingKeyVal.replaceAll("%1", "" + downloading);
toolTip.append(seeding_text).append(downloading_text).append("\n");
if (next_download != null) {
String dl_name = next_download.getDisplayName();
if (dl_name.length() > 80) {
dl_name = dl_name.substring(0, 77) + "...";
}
dl_name = dl_name.replaceAll("&", "&&");
toolTip.append(" ");
toolTip.append(dl_name);
toolTip.append(": ");
toolTip.append(etaKeyVal);
toolTip.append("=");
toolTip.append(DisplayFormatters.formatETA(next_download_eta));
toolTip.append("\n");
}
toolTip.append(dlAbbrKeyVal).append(" ");
toolTip.append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataReceiveRate(), stats.getProtocolReceiveRate()));
toolTip.append(", ").append(ulAbbrKeyVal).append(" ");
toolTip.append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataSendRate(), stats.getProtocolSendRate()));
int alerts = Alerts.getUnviewedLogAlertCount();
if (alerts > 0) {
toolTip.append("\n");
toolTip.append(alertsKeyVal.replaceAll("%1", "" + alerts));
}
trayItem.setToolTipText(toolTip.toString());
}
if (Constants.isUnix && gm != null) {
GlobalManagerStats stats = gm.getStats();
long l = (stats.getDataReceiveRate() + stats.getDataSendRate()) / 1024;
if (l != lastUnixVal) {
lastUnixVal = l;
trayItem.setMenu(menu, menuBuilder);
}
}
// Why should we refresh the image? it never changes ...
// and is a memory bottleneck for some non-obvious reasons.
// trayItem.setImage(ImageLoader.getInstance().getImage("logo16"));
trayItem.setVisible(true);
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class TableViewSWT_TabsCommon method createSashForm.
public Composite createSashForm(final Composite composite) {
if (!tv.isTabViewsEnabled()) {
tableComposite = tv.createMainPanel(composite);
return tableComposite;
}
SelectedContentManager.addCurrentlySelectedContentListener(this);
ConfigurationManager configMan = ConfigurationManager.getInstance();
int iNumViews = 0;
UIFunctionsSWT uiFunctions = UIFunctionsManagerSWT.getUIFunctionsSWT();
if (uiFunctions != null) {
UISWTInstance pluginUI = uiFunctions.getUISWTInstance();
if (pluginUI != null) {
iNumViews += pluginUI.getViewListeners(tv.getTableID()).length;
}
}
if (iNumViews == 0) {
tableComposite = tv.createMainPanel(composite);
return tableComposite;
}
final String props_prefix = tv.getTableID() + "." + tv.getPropertiesPrefix();
FormData formData;
final Composite form = new Composite(composite, SWT.NONE);
FormLayout flayout = new FormLayout();
flayout.marginHeight = 0;
flayout.marginWidth = 0;
form.setLayout(flayout);
GridData gridData;
gridData = new GridData(GridData.FILL_BOTH);
form.setLayoutData(gridData);
// Create them in reverse order, so we can have the table auto-grow, and
// set the tabFolder's height manually
cTabsHolder = new Composite(form, SWT.NONE);
tabbedMDI = uiFunctions.createTabbedMDI(cTabsHolder, props_prefix);
tabbedMDI.setMaximizeVisible(true);
tabbedMDI.setMinimizeVisible(true);
tabbedMDI.setTabbedMdiMaximizeListener(new TabbedMdiMaximizeListener() {
@Override
public void maximizePressed() {
TableView tvToUse = tvOverride == null ? tv : tvOverride;
Object[] ds = tvToUse.getSelectedDataSources(true);
if (ds.length == 1 && ds[0] instanceof DownloadManager) {
UIFunctions uiFunctions = UIFunctionsManager.getUIFunctions();
if (uiFunctions != null) {
uiFunctions.getMDI().showEntryByID(MultipleDocumentInterface.SIDEBAR_SECTION_TORRENT_DETAILS, ds);
}
}
}
});
final int SASH_WIDTH = 5;
sash = Utils.createSash(form, SASH_WIDTH);
tableComposite = tv.createMainPanel(form);
Composite cFixLayout = tableComposite;
while (cFixLayout != null && cFixLayout.getParent() != form) {
cFixLayout = cFixLayout.getParent();
}
if (cFixLayout == null) {
cFixLayout = tableComposite;
}
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.horizontalSpacing = 0;
layout.verticalSpacing = 0;
layout.marginHeight = 0;
layout.marginWidth = 0;
cFixLayout.setLayout(layout);
// FormData for Folder
formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.bottom = new FormAttachment(100, 0);
int iSplitAt = configMan.getIntParameter(props_prefix + ".SplitAt", 3000);
// Was stored at whole
if (iSplitAt < 100) {
iSplitAt *= 100;
}
// pct is % bottom
double pct = iSplitAt / 10000.0;
if (pct < 0.03) {
pct = 0.03;
} else if (pct > 0.97) {
pct = 0.97;
}
// height will be set on first resize call
sash.setData("PCT", new Double(pct));
cTabsHolder.setLayout(new FormLayout());
fdHeightChanger = formData;
cTabsHolder.setLayoutData(formData);
// FormData for Sash
formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.bottom = new FormAttachment(cTabsHolder);
formData.height = SASH_WIDTH;
sash.setLayoutData(formData);
// FormData for table Composite
formData = new FormData();
formData.left = new FormAttachment(0, 0);
formData.right = new FormAttachment(100, 0);
formData.top = new FormAttachment(0, 0);
formData.bottom = new FormAttachment(sash);
cFixLayout.setLayoutData(formData);
// Listeners to size the folder
sash.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final boolean FASTDRAG = true;
if (FASTDRAG && e.detail == SWT.DRAG) {
return;
}
Rectangle area = form.getClientArea();
int height = area.height - e.y - e.height;
if (!Constants.isWindows) {
height -= SASH_WIDTH;
}
if (area.height - height < 100) {
height = area.height - 100;
}
if (height < 0) {
height = 0;
}
fdHeightChanger.height = height;
Double l = new Double((double) height / area.height);
sash.setData("PCT", l);
if (e.detail != SWT.DRAG) {
ConfigurationManager configMan = ConfigurationManager.getInstance();
configMan.setParameter(props_prefix + ".SplitAt", (int) (l.doubleValue() * 10000));
}
form.layout();
// sometimes sash cheese is left
cTabsHolder.redraw();
}
});
buildFolder(form, props_prefix);
return form;
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class ColumnFileCount method cellAdded.
// @see com.biglybt.pif.ui.tables.TableCellAddedListener#cellAdded(com.biglybt.pif.ui.tables.TableCell)
@Override
public void cellAdded(TableCell cell) {
DownloadManager dm = (DownloadManager) cell.getDataSource();
int sortVal = dm.getNumFileInfos();
cell.setSortValue(sortVal);
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class ColumnSizeWithDND method refresh.
@Override
public void refresh(TableCell cell) {
long value = 0;
Object ds = cell.getDataSource();
if (ds instanceof DownloadManager) {
DownloadManager dm = (DownloadManager) ds;
value = dm.getSize();
} else if (ds instanceof DiskManagerFileInfo) {
DiskManagerFileInfo fileInfo = (DiskManagerFileInfo) ds;
value = fileInfo.getLength();
}
if (!cell.setSortValue(value) && cell.isValid())
return;
cell.setText(DisplayFormatters.formatByteCountToKiBEtc(value));
}
use of com.biglybt.core.download.DownloadManager in project BiglyBT by BiglySoftware.
the class CommentIconItem 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.promptUserForComment(new DownloadManager[] { dm });
refresh(event.cell);
}
Aggregations