Search in sources :

Example 1 with DownloadHistory

use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.

the class SBC_DownloadHistoryView method toolBarItemActivated.

@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
    if (tv == null || !tv.isVisible() || dh_manager == null) {
        return (false);
    }
    List<Object> datasources = tv.getSelectedDataSources();
    if (datasources.size() > 0) {
        List<DownloadHistory> dms = new ArrayList<>(datasources.size());
        for (Object o : datasources) {
            dms.add((DownloadHistory) o);
        }
        String id = item.getID();
        if (id.equals("remove")) {
            dh_manager.removeHistory(dms);
        } else if (id.equals("startstop")) {
            for (DownloadHistory download : dms) {
                download.setRedownloading();
                String magnet = UrlUtils.getMagnetURI(download.getTorrentHash(), download.getName(), null);
                TorrentOpener.openTorrent(magnet);
            }
        }
        return true;
    }
    return false;
}
Also used : DownloadHistory(com.biglybt.core.history.DownloadHistory) SWTSkinObject(com.biglybt.ui.swt.skin.SWTSkinObject)

Example 2 with DownloadHistory

use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.

the class DownloadHistoryManagerImpl method removeHistory.

@Override
public void removeHistory(List<DownloadHistory> to_remove) {
    synchronized (lock) {
        List<DownloadHistory> removed = new ArrayList<>(to_remove.size());
        int update_type = 0;
        Map<Long, DownloadHistoryImpl> active = getActiveHistory();
        Map<Long, DownloadHistoryImpl> dead = getDeadHistory();
        for (DownloadHistory h : to_remove) {
            long uid = h.getUID();
            DownloadHistoryImpl r = active.remove(uid);
            if (r != null) {
                removed.add(r);
                update_type |= UPDATE_TYPE_ACTIVE;
            } else {
                r = dead.remove(uid);
                if (r != null) {
                    removed.add(r);
                    update_type |= UPDATE_TYPE_DEAD;
                }
            }
        }
        if (removed.size() > 0) {
            historyUpdated(removed, DownloadHistoryEvent.DHE_HISTORY_REMOVED, update_type);
        }
    }
}
Also used : DownloadHistory(com.biglybt.core.history.DownloadHistory)

Example 3 with DownloadHistory

use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.

the class ColumnDLHistoryRemoveDate method refresh.

@Override
public void refresh(TableCell cell) {
    TableColumn tc = cell.getTableColumn();
    if (tc instanceof ColumnDateSizer) {
        DownloadHistory dl = (DownloadHistory) cell.getDataSource();
        ((ColumnDateSizer) tc).refresh(cell, dl.getRemoveTime());
    }
}
Also used : ColumnDateSizer(com.biglybt.ui.swt.views.tableitems.ColumnDateSizer) DownloadHistory(com.biglybt.core.history.DownloadHistory) TableColumn(com.biglybt.pif.ui.tables.TableColumn)

Example 4 with DownloadHistory

use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.

the class ColumnDLHistorySize method refresh.

@Override
public void refresh(TableCell cell) {
    DownloadHistory dl = (DownloadHistory) cell.getDataSource();
    long size = 0;
    if (dl != null) {
        size = dl.getSize();
    }
    if (!cell.setSortValue(size) && cell.isValid()) {
        return;
    }
    if (!cell.isShown()) {
        return;
    }
    cell.setText(size <= 0 ? "" : DisplayFormatters.formatByteCountToKiBEtc(size));
}
Also used : DownloadHistory(com.biglybt.core.history.DownloadHistory)

Example 5 with DownloadHistory

use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.

the class DownloadHistoryManagerImpl method getDates.

@Override
public long[] getDates(byte[] hash) {
    List<DownloadHistory> history = getHistory();
    for (DownloadHistory dh : history) {
        if (Arrays.equals(hash, dh.getTorrentHash())) {
            Long rdl = redownload_cache.remove(dh.getUID());
            long[] result = { dh.getAddTime(), dh.getCompleteTime(), dh.getRemoveTime(), rdl == null ? 0 : rdl };
            return (result);
        }
    }
    return (null);
}
Also used : DownloadHistory(com.biglybt.core.history.DownloadHistory)

Aggregations

DownloadHistory (com.biglybt.core.history.DownloadHistory)11 TableColumn (com.biglybt.pif.ui.tables.TableColumn)3 ColumnDateSizer (com.biglybt.ui.swt.views.tableitems.ColumnDateSizer)3 SWTSkinObject (com.biglybt.ui.swt.skin.SWTSkinObject)2 DownloadHistoryEvent (com.biglybt.core.history.DownloadHistoryEvent)1 DownloadHistoryListener (com.biglybt.core.history.DownloadHistoryListener)1 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)1 TableColumnCreationListener (com.biglybt.pif.ui.tables.TableColumnCreationListener)1 UserPrompterResultListener (com.biglybt.ui.UserPrompterResultListener)1 TableViewSWTMenuFillListener (com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener)1 File (java.io.File)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1