Search in sources :

Example 1 with PlaylistItem

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

the class LibraryFilesTableTransferHandler method importData.

@Override
public boolean importData(TransferSupport support) {
    if (!canImport(support, false)) {
        return fallbackTransferHandler.importData(support);
    }
    try {
        Transferable transferable = support.getTransferable();
        if (DNDUtils.contains(transferable.getTransferDataFlavors(), LibraryPlaylistsTableTransferable.ITEM_ARRAY)) {
            PlaylistItem[] playlistItems = LibraryUtils.convertToPlaylistItems((LibraryPlaylistsTableTransferable.Item[]) transferable.getTransferData(LibraryPlaylistsTableTransferable.ITEM_ARRAY));
            LibraryUtils.createNewPlaylist(playlistItems);
        } else {
            File[] files = DNDUtils.getFiles(support.getTransferable());
            if (files.length == 1 && files[0].getAbsolutePath().endsWith(".m3u")) {
                LibraryUtils.createNewPlaylist(files[0]);
            } else {
                LibraryUtils.createNewPlaylist(files);
            }
        }
    } catch (Throwable e) {
        return fallbackTransferHandler.importData(support);
    }
    return false;
}
Also used : PlaylistItem(com.frostwire.alexandria.PlaylistItem) Transferable(java.awt.datatransfer.Transferable) FileTransferable(com.limegroup.gnutella.gui.dnd.FileTransferable) File(java.io.File) PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 2 with PlaylistItem

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

the class LibraryPlaylists method getPlaylistPopupMenu.

private SkinPopupMenu getPlaylistPopupMenu(Playlist playlist) {
    SkinPopupMenu playlistPopup = new SkinPopupMenu();
    final List<PlaylistItem> items = playlist.getItems();
    boolean playlistEmpty = items == null || items.size() == 0;
    playlistPopup.add(new SkinMenuItem(actions[REFRESH_ACTION]));
    if (!playlistEmpty) {
        playlistPopup.add(new SkinMenuItem(actions[REFRESH_ID3_TAGS_ACTION]));
    }
    playlistPopup.addSeparator();
    playlistPopup.add(new SkinMenuItem(actions[RENAME_ACTION]));
    playlistPopup.add(new SkinMenuItem(actions[DELETE_ACTION]));
    if (!playlistEmpty) {
        playlistPopup.add(new SkinMenuItem(actions[CLEANUP_PLAYLIST_ACTION]));
    }
    playlistPopup.addSeparator();
    playlistPopup.add(new SkinMenuItem(actions[IMPORT_TO_PLAYLIST_ACTION]));
    playlistPopup.add(new SkinMenuItem(actions[IMPORT_TO_NEW_PLAYLIST_ACTION]));
    addExportActionsToPopupMenu(playlistPopup, playlistEmpty);
    playlistPopup.addSeparator();
    playlistPopup.add(new SkinMenuItem(actions[CONFIGURE_OPTIONS_ACTION]));
    return playlistPopup;
}
Also used : SkinMenuItem(com.frostwire.gui.theme.SkinMenuItem) SkinPopupMenu(com.frostwire.gui.theme.SkinPopupMenu) PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 3 with PlaylistItem

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

the class LibraryPlaylists method getStarredPlaylistPopupMenu.

private SkinPopupMenu getStarredPlaylistPopupMenu(Playlist playlist) {
    SkinPopupMenu starredPlaylistPopupMenu = new SkinPopupMenu();
    final List<PlaylistItem> items = playlist.getItems();
    boolean playlistEmpty = items == null || items.size() == 0;
    if (!playlistEmpty) {
        starredPlaylistPopupMenu.add(new SkinMenuItem(actions[CLEANUP_PLAYLIST_ACTION]));
    }
    starredPlaylistPopupMenu.add(new SkinMenuItem(actions[REFRESH_ACTION]));
    if (!playlistEmpty) {
        starredPlaylistPopupMenu.add(new SkinMenuItem(actions[REFRESH_ID3_TAGS_ACTION]));
    }
    starredPlaylistPopupMenu.addSeparator();
    starredPlaylistPopupMenu.add(new SkinMenuItem(actions[IMPORT_TO_PLAYLIST_ACTION]));
    addExportActionsToPopupMenu(starredPlaylistPopupMenu, playlistEmpty);
    starredPlaylistPopupMenu.addSeparator();
    starredPlaylistPopupMenu.add(new SkinMenuItem(actions[CONFIGURE_OPTIONS_ACTION]));
    return starredPlaylistPopupMenu;
}
Also used : SkinMenuItem(com.frostwire.gui.theme.SkinMenuItem) SkinPopupMenu(com.frostwire.gui.theme.SkinPopupMenu) PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 4 with PlaylistItem

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

the class LibraryPlaylistsTableMediator method removeSelection.

/**
 * Delete selected items from a playlist (not from disk)
 */
public void removeSelection() {
    LibraryPlaylistsTableDataLine[] lines = getSelectedLibraryLines();
    if (currentPlaylist != null && currentPlaylist.getId() == LibraryDatabase.STARRED_PLAYLIST_ID) {
        for (LibraryPlaylistsTableDataLine line : lines) {
            PlaylistItem playlistItem = line.getInitializeObject();
            playlistItem.setStarred(false);
            playlistItem.save(true);
        }
        LibraryMediator.instance().getLibraryExplorer().refreshSelection();
    } else {
        for (LibraryPlaylistsTableDataLine line : lines) {
            PlaylistItem playlistItem = line.getInitializeObject();
            playlistItem.delete();
        }
        LibraryMediator.instance().getLibraryPlaylists().reselectPlaylist();
        clearSelection();
    }
    super.removeSelection();
}
Also used : PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Example 5 with PlaylistItem

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

the class LibraryPlaylistsTableMediator method createLyricsPanel.

private JPanel createLyricsPanel(String lyrics) {
    int[] sel = TABLE.getSelectedRows();
    String songTitle = "";
    if (sel.length == 1) {
        PlaylistItem playlistItem = currentPlaylist.getItems().get(sel[0]);
        songTitle = playlistItem.getTrackTitle() + " ";
    }
    JPanel lyricsPanel = new JPanel(new MigLayout("fillx, wrap 1, insets 0", "[]"));
    lyricsPanel.add(new JLabel(songTitle + I18n.tr("Lyrics")), "wrap");
    JTextArea lyricsTextArea = new JTextArea(lyrics);
    lyricsTextArea.setEditable(false);
    JScrollPane scrollPane = new JScrollPane(lyricsTextArea);
    Dimension d = new Dimension(500, 210);
    scrollPane.setPreferredSize(d);
    scrollPane.setMaximumSize(d);
    scrollPane.setMaximumSize(d);
    lyricsPanel.add(scrollPane, "growx");
    return lyricsPanel;
}
Also used : MigLayout(net.miginfocom.swing.MigLayout) PlaylistItem(com.frostwire.alexandria.PlaylistItem)

Aggregations

PlaylistItem (com.frostwire.alexandria.PlaylistItem)28 ArrayList (java.util.ArrayList)8 File (java.io.File)7 Transferable (java.awt.datatransfer.Transferable)4 Playlist (com.frostwire.alexandria.Playlist)3 Item (com.frostwire.gui.library.LibraryPlaylistsTableTransferable.Item)3 List (java.util.List)3 TagsReader (com.frostwire.gui.library.tags.TagsReader)2 SkinMenuItem (com.frostwire.gui.theme.SkinMenuItem)2 SkinPopupMenu (com.frostwire.gui.theme.SkinPopupMenu)2 MigLayout (net.miginfocom.swing.MigLayout)2 TagsData (com.frostwire.gui.library.tags.TagsData)1 IsoFile (com.frostwire.mp4.IsoFile)1 FileTransferable (com.limegroup.gnutella.gui.dnd.FileTransferable)1 DataFlavor (java.awt.datatransfer.DataFlavor)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 HashSet (java.util.HashSet)1