Search in sources :

Example 16 with Category

use of com.biglybt.core.category.Category in project BiglyBT by BiglySoftware.

the class CategoryItem method refresh.

@Override
public void refresh(TableCell cell) {
    String sCategory = null;
    DownloadManager dm = (DownloadManager) cell.getDataSource();
    if (dm != null) {
        Category cat = dm.getDownloadState().getCategory();
        if (cat != null)
            sCategory = cat.getName();
    }
    cell.setText((sCategory == null) ? "" : sCategory);
}
Also used : Category(com.biglybt.core.category.Category) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 17 with Category

use of com.biglybt.core.category.Category in project BiglyBT by BiglySoftware.

the class DownloadImpl method setCategory.

@Override
public void setCategory(String sName) {
    Category category = CategoryManager.getCategory(sName);
    if (category == null)
        category = CategoryManager.createCategory(sName);
    download_manager.getDownloadState().setCategory(category);
}
Also used : Category(com.biglybt.core.category.Category)

Example 18 with Category

use of com.biglybt.core.category.Category in project BiglyBT by BiglySoftware.

the class TorrentAttributeCategoryImpl method getDefinedValues.

@Override
public String[] getDefinedValues() {
    Category[] categories = CategoryManager.getCategories();
    List v = new ArrayList();
    for (int i = 0; i < categories.length; i++) {
        Category cat = categories[i];
        if (cat.getType() == Category.TYPE_USER) {
            v.add(cat.getName());
        }
    }
    String[] res = new String[v.size()];
    v.toArray(res);
    // make it nice for clients
    Arrays.sort(res, StaticUtilities.getFormatters().getAlphanumericComparator(true));
    return (res);
}
Also used : Category(com.biglybt.core.category.Category) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 19 with Category

use of com.biglybt.core.category.Category in project BiglyBT by BiglySoftware.

the class Show method printTorrentDetails.

/**
 * prints out the full details of a particular torrent
 * @param out
 * @param dm
 * @param torrentNum
 */
private static void printTorrentDetails(PrintStream out, DownloadManager dm, int torrentNum, List<String> args) {
    String name = dm.getDisplayName();
    if (name == null)
        name = "?";
    out.println("> -----");
    out.println("Info on Torrent #" + torrentNum + " (" + name + ")");
    out.println("- General Info -");
    String[] health = { "- no info -", "stopped", "no remote connections", "no tracker", "OK", "ko" };
    try {
        out.println("Health: " + health[dm.getHealthStatus()]);
    } catch (Exception e) {
        out.println("Health: " + health[0]);
    }
    out.println("State: " + Integer.toString(dm.getState()));
    if (dm.getState() == DownloadManager.STATE_ERROR)
        out.println("Error: " + dm.getErrorDetails());
    out.println("Hash: " + TorrentUtils.nicePrintTorrentHash(dm.getTorrent(), true));
    out.println("- Torrent file -");
    out.println("Torrent Filename: " + dm.getTorrentFileName());
    out.println("Saving to: " + dm.getSaveLocation());
    out.println("Created By: " + dm.getTorrentCreatedBy());
    out.println("Comment: " + dm.getTorrentComment());
    Category cat = dm.getDownloadState().getCategory();
    if (cat != null) {
        out.println("Category: " + cat.getName());
    }
    List<Tag> tags = TagManagerFactory.getTagManager().getTagsForTaggable(TagType.TT_DOWNLOAD_MANUAL, dm);
    String tags_str;
    if (tags.size() == 0) {
        tags_str = "None";
    } else {
        tags_str = "";
        for (Tag t : tags) {
            tags_str += (tags_str.length() == 0 ? "" : ",") + t.getTagName(true);
        }
    }
    out.println("Tags: " + tags_str);
    out.println("- Tracker Info -");
    TRTrackerAnnouncer trackerclient = dm.getTrackerClient();
    if (trackerclient != null) {
        out.println("URL: " + trackerclient.getTrackerURL());
        String timestr;
        try {
            int time = trackerclient.getTimeUntilNextUpdate();
            if (time < 0) {
                timestr = MessageText.getString("GeneralView.label.updatein.querying");
            } else {
                int minutes = time / 60;
                int seconds = time % 60;
                String strSeconds = "" + seconds;
                if (seconds < 10) {
                    // $NON-NLS-1$
                    strSeconds = "0" + seconds;
                }
                timestr = minutes + ":" + strSeconds;
            }
        } catch (Exception e) {
            timestr = "unknown";
        }
        out.println("Time till next Update: " + timestr);
        out.println("Status: " + trackerclient.getStatusString());
    } else
        out.println("  Not available");
    out.println("- Files Info -");
    DiskManagerFileInfo[] files = dm.getDiskManagerFileInfo();
    if (files != null) {
        for (int i = 0; i < files.length; i++) {
            out.print(((i < 9) ? "   " : "  ") + Integer.toString(i + 1) + " (");
            String tmp = ">";
            if (files[i].getPriority() > 0)
                tmp = "+";
            if (files[i].isSkipped())
                tmp = "!";
            out.print(tmp + ") ");
            if (files[i] != null) {
                long fLen = files[i].getLength();
                if (fLen > 0) {
                    DecimalFormat df = new DecimalFormat("000.0%");
                    out.print(df.format(files[i].getDownloaded() * 1.0 / fLen));
                    out.println("\t" + files[i].getFile(true).getName());
                } else
                    out.println("Info not available.");
            } else
                out.println("Info not available.");
        }
    } else {
        out.println("  Info not available.");
    }
    for (String arg : args) {
        arg = arg.toLowerCase();
        if (arg.startsWith("pie")) {
            out.println("Pieces");
            PEPeerManager pm = dm.getPeerManager();
            if (pm != null) {
                PiecePicker picker = pm.getPiecePicker();
                PEPiece[] pieces = pm.getPieces();
                String line = "";
                for (int i = 0; i < pieces.length; i++) {
                    String str = picker.getPieceString(i);
                    line += (line.length() == 0 ? (i + " ") : ",") + str;
                    PEPiece piece = pieces[i];
                    if (piece != null) {
                        line += ":" + piece.getString();
                    }
                    if ((i + 1) % 10 == 0) {
                        out.println(line);
                        line = "";
                    }
                }
                if (line.length() > 0) {
                    out.println(line);
                }
            }
        } else if (arg.startsWith("pee")) {
            out.println("Peers");
            PEPeerManager pm = dm.getPeerManager();
            if (pm != null) {
                List<PEPeer> peers = pm.getPeers();
                out.println("\tConnected to " + peers.size() + " peers");
                for (PEPeer peer : peers) {
                    PEPeerStats stats = peer.getStats();
                    System.out.println("\t\t" + peer.getIp() + ", in=" + (peer.isIncoming() ? "Y" : "N") + ", prot=" + peer.getProtocol() + ", choked=" + (peer.isChokingMe() ? "Y" : "N") + ", up=" + DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataSendRate() + stats.getProtocolSendRate()) + ", down=" + DisplayFormatters.formatByteCountToKiBEtcPerSec(stats.getDataReceiveRate() + stats.getProtocolReceiveRate()) + ", in_req=" + peer.getIncomingRequestCount() + ", out_req=" + peer.getOutgoingRequestCount());
                }
            }
        }
    }
    out.println("> -----");
}
Also used : DiskManagerFileInfo(com.biglybt.core.disk.DiskManagerFileInfo) PEPeer(com.biglybt.core.peer.PEPeer) Category(com.biglybt.core.category.Category) PiecePicker(com.biglybt.core.peermanager.piecepicker.PiecePicker) DecimalFormat(java.text.DecimalFormat) PEPeerStats(com.biglybt.core.peer.PEPeerStats) PEPiece(com.biglybt.core.peer.PEPiece) TRTrackerAnnouncer(com.biglybt.core.tracker.client.TRTrackerAnnouncer) PEPeerManager(com.biglybt.core.peer.PEPeerManager) ArrayList(java.util.ArrayList) List(java.util.List) Tag(com.biglybt.core.tag.Tag)

Example 20 with Category

use of com.biglybt.core.category.Category in project BiglyBT by BiglySoftware.

the class SubscriptionManagerUI method addCategorySubMenu.

private static void addCategorySubMenu(MenuManager menu_manager, MenuItem menu, final Subscription subs) {
    menu.removeAllChildItems();
    Category[] categories = CategoryManager.getCategories();
    Arrays.sort(categories);
    MenuItem m;
    if (categories.length > 0) {
        String assigned_category = subs.getCategory();
        final Category uncat = CategoryManager.getCategory(Category.TYPE_UNCATEGORIZED);
        if (uncat != null) {
            m = menu_manager.addMenuItem(menu, uncat.getName());
            m.setStyle(MenuItem.STYLE_RADIO);
            m.setData(Boolean.valueOf(assigned_category == null));
            m.addListener(new MenuItemListener() {

                @Override
                public void selected(MenuItem menu, Object target) {
                    assignSelectedToCategory(subs, uncat);
                }
            });
            m = menu_manager.addMenuItem(menu, "sep1");
            m.setStyle(MenuItem.STYLE_SEPARATOR);
        }
        for (int i = 0; i < categories.length; i++) {
            final Category cat = categories[i];
            if (cat.getType() == Category.TYPE_USER) {
                m = menu_manager.addMenuItem(menu, "!" + cat.getName() + "!");
                m.setStyle(MenuItem.STYLE_RADIO);
                m.setData(Boolean.valueOf(assigned_category != null && assigned_category.equals(cat.getName())));
                m.addListener(new MenuItemListener() {

                    @Override
                    public void selected(MenuItem menu, Object target) {
                        assignSelectedToCategory(subs, cat);
                    }
                });
            }
        }
        m = menu_manager.addMenuItem(menu, "sep2");
        m.setStyle(MenuItem.STYLE_SEPARATOR);
    }
    m = menu_manager.addMenuItem(menu, "MyTorrentsView.menu.setCategory.add");
    m.addListener(new MenuItemListener() {

        @Override
        public void selected(MenuItem menu, Object target) {
            addCategory(subs);
        }
    });
}
Also used : Category(com.biglybt.core.category.Category) MenuItem(com.biglybt.pif.ui.menus.MenuItem) MenuItemListener(com.biglybt.pif.ui.menus.MenuItemListener)

Aggregations

Category (com.biglybt.core.category.Category)22 DownloadManager (com.biglybt.core.download.DownloadManager)10 CoreRunningListener (com.biglybt.core.CoreRunningListener)4 TableViewSWTMenuFillListener (com.biglybt.ui.swt.views.table.TableViewSWTMenuFillListener)4 CategoryManagerListener (com.biglybt.core.category.CategoryManagerListener)3 Tag (com.biglybt.core.tag.Tag)3 UIPluginViewToolBarListener (com.biglybt.pif.ui.UIPluginViewToolBarListener)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Core (com.biglybt.core.Core)2 CategoryListener (com.biglybt.core.category.CategoryListener)2 ParameterListener (com.biglybt.core.config.ParameterListener)2 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)2 DownloadManagerStats (com.biglybt.core.download.DownloadManagerStats)2 GlobalManager (com.biglybt.core.global.GlobalManager)2 GlobalManagerAdapter (com.biglybt.core.global.GlobalManagerAdapter)2 LogEvent (com.biglybt.core.logging.LogEvent)2 TOTorrent (com.biglybt.core.torrent.TOTorrent)2 PluginInterface (com.biglybt.pif.PluginInterface)2 DownloadManagerListener (com.biglybt.core.download.DownloadManagerListener)1