use of com.biglybt.core.history.DownloadHistory in project BiglyBT by BiglySoftware.
the class SBC_DownloadHistoryView method fillMenu.
@Override
public void fillMenu(String sColumnName, Menu menu) {
if (dh_manager != null) {
if (dh_manager.isEnabled()) {
List<Object> ds = tv.getSelectedDataSources();
final List<DownloadHistory> dms = new ArrayList<>(ds.size());
for (Object o : ds) {
dms.add((DownloadHistory) o);
}
boolean hasSelection = dms.size() > 0;
// Explore (or open containing folder)
final boolean use_open_containing_folder = COConfigurationManager.getBooleanParameter("MyTorrentsView.menu.show_parent_folder_enabled");
MenuItem itemExplore = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemExplore, "MyTorrentsView.menu." + (use_open_containing_folder ? "open_parent_folder" : "explore"));
itemExplore.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
for (DownloadHistory download : dms) {
ManagerUtils.open(new File(download.getSaveLocation()), use_open_containing_folder);
}
}
});
itemExplore.setEnabled(hasSelection);
// redownload
MenuItem itemRedownload = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemRedownload, "label.redownload");
itemRedownload.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
for (DownloadHistory download : dms) {
download.setRedownloading();
String magnet = UrlUtils.getMagnetURI(download.getTorrentHash(), download.getName(), null);
TorrentOpener.openTorrent(magnet);
}
}
});
itemExplore.setEnabled(hasSelection);
// remove
MenuItem itemRemove = new MenuItem(menu, SWT.PUSH);
Utils.setMenuItemImage(itemRemove, "delete");
Messages.setLanguageText(itemRemove, "MySharesView.menu.remove");
itemRemove.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
dh_manager.removeHistory(dms);
}
});
itemRemove.setEnabled(hasSelection);
new MenuItem(menu, SWT.SEPARATOR);
// reset
MenuItem itemReset = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemReset, "label.reset.history");
itemReset.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
resetHistory();
}
});
// disable
MenuItem itemDisable = new MenuItem(menu, SWT.PUSH);
Messages.setLanguageText(itemDisable, "label.disable.history");
itemDisable.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
dh_manager.setEnabled(false);
}
});
new MenuItem(menu, SWT.SEPARATOR);
}
}
}
Aggregations