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;
}
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);
}
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);
}
}
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;
}
Aggregations