Added ability to remove entire CD.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@598 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,14 +1,16 @@
|
|||||||
//
|
//
|
||||||
// $Id: PlaylistPanel.java,v 1.9 2001/10/12 18:21:27 mdb Exp $
|
// $Id: PlaylistPanel.java,v 1.10 2002/02/22 08:37:17 mdb Exp $
|
||||||
|
|
||||||
package robodj.chooser;
|
package robodj.chooser;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import com.samskivert.io.PersistenceException;
|
import com.samskivert.io.PersistenceException;
|
||||||
import com.samskivert.swing.*;
|
import com.samskivert.swing.*;
|
||||||
import com.samskivert.swing.util.*;
|
import com.samskivert.swing.util.*;
|
||||||
@@ -95,6 +97,58 @@ public class PlaylistPanel
|
|||||||
// remove the entry UI elements
|
// remove the entry UI elements
|
||||||
JPanel epanel = (JPanel)entry.label.getParent();
|
JPanel epanel = (JPanel)entry.label.getParent();
|
||||||
epanel.getParent().remove(epanel);
|
epanel.getParent().remove(epanel);
|
||||||
|
revalidate(); // relayout
|
||||||
|
|
||||||
|
// remove the entry from the playlist
|
||||||
|
_plist.remove(entry);
|
||||||
|
|
||||||
|
// update the playing indicator because we may have removed
|
||||||
|
// the playing entry
|
||||||
|
refreshPlaying();
|
||||||
|
|
||||||
|
} else if (cmd.equals("remove_all")) {
|
||||||
|
JButton src = (JButton)e.getSource();
|
||||||
|
PlaylistEntry entry =
|
||||||
|
(PlaylistEntry)src.getClientProperty("entry");
|
||||||
|
|
||||||
|
// remove all entries starting with this one until we get to
|
||||||
|
// one that has a different entryid
|
||||||
|
int count = 0;
|
||||||
|
Iterator iter = _plist.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
PlaylistEntry pe = (PlaylistEntry)iter.next();
|
||||||
|
if (entry == pe) {
|
||||||
|
count++;
|
||||||
|
// remove the entry UI elements
|
||||||
|
JPanel epanel = (JPanel)pe.label.getParent();
|
||||||
|
epanel.getParent().remove(epanel);
|
||||||
|
// remove the entry
|
||||||
|
iter.remove();
|
||||||
|
|
||||||
|
} else if (count > 0) {
|
||||||
|
if (pe.entry.entryid == entry.entry.entryid) {
|
||||||
|
count++;
|
||||||
|
// remove the entry UI elements
|
||||||
|
JPanel epanel = (JPanel)pe.label.getParent();
|
||||||
|
epanel.getParent().remove(epanel);
|
||||||
|
// remove the entry
|
||||||
|
iter.remove();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// we hit an entry that doesn't match, bail
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// remove the title and stuff
|
||||||
|
JPanel tpanel = (JPanel)src.getParent();
|
||||||
|
tpanel.getParent().remove(tpanel);
|
||||||
|
|
||||||
|
revalidate(); // relayout
|
||||||
|
|
||||||
|
// now tell the music daemon to remove these entries
|
||||||
|
Chooser.scontrol.removeGroup(entry.song.songid, count);
|
||||||
|
|
||||||
// update the playing indicator because we may have removed
|
// update the playing indicator because we may have removed
|
||||||
// the playing entry
|
// the playing entry
|
||||||
@@ -213,14 +267,24 @@ public class PlaylistPanel
|
|||||||
String title = null;
|
String title = null;
|
||||||
for (int i = 0; i < _plist.size(); i++) {
|
for (int i = 0; i < _plist.size(); i++) {
|
||||||
PlaylistEntry entry = (PlaylistEntry)_plist.get(i);
|
PlaylistEntry entry = (PlaylistEntry)_plist.get(i);
|
||||||
|
JButton button;
|
||||||
|
|
||||||
// add record/artist indicators when the record and artist
|
// add record/artist indicators when the record and artist
|
||||||
// changes
|
// changes
|
||||||
if (!entry.entry.title.equals(title)) {
|
if (!entry.entry.title.equals(title)) {
|
||||||
|
JPanel tpanel = new JPanel();
|
||||||
|
gl = new HGroupLayout(GroupLayout.NONE);
|
||||||
|
gl.setOffAxisPolicy(GroupLayout.STRETCH);
|
||||||
|
gl.setJustification(GroupLayout.LEFT);
|
||||||
|
tpanel.setLayout(gl);
|
||||||
|
|
||||||
title = entry.entry.title;
|
title = entry.entry.title;
|
||||||
JLabel label = new JLabel(entry.entry.title + " - " +
|
JLabel label = new JLabel(entry.entry.title + " - " +
|
||||||
entry.entry.artist);
|
entry.entry.artist);
|
||||||
_bpanel.add(label);
|
tpanel.add(label);
|
||||||
|
tpanel.add(newButton("Remove", "remove_all", entry));
|
||||||
|
|
||||||
|
_bpanel.add(tpanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
// create a browse and a play button
|
// create a browse and a play button
|
||||||
@@ -236,20 +300,8 @@ public class PlaylistPanel
|
|||||||
entry.label.setFont(_nameFont);
|
entry.label.setFont(_nameFont);
|
||||||
hpanel.add(entry.label);
|
hpanel.add(entry.label);
|
||||||
|
|
||||||
JButton button;
|
hpanel.add(newButton("Skip to", "skipto", entry));
|
||||||
button = new JButton("Skip to");
|
hpanel.add(newButton("Remove", "remove", entry));
|
||||||
button.setFont(_nameFont);
|
|
||||||
button.setActionCommand("skipto");
|
|
||||||
button.addActionListener(this);
|
|
||||||
button.putClientProperty("entry", entry);
|
|
||||||
hpanel.add(button);
|
|
||||||
|
|
||||||
button = new JButton("Remove");
|
|
||||||
button.setActionCommand("remove");
|
|
||||||
button.setFont(_nameFont);
|
|
||||||
button.addActionListener(this);
|
|
||||||
button.putClientProperty("entry", entry);
|
|
||||||
hpanel.add(button);
|
|
||||||
|
|
||||||
// let the bpanel know that we want to scroll the active track
|
// let the bpanel know that we want to scroll the active track
|
||||||
// label into place once we're all laid out
|
// label into place once we're all laid out
|
||||||
@@ -270,6 +322,17 @@ public class PlaylistPanel
|
|||||||
_bpanel.revalidate();
|
_bpanel.revalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected JButton newButton (String label, String command,
|
||||||
|
Object clientProperty)
|
||||||
|
{
|
||||||
|
JButton button = new JButton(label);
|
||||||
|
button.setFont(_nameFont);
|
||||||
|
button.setActionCommand(command);
|
||||||
|
button.addActionListener(this);
|
||||||
|
button.putClientProperty("entry", clientProperty);
|
||||||
|
return button;
|
||||||
|
}
|
||||||
|
|
||||||
protected void highlightPlaying ()
|
protected void highlightPlaying ()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _plist.size(); i++) {
|
for (int i = 0; i < _plist.size(); i++) {
|
||||||
@@ -278,6 +341,7 @@ public class PlaylistPanel
|
|||||||
entry.label.setForeground(Color.red);
|
entry.label.setForeground(Color.red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PlaylistEntry getPlayingEntry ()
|
protected PlaylistEntry getPlayingEntry ()
|
||||||
|
|||||||
Reference in New Issue
Block a user