Search in sources :

Example 1 with Library

use of com.frostwire.alexandria.Library in project frostwire by frostwire.

the class AbstractLibraryTableMediator method createAddToPlaylistSubMenu.

SkinMenu createAddToPlaylistSubMenu() {
    SkinMenu menu = new SkinMenu(tr("Add to playlist"));
    menu.add(new SkinMenuItem(new CreateNewPlaylistAction()));
    Playlist currentPlaylist = LibraryMediator.instance().getSelectedPlaylist();
    Playlist starredPlaylist = LibraryMediator.getLibrary().getStarredPlaylist();
    if (currentPlaylist == null || !currentPlaylist.equals(starredPlaylist)) {
        addToStarredPlaylistMenuItem(menu, starredPlaylist);
    }
    Library library = LibraryMediator.getLibrary();
    List<Playlist> playlists = library.getPlaylists();
    if (playlists.size() > 0) {
        menu.addSeparator();
        for (Playlist playlist : library.getPlaylists()) {
            if (currentPlaylist != null && currentPlaylist.equals(playlist)) {
                continue;
            }
            menu.add(new SkinMenuItem(new AddToPlaylistAction(playlist)));
        }
    }
    return menu;
}
Also used : SkinMenuItem(com.frostwire.gui.theme.SkinMenuItem) Playlist(com.frostwire.alexandria.Playlist) SkinMenu(com.frostwire.gui.theme.SkinMenu) Library(com.frostwire.alexandria.Library)

Example 2 with Library

use of com.frostwire.alexandria.Library in project frostwire by frostwire.

the class LibraryPlaylists method createNewPlaylist.

private void createNewPlaylist() {
    if (!textName.isVisible()) {
        return;
    }
    String name = textName.getText();
    Library library = LibraryMediator.getLibrary();
    Playlist playlist = library.newPlaylist(name, name);
    playlist.save();
    LibraryPlaylistsListCell cell = new LibraryPlaylistsListCell(null, null, GUIMediator.getThemeImage("playlist"), playlist, selectedPlaylistAction);
    model.addElement(cell);
    list.setSelectedValue(cell, true);
    textName.setVisible(false);
    UXStats.instance().log(UXAction.LIBRARY_PLAYLIST_CREATED);
}
Also used : Playlist(com.frostwire.alexandria.Playlist) Library(com.frostwire.alexandria.Library)

Example 3 with Library

use of com.frostwire.alexandria.Library in project frostwire by frostwire.

the class LibraryPlaylists method setupModel.

private void setupModel() {
    model = new DefaultListModel<>();
    newPlaylistCell = new LibraryPlaylistsListCell(I18n.tr("New Playlist"), I18n.tr("Creates a new Playlist"), GUIMediator.getThemeImage("playlist_plus"), null, null);
    Library library = LibraryMediator.getLibrary();
    selectedPlaylistAction = new SelectedPlaylistActionListener();
    Playlist starredPlaylist = LibraryMediator.getLibrary().getStarredPlaylist();
    starredPlaylistCell = new LibraryPlaylistsListCell(I18n.tr("Starred"), I18n.tr("Show all starred items"), GUIMediator.getThemeImage("star_on"), starredPlaylist, selectedPlaylistAction);
    model.addElement(newPlaylistCell);
    model.addElement(starredPlaylistCell);
    for (Playlist playlist : library.getPlaylists()) {
        LibraryPlaylistsListCell cell = new LibraryPlaylistsListCell(null, null, GUIMediator.getThemeImage("playlist"), playlist, selectedPlaylistAction);
        model.addElement(cell);
    }
}
Also used : Playlist(com.frostwire.alexandria.Playlist) Library(com.frostwire.alexandria.Library)

Example 4 with Library

use of com.frostwire.alexandria.Library in project frostwire by frostwire.

the class BTDownloadMediatorAdvancedMenuFactory method createAddToPlaylistSubMenu.

public static SkinMenu createAddToPlaylistSubMenu() {
    BTDownload[] downloaders = BTDownloadMediator.instance().getSelectedDownloaders();
    if (downloaders.length == 0) {
        return null;
    }
    for (BTDownload dler : downloaders) {
        if (!dler.isCompleted()) {
            return null;
        }
        File saveLocation = dler.getSaveLocation();
        if (saveLocation.isDirectory()) {
            // If the file(s) is(are) inside a folder
            if (!LibraryUtils.directoryContainsAudio(saveLocation)) {
                return null;
            }
        } else if (!MediaPlayer.isPlayableFile(saveLocation)) {
            return null;
        }
    }
    SkinMenu menu = new SkinMenu(I18n.tr("Add to playlist"));
    menu.add(new SkinMenuItem(new CreateNewPlaylistAction()));
    Library library = LibraryMediator.getLibrary();
    List<Playlist> playlists = library.getPlaylists();
    if (playlists.size() > 0) {
        menu.addSeparator();
        for (Playlist playlist : library.getPlaylists()) {
            menu.add(new SkinMenuItem(new AddToPlaylistAction(playlist)));
        }
    }
    return menu;
}
Also used : SkinMenuItem(com.frostwire.gui.theme.SkinMenuItem) Playlist(com.frostwire.alexandria.Playlist) SkinMenu(com.frostwire.gui.theme.SkinMenu) CreateNewPlaylistAction(com.frostwire.gui.bittorrent.BTDownloadActions.CreateNewPlaylistAction) AddToPlaylistAction(com.frostwire.gui.bittorrent.BTDownloadActions.AddToPlaylistAction) Library(com.frostwire.alexandria.Library) File(java.io.File)

Aggregations

Library (com.frostwire.alexandria.Library)4 Playlist (com.frostwire.alexandria.Playlist)4 SkinMenu (com.frostwire.gui.theme.SkinMenu)2 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)2 AddToPlaylistAction (com.frostwire.gui.bittorrent.BTDownloadActions.AddToPlaylistAction)1 CreateNewPlaylistAction (com.frostwire.gui.bittorrent.BTDownloadActions.CreateNewPlaylistAction)1 File (java.io.File)1