use of com.biglybt.pif.download.DownloadStub.DownloadStubFile in project BiglyBT by BiglySoftware.
the class SBC_ArchivedDownloadsView method filterCheck.
@Override
public boolean filterCheck(DownloadStub ds, String filter, boolean regex) {
if (filter.toLowerCase(Locale.US).startsWith("f:")) {
filter = filter.substring(2).trim();
DownloadStubFile[] files = ds.getStubFiles();
String s = regex ? filter : "\\Q" + filter.replaceAll("\\s*[|;]\\s*", "\\\\E|\\\\Q") + "\\E";
boolean match_result = true;
if (regex && s.startsWith("!")) {
s = s.substring(1);
match_result = false;
}
Pattern pattern = RegExUtil.getCachedPattern("archiveview:search", s, Pattern.CASE_INSENSITIVE);
boolean result = !match_result;
for (DownloadStubFile file : files) {
String name = file.getFile().getName();
if (pattern.matcher(name).find()) {
result = match_result;
break;
}
}
return (result);
} else {
String name = ds.getName();
String s = regex ? filter : "\\Q" + filter.replaceAll("\\s*[|;]\\s*", "\\\\E|\\\\Q") + "\\E";
boolean match_result = true;
if (regex && s.startsWith("!")) {
s = s.substring(1);
match_result = false;
}
Pattern pattern = RegExUtil.getCachedPattern("archiveview:search", s, Pattern.CASE_INSENSITIVE);
return (pattern.matcher(name).find() == match_result);
}
}
use of com.biglybt.pif.download.DownloadStub.DownloadStubFile in project BiglyBT by BiglySoftware.
the class NameItem method getObfuscatedText.
@Override
public String getObfuscatedText(TableCell cell) {
DownloadStubFile fileInfo = (DownloadStubFile) cell.getDataSource();
String name = (fileInfo == null) ? "" : Debug.secretFileName(fileInfo.getFile().getName());
return (name);
}
use of com.biglybt.pif.download.DownloadStub.DownloadStubFile in project BiglyBT by BiglySoftware.
the class NameItem method refresh.
@Override
public void refresh(TableCell cell, boolean sortOnlyRefresh) {
DownloadStubFile fileInfo = (DownloadStubFile) cell.getDataSource();
String name;
if (fileInfo == null) {
name = "";
} else {
File f = fileInfo.getFile();
if (show_full_path) {
name = f.getAbsolutePath();
} else {
name = f.getName();
}
}
cell.setText(name);
}
use of com.biglybt.pif.download.DownloadStub.DownloadStubFile 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.DownloadStubFile in project BiglyBT by BiglySoftware.
the class ArchivedFilesView method fillMenu.
@Override
public void fillMenu(String sColumnName, Menu menu) {
List<Object> ds = tv.getSelectedDataSources();
final List<DownloadStubFile> files = new ArrayList<>();
for (Object o : ds) {
files.add((DownloadStubFile) o);
}
boolean hasSelection = files.size() > 0;
// Explore (or open containing folder)
final boolean use_open_containing_folder = COConfigurationManager.getBooleanParameter("MyTorrentsView.menu.show_parent_folder_enabled");
final 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 (DownloadStubFile file : files) {
ManagerUtils.open(new File(file.getFile().getAbsolutePath()), use_open_containing_folder);
}
}
});
itemExplore.setEnabled(hasSelection);
new MenuItem(menu, SWT.SEPARATOR);
}
Aggregations