Search in sources :

Example 1 with DownloadStubFile

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);
    }
}
Also used : DownloadStubFile(com.biglybt.pif.download.DownloadStub.DownloadStubFile) Pattern(java.util.regex.Pattern)

Example 2 with DownloadStubFile

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);
}
Also used : DownloadStubFile(com.biglybt.pif.download.DownloadStub.DownloadStubFile)

Example 3 with DownloadStubFile

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);
}
Also used : DownloadStubFile(com.biglybt.pif.download.DownloadStub.DownloadStubFile) DownloadStubFile(com.biglybt.pif.download.DownloadStub.DownloadStubFile) File(java.io.File)

Example 4 with DownloadStubFile

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);
    }
}
Also used : DownloadStub(com.biglybt.pif.download.DownloadStub) DownloadStubFile(com.biglybt.pif.download.DownloadStub.DownloadStubFile) PluginInterface(com.biglybt.pif.PluginInterface) Download(com.biglybt.pif.download.Download)

Example 5 with DownloadStubFile

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);
}
Also used : DownloadStubFile(com.biglybt.pif.download.DownloadStub.DownloadStubFile) TableViewSWTMenuFillListener(com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener) TableLifeCycleListener(com.biglybt.ui.common.table.TableLifeCycleListener) Listener(org.eclipse.swt.widgets.Listener) TableDataSourceChangedListener(com.biglybt.ui.common.table.TableDataSourceChangedListener) ArrayList(java.util.ArrayList) Event(org.eclipse.swt.widgets.Event) MenuItem(org.eclipse.swt.widgets.MenuItem) File(java.io.File) DownloadStubFile(com.biglybt.pif.download.DownloadStub.DownloadStubFile)

Aggregations

DownloadStubFile (com.biglybt.pif.download.DownloadStub.DownloadStubFile)6 File (java.io.File)2 PluginInterface (com.biglybt.pif.PluginInterface)1 Download (com.biglybt.pif.download.Download)1 DownloadStub (com.biglybt.pif.download.DownloadStub)1 TableDataSourceChangedListener (com.biglybt.ui.common.table.TableDataSourceChangedListener)1 TableLifeCycleListener (com.biglybt.ui.common.table.TableLifeCycleListener)1 TableCellSWT (com.biglybt.ui.swt.views.table.TableCellSWT)1 TableViewSWTMenuFillListener (com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener)1 ArrayList (java.util.ArrayList)1 Pattern (java.util.regex.Pattern)1 Event (org.eclipse.swt.widgets.Event)1 Listener (org.eclipse.swt.widgets.Listener)1 MenuItem (org.eclipse.swt.widgets.MenuItem)1