use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.
the class SBC_ArchivedDownloadsView method toolBarItemActivated.
@Override
public boolean toolBarItemActivated(ToolBarItem item, long activationType, Object datasource) {
if (tv == null || !tv.isVisible()) {
return (false);
}
List<Object> datasources = tv.getSelectedDataSources();
if (datasources.size() > 0) {
List<DownloadStub> dms = new ArrayList<>(datasources.size());
for (Object o : datasources) {
dms.add((DownloadStub) o);
}
String id = item.getID();
if (id.equals("remove")) {
TorrentUtil.removeDataSources(datasources.toArray());
} else if (id.equals("startstop") || id.equals("start")) {
ManagerUtils.restoreFromArchive(dms, true, null);
}
return true;
}
return false;
}
use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.
the class ManagerUtils method moveToArchive.
public static void moveToArchive(final List<Download> downloads, ArchiveCallback _run_when_complete) {
final ArchiveCallback run_when_complete = _run_when_complete == null ? new ArchiveCallback() : _run_when_complete;
Utils.getOffOfSWTThread(new AERunnable() {
@Override
public void runSupport() {
try {
String title = MessageText.getString("archive.info.title");
String text = MessageText.getString("archive.info.text");
MessageBoxShell prompter = new MessageBoxShell(title, text, new String[] { MessageText.getString("Button.ok") }, 0);
String remember_id = "managerutils.archive.info";
prompter.setRemember(remember_id, true, MessageText.getString("MessageBoxWindow.nomoreprompting"));
prompter.setAutoCloseInMS(0);
prompter.open(null);
prompter.waitUntilClosed();
for (Download dm : downloads) {
try {
DownloadStub stub = dm.stubbify();
run_when_complete.success(dm, stub);
} catch (Throwable e) {
run_when_complete.failed(dm, e);
Debug.out(e);
}
}
} finally {
run_when_complete.completed();
}
}
});
}
use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.
the class Archive method execute.
@Override
public void execute(String commandName, ConsoleInput ci, List<String> args) {
if (args.size() > 0) {
PluginInterface pi = ci.getCore().getPluginManager().getDefaultPluginInterface();
DownloadStub[] stubs = pi.getDownloadManager().getDownloadStubs();
String sub = args.get(0);
int index = -1;
if (args.size() > 1) {
String index_str = args.get(1);
try {
index = Integer.parseInt(index_str);
index--;
if (index < 0 || index >= stubs.length) {
index = -1;
}
} catch (Throwable e) {
}
if (index == -1) {
ci.out.println("Invalid archive index: " + index_str);
}
}
if (sub.equals("list") || sub.equals("l")) {
int pos = 1;
ci.out.println("> -----");
for (DownloadStub stub : stubs) {
System.out.println(" " + (pos++) + "\t" + stub.getName() + " (" + DisplayFormatters.formatByteCountToKiBEtc(stub.getTorrentSize()) + ")");
}
ci.out.println("> -----");
} else if (index != -1 && (sub.equals("show") || sub.equals("s"))) {
try {
DownloadStub stub = stubs[index];
ci.out.println("> -----");
ci.out.println(" " + stub.getName() + " - hash=" + ByteFormatter.encodeString(stub.getTorrentHash()));
DownloadStubFile[] files = stub.getStubFiles();
ci.out.println(" Files: " + files.length);
for (DownloadStubFile file : files) {
long length = file.getLength();
ci.out.println(" " + file.getFile() + " - " + (length < 0 ? ("Not downloaded") : DisplayFormatters.formatByteCountToKiBEtc(length)));
}
ci.out.println("> -----");
} catch (Throwable e) {
ci.out.print(e);
}
} else if (index != -1 && (sub.equals("restore") || sub.equals("res"))) {
try {
Download d = stubs[index].destubbify();
ci.out.println("> Restore of " + d.getName() + " succeeded.");
} catch (Throwable e) {
ci.out.print(e);
}
} else if (index != -1 && (sub.equals("delete") || sub.equals("del"))) {
try {
DownloadStub stub = stubs[index];
String name = stub.getName();
stub.remove();
ci.out.println("> Delete of " + name + " succeeded.");
} catch (Throwable e) {
ci.out.print(e);
}
} else {
ci.out.println("Unsupported sub-command: " + sub);
return;
}
} else {
printHelp(ci.out, args);
}
}
use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.
the class ColumnArchiveDLFileCount method refresh.
@Override
public void refresh(TableCell cell) {
DownloadStub dl = (DownloadStub) cell.getDataSource();
long count = 0;
if (dl != null) {
count = dl.getStubFiles().length;
}
if (!cell.setSortValue(count) && cell.isValid()) {
// return;
}
if (!cell.isShown()) {
return;
}
cell.setText(String.valueOf(count));
}
use of com.biglybt.pif.download.DownloadStub in project BiglyBT by BiglySoftware.
the class ColumnArchiveDLName method refresh.
@Override
public void refresh(TableCell cell) {
DownloadStub dl = (DownloadStub) cell.getDataSource();
String name = null;
if (dl != null) {
name = dl.getName();
}
if (name == null) {
name = "";
}
if (!cell.setSortValue(name) && cell.isValid()) {
return;
}
if (!cell.isShown()) {
return;
}
cell.setText(name);
}
Aggregations