Added ability to pop back to previous panels. Only the first two panels

are wired up properly to support this. I may do so for later panels if it
seems useful.


git-svn-id: https://samskivert.googlecode.com/svn/trunk@637 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-03-03 21:17:03 +00:00
parent ed488b3a97
commit 8dee2816b1
9 changed files with 110 additions and 43 deletions
+11 -2
View File
@@ -1,10 +1,19 @@
RoboDJ 1.2 (March 02, 2002) RoboDJ 1.2 (March 03, 2002)
NEW FEATURES NEW FEATURES
* (importer) Added support for adding ID3 tags to MP3 files after * (importer) Added support for adding ID3 tags to MP3 files after
they are encoded. they are encoded.
* (chooser) Gave the UI a major facelift:
- added icons for most buttons;
- fixed layout to work more nicely;
- made controls reflect actual state of the music daemon (paused
versus playing, etc.).
* (importer) Added ability to back up from the CDDB panel to the
"insert CD" panel.
RoboDJ 1.1 (February 22, 2002) RoboDJ 1.1 (February 22, 2002)
NEW FEATURES NEW FEATURES
@@ -19,4 +28,4 @@ RoboDJ 1.0 (February 21, 2002)
INITIAL RELEASE INITIAL RELEASE
$Id: NEWS,v 1.1 2002/03/03 06:21:19 mdb Exp $ $Id: NEWS,v 1.2 2002/03/03 21:17:03 mdb Exp $
+6
View File
@@ -1,3 +1,9 @@
robodj (1.2-2) unstable; urgency=low
* Upstream release updated with more features.
-- Michael Bayne <mdb@samskivert.com> Sun, 3 Mar 2002 12:59:12 -0800
robodj (1.2-1) unstable; urgency=low robodj (1.2-1) unstable; urgency=low
* New upstream release. * New upstream release.
@@ -1,5 +1,5 @@
// //
// $Id: CDDBLookupPanel.java,v 1.4 2001/06/10 21:32:23 mdb Exp $ // $Id: CDDBLookupPanel.java,v 1.5 2002/03/03 21:17:03 mdb Exp $
package robodj.importer; package robodj.importer;
@@ -54,31 +54,26 @@ public class CDDBLookupPanel
add(_spanel); add(_spanel);
} }
public void wasAddedToFrame (ImporterFrame frame) public void wasAddedToFrame (ImporterFrame frame, boolean popped)
{ {
// keep this for later // keep this for later
_frame = frame; _frame = frame;
frame.addControlButton("Cancel", "cancel", this); frame.addControlButton("Cancel", "cancel", this);
frame.addControlButton("Back", "back", this);
_next = frame.addControlButton("Next...", "next", this); _next = frame.addControlButton("Next...", "next", this);
_next.setEnabled(false); _next.setEnabled(popped);
// if we are being shown for the first time...
if (!popped) {
// create our info task and set it a running // create our info task and set it a running
Task infoTask = new Task() TaskMaster.invokeTask("getinfo", new TaskAdapter() {
{ public Object invoke () throws Exception {
public Object invoke ()
throws Exception
{
Ripper ripper = new CDParanoiaRipper(); Ripper ripper = new CDParanoiaRipper();
return ripper.getTrackInfo(); return ripper.getTrackInfo();
} }
}, this);
public boolean abort ()
{
return false;
} }
};
TaskMaster.invokeTask("getinfo", infoTask, this);
} }
public void taskCompleted (String name, Object result) public void taskCompleted (String name, Object result)
@@ -141,6 +136,10 @@ public class CDDBLookupPanel
if (cmd.equals("cancel")) { if (cmd.equals("cancel")) {
System.exit(0); System.exit(0);
} else if (cmd.equals("back")) {
// pop back to the last panel
_frame.popPanel();
} else if (cmd.equals("next")) { } else if (cmd.equals("next")) {
extractEntryAndContinue(); extractEntryAndContinue();
@@ -175,7 +174,7 @@ public class CDDBLookupPanel
} }
// create the rip panel and pass the entry and info along // create the rip panel and pass the entry and info along
_frame.setPanel(new RipPanel(_info, entry)); _frame.pushPanel(new RipPanel(_info, entry));
} }
protected boolean validate (String value, String errmsg) protected boolean validate (String value, String errmsg)
@@ -1,5 +1,5 @@
// //
// $Id: FinishedPanel.java,v 1.3 2001/06/07 08:42:09 mdb Exp $ // $Id: FinishedPanel.java,v 1.4 2002/03/03 21:17:03 mdb Exp $
package robodj.importer; package robodj.importer;
@@ -52,7 +52,7 @@ public class FinishedPanel
_entry = entry; _entry = entry;
} }
public void wasAddedToFrame (ImporterFrame frame) public void wasAddedToFrame (ImporterFrame frame, boolean popped)
{ {
frame.addControlButton("Exit", "exit", this); frame.addControlButton("Exit", "exit", this);
frame.addControlButton("Another", "import", this); frame.addControlButton("Another", "import", this);
@@ -1,5 +1,5 @@
// //
// $Id: Importer.java,v 1.9 2002/01/17 18:22:53 mdb Exp $ // $Id: Importer.java,v 1.10 2002/03/03 21:17:03 mdb Exp $
package robodj.importer; package robodj.importer;
@@ -68,7 +68,7 @@ public class Importer
// create our frame and first panel // create our frame and first panel
ImporterFrame frame = new ImporterFrame(); ImporterFrame frame = new ImporterFrame();
InsertCDPanel panel = new InsertCDPanel(); InsertCDPanel panel = new InsertCDPanel();
frame.setPanel(panel); frame.pushPanel(panel);
// center the frame in the screen and show it // center the frame in the screen and show it
frame.setSize(640, 480); frame.setSize(640, 480);
@@ -1,10 +1,11 @@
// //
// $Id: ImporterFrame.java,v 1.7 2002/03/03 06:32:12 mdb Exp $ // $Id: ImporterFrame.java,v 1.8 2002/03/03 21:17:03 mdb Exp $
package robodj.importer; package robodj.importer;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.ArrayList;
import javax.swing.*; import javax.swing.*;
import com.samskivert.swing.*; import com.samskivert.swing.*;
@@ -41,10 +42,25 @@ public class ImporterFrame extends JFrame
getContentPane().add(_top, BorderLayout.CENTER); getContentPane().add(_top, BorderLayout.CENTER);
} }
/**
* Clears out the panel stack and pushes the specified panel onto the
* fresh stack.
*/
public void setPanel (ImporterPanel panel) public void setPanel (ImporterPanel panel)
{ {
// clear out any old panel _panels.clear();
pushPanel(panel);
}
/**
* Pushes the specified panel onto the stack (removing the previous
* panel and keeping it around in case we want to go back to it.
*/
public void pushPanel (ImporterPanel panel)
{
// push the current panel onto the stack
if (_panel != null) { if (_panel != null) {
_panels.add(_panel);
_top.remove(_panel); _top.remove(_panel);
} }
@@ -56,11 +72,40 @@ public class ImporterFrame extends JFrame
_panel = panel; _panel = panel;
_top.add(_panel, 0); _top.add(_panel, 0);
// let the panel know that it was added // let the panel know that it was added
_panel.wasAddedToFrame(this); _panel.wasAddedToFrame(this, false);
} }
// and lay out the new panel // and lay out the new panel
validate(); validate();
repaint();
}
/**
* Pops back to the previous panel on the stack.
*/
public void popPanel ()
{
// remove the old panel
if (_panel != null) {
_top.remove(_panel);
}
// clear out old control buttons
clearControlButtons();
// now pop the last panel from the stack
int pcount = _panels.size();
if (pcount > 0) {
_panel = (ImporterPanel)_panels.get(pcount-1);
_panels.remove(pcount-1);
_top.add(_panel, 0);
// let the panel know that it was added
_panel.wasAddedToFrame(this, true);
}
// and lay out the new panel
validate();
repaint();
} }
public JButton addControlButton (String label, String command, public JButton addControlButton (String label, String command,
@@ -72,7 +117,7 @@ public class ImporterFrame extends JFrame
_buttonPanel.add(abutton); _buttonPanel.add(abutton);
// swing doesn't automatically validate after adding/removing // swing doesn't automatically validate after adding/removing
// children // children
_buttonPanel.revalidate(); _buttonPanel.validate();
return abutton; return abutton;
} }
@@ -81,10 +126,12 @@ public class ImporterFrame extends JFrame
_buttonPanel.removeAll(); _buttonPanel.removeAll();
// swing doesn't automatically validate after adding/removing // swing doesn't automatically validate after adding/removing
// children // children
_buttonPanel.revalidate(); _buttonPanel.validate();
} }
protected ImporterPanel _panel; protected ImporterPanel _panel;
protected JPanel _top; protected JPanel _top;
protected JPanel _buttonPanel; protected JPanel _buttonPanel;
protected ArrayList _panels = new ArrayList();
} }
@@ -1,5 +1,5 @@
// //
// $Id: ImporterPanel.java,v 1.1 2000/12/10 07:02:09 mdb Exp $ // $Id: ImporterPanel.java,v 1.2 2002/03/03 21:17:03 mdb Exp $
package robodj.importer; package robodj.importer;
@@ -20,6 +20,10 @@ public abstract class ImporterPanel extends JPanel
/** /**
* When an importer panel is added to the importer frame, it is * When an importer panel is added to the importer frame, it is
* notified so that it can create the appropriate control buttons. * notified so that it can create the appropriate control buttons.
*
* @param frame a reference to the importer frame.
* @param popped if true, this panel was popped from the stack rather
* than added to the frame for the first time.
*/ */
public abstract void wasAddedToFrame (ImporterFrame frame); public abstract void wasAddedToFrame (ImporterFrame frame, boolean popped);
} }
@@ -1,5 +1,5 @@
// //
// $Id: InsertCDPanel.java,v 1.2 2001/03/21 00:41:03 mdb Exp $ // $Id: InsertCDPanel.java,v 1.3 2002/03/03 21:17:03 mdb Exp $
package robodj.importer; package robodj.importer;
@@ -33,7 +33,7 @@ public class InsertCDPanel
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
} }
public void wasAddedToFrame (ImporterFrame frame) public void wasAddedToFrame (ImporterFrame frame, boolean popped)
{ {
frame.addControlButton("Cancel", "cancel", this); frame.addControlButton("Cancel", "cancel", this);
frame.addControlButton("Next...", "next", this); frame.addControlButton("Next...", "next", this);
@@ -49,7 +49,7 @@ public class InsertCDPanel
System.exit(0); System.exit(0);
} else if (cmd.equals("next")) { } else if (cmd.equals("next")) {
_frame.setPanel(new CDDBLookupPanel()); _frame.pushPanel(new CDDBLookupPanel());
} else { } else {
System.out.println("Unknown action event: " + cmd); System.out.println("Unknown action event: " + cmd);
@@ -1,5 +1,5 @@
// //
// $Id: RipPanel.java,v 1.6 2002/03/03 06:04:56 mdb Exp $ // $Id: RipPanel.java,v 1.7 2002/03/03 21:17:03 mdb Exp $
package robodj.importer; package robodj.importer;
@@ -350,7 +350,7 @@ public class RipPanel
protected Ripper.TrackInfo[] _info; protected Ripper.TrackInfo[] _info;
} }
public void wasAddedToFrame (ImporterFrame frame) public void wasAddedToFrame (ImporterFrame frame, boolean popped)
{ {
// keep this for later // keep this for later
_frame = frame; _frame = frame;
@@ -358,12 +358,14 @@ public class RipPanel
// add our next and cancel buttons // add our next and cancel buttons
_cancel = frame.addControlButton("Cancel", "cancel", this); _cancel = frame.addControlButton("Cancel", "cancel", this);
_next = frame.addControlButton("Next...", "next", this); _next = frame.addControlButton("Next...", "next", this);
_next.setEnabled(false); _next.setEnabled(popped);
if (!popped) {
// create our info task and set it a running // create our info task and set it a running
Task ripTask = new RipperTask(_info, _entry); Task ripTask = new RipperTask(_info, _entry);
TaskMaster.invokeTask("convert", ripTask, this); TaskMaster.invokeTask("convert", ripTask, this);
} }
}
public void taskCompleted (String name, Object result) public void taskCompleted (String name, Object result)
{ {
@@ -398,7 +400,7 @@ public class RipPanel
System.exit(0); System.exit(0);
} else if (cmd.equals("next")) { } else if (cmd.equals("next")) {
_frame.setPanel(new FinishedPanel(_entry)); _frame.pushPanel(new FinishedPanel(_entry));
} else { } else {
System.out.println("Unknown action event: " + cmd); System.out.println("Unknown action event: " + cmd);