From 8dee2816b12d64a87f46cc645ac8d4bca7b74cb8 Mon Sep 17 00:00:00 2001 From: mdb Date: Sun, 3 Mar 2002 21:17:03 +0000 Subject: [PATCH] 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 --- projects/robodj/NEWS | 13 ++++- projects/robodj/debian/changelog | 6 ++ .../java/robodj/importer/CDDBLookupPanel.java | 39 +++++++------ .../java/robodj/importer/FinishedPanel.java | 4 +- .../src/java/robodj/importer/Importer.java | 4 +- .../java/robodj/importer/ImporterFrame.java | 57 +++++++++++++++++-- .../java/robodj/importer/ImporterPanel.java | 8 ++- .../java/robodj/importer/InsertCDPanel.java | 6 +- .../src/java/robodj/importer/RipPanel.java | 16 +++--- 9 files changed, 110 insertions(+), 43 deletions(-) diff --git a/projects/robodj/NEWS b/projects/robodj/NEWS index 1ff20e20..eafb3db3 100644 --- a/projects/robodj/NEWS +++ b/projects/robodj/NEWS @@ -1,10 +1,19 @@ -RoboDJ 1.2 (March 02, 2002) +RoboDJ 1.2 (March 03, 2002) NEW FEATURES * (importer) Added support for adding ID3 tags to MP3 files after 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) NEW FEATURES @@ -19,4 +28,4 @@ RoboDJ 1.0 (February 21, 2002) 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 $ diff --git a/projects/robodj/debian/changelog b/projects/robodj/debian/changelog index 0b816e82..07ab3fdb 100644 --- a/projects/robodj/debian/changelog +++ b/projects/robodj/debian/changelog @@ -1,3 +1,9 @@ +robodj (1.2-2) unstable; urgency=low + + * Upstream release updated with more features. + + -- Michael Bayne Sun, 3 Mar 2002 12:59:12 -0800 + robodj (1.2-1) unstable; urgency=low * New upstream release. diff --git a/projects/robodj/src/java/robodj/importer/CDDBLookupPanel.java b/projects/robodj/src/java/robodj/importer/CDDBLookupPanel.java index 17dbf53d..6eda5b65 100644 --- a/projects/robodj/src/java/robodj/importer/CDDBLookupPanel.java +++ b/projects/robodj/src/java/robodj/importer/CDDBLookupPanel.java @@ -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; @@ -54,31 +54,26 @@ public class CDDBLookupPanel add(_spanel); } - public void wasAddedToFrame (ImporterFrame frame) + public void wasAddedToFrame (ImporterFrame frame, boolean popped) { // keep this for later _frame = frame; frame.addControlButton("Cancel", "cancel", this); + frame.addControlButton("Back", "back", this); _next = frame.addControlButton("Next...", "next", this); - _next.setEnabled(false); + _next.setEnabled(popped); - // create our info task and set it a running - Task infoTask = new Task() - { - public Object invoke () - throws Exception - { - Ripper ripper = new CDParanoiaRipper(); - return ripper.getTrackInfo(); - } - - public boolean abort () - { - return false; - } - }; - TaskMaster.invokeTask("getinfo", infoTask, this); + // if we are being shown for the first time... + if (!popped) { + // create our info task and set it a running + TaskMaster.invokeTask("getinfo", new TaskAdapter() { + public Object invoke () throws Exception { + Ripper ripper = new CDParanoiaRipper(); + return ripper.getTrackInfo(); + } + }, this); + } } public void taskCompleted (String name, Object result) @@ -141,6 +136,10 @@ public class CDDBLookupPanel if (cmd.equals("cancel")) { System.exit(0); + } else if (cmd.equals("back")) { + // pop back to the last panel + _frame.popPanel(); + } else if (cmd.equals("next")) { extractEntryAndContinue(); @@ -175,7 +174,7 @@ public class CDDBLookupPanel } // 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) diff --git a/projects/robodj/src/java/robodj/importer/FinishedPanel.java b/projects/robodj/src/java/robodj/importer/FinishedPanel.java index d90aa727..7be69924 100644 --- a/projects/robodj/src/java/robodj/importer/FinishedPanel.java +++ b/projects/robodj/src/java/robodj/importer/FinishedPanel.java @@ -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; @@ -52,7 +52,7 @@ public class FinishedPanel _entry = entry; } - public void wasAddedToFrame (ImporterFrame frame) + public void wasAddedToFrame (ImporterFrame frame, boolean popped) { frame.addControlButton("Exit", "exit", this); frame.addControlButton("Another", "import", this); diff --git a/projects/robodj/src/java/robodj/importer/Importer.java b/projects/robodj/src/java/robodj/importer/Importer.java index bb1a93f7..5e6ae985 100644 --- a/projects/robodj/src/java/robodj/importer/Importer.java +++ b/projects/robodj/src/java/robodj/importer/Importer.java @@ -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; @@ -68,7 +68,7 @@ public class Importer // create our frame and first panel ImporterFrame frame = new ImporterFrame(); InsertCDPanel panel = new InsertCDPanel(); - frame.setPanel(panel); + frame.pushPanel(panel); // center the frame in the screen and show it frame.setSize(640, 480); diff --git a/projects/robodj/src/java/robodj/importer/ImporterFrame.java b/projects/robodj/src/java/robodj/importer/ImporterFrame.java index 0e1b2b13..900c5bcb 100644 --- a/projects/robodj/src/java/robodj/importer/ImporterFrame.java +++ b/projects/robodj/src/java/robodj/importer/ImporterFrame.java @@ -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; import java.awt.*; import java.awt.event.ActionListener; +import java.util.ArrayList; import javax.swing.*; import com.samskivert.swing.*; @@ -41,10 +42,25 @@ public class ImporterFrame extends JFrame getContentPane().add(_top, BorderLayout.CENTER); } + /** + * Clears out the panel stack and pushes the specified panel onto the + * fresh stack. + */ 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) { + _panels.add(_panel); _top.remove(_panel); } @@ -56,11 +72,40 @@ public class ImporterFrame extends JFrame _panel = panel; _top.add(_panel, 0); // let the panel know that it was added - _panel.wasAddedToFrame(this); + _panel.wasAddedToFrame(this, false); } // and lay out the new panel 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, @@ -72,7 +117,7 @@ public class ImporterFrame extends JFrame _buttonPanel.add(abutton); // swing doesn't automatically validate after adding/removing // children - _buttonPanel.revalidate(); + _buttonPanel.validate(); return abutton; } @@ -81,10 +126,12 @@ public class ImporterFrame extends JFrame _buttonPanel.removeAll(); // swing doesn't automatically validate after adding/removing // children - _buttonPanel.revalidate(); + _buttonPanel.validate(); } protected ImporterPanel _panel; protected JPanel _top; protected JPanel _buttonPanel; + + protected ArrayList _panels = new ArrayList(); } diff --git a/projects/robodj/src/java/robodj/importer/ImporterPanel.java b/projects/robodj/src/java/robodj/importer/ImporterPanel.java index 8b3594eb..01437769 100644 --- a/projects/robodj/src/java/robodj/importer/ImporterPanel.java +++ b/projects/robodj/src/java/robodj/importer/ImporterPanel.java @@ -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; @@ -20,6 +20,10 @@ public abstract class ImporterPanel extends JPanel /** * When an importer panel is added to the importer frame, it is * 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); } diff --git a/projects/robodj/src/java/robodj/importer/InsertCDPanel.java b/projects/robodj/src/java/robodj/importer/InsertCDPanel.java index 03f5ff0e..a2cedb5d 100644 --- a/projects/robodj/src/java/robodj/importer/InsertCDPanel.java +++ b/projects/robodj/src/java/robodj/importer/InsertCDPanel.java @@ -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; @@ -33,7 +33,7 @@ public class InsertCDPanel 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("Next...", "next", this); @@ -49,7 +49,7 @@ public class InsertCDPanel System.exit(0); } else if (cmd.equals("next")) { - _frame.setPanel(new CDDBLookupPanel()); + _frame.pushPanel(new CDDBLookupPanel()); } else { System.out.println("Unknown action event: " + cmd); diff --git a/projects/robodj/src/java/robodj/importer/RipPanel.java b/projects/robodj/src/java/robodj/importer/RipPanel.java index 3a7d7393..b43e5f6b 100644 --- a/projects/robodj/src/java/robodj/importer/RipPanel.java +++ b/projects/robodj/src/java/robodj/importer/RipPanel.java @@ -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; @@ -350,7 +350,7 @@ public class RipPanel protected Ripper.TrackInfo[] _info; } - public void wasAddedToFrame (ImporterFrame frame) + public void wasAddedToFrame (ImporterFrame frame, boolean popped) { // keep this for later _frame = frame; @@ -358,11 +358,13 @@ public class RipPanel // add our next and cancel buttons _cancel = frame.addControlButton("Cancel", "cancel", this); _next = frame.addControlButton("Next...", "next", this); - _next.setEnabled(false); + _next.setEnabled(popped); - // create our info task and set it a running - Task ripTask = new RipperTask(_info, _entry); - TaskMaster.invokeTask("convert", ripTask, this); + if (!popped) { + // create our info task and set it a running + Task ripTask = new RipperTask(_info, _entry); + TaskMaster.invokeTask("convert", ripTask, this); + } } public void taskCompleted (String name, Object result) @@ -398,7 +400,7 @@ public class RipPanel System.exit(0); } else if (cmd.equals("next")) { - _frame.setPanel(new FinishedPanel(_entry)); + _frame.pushPanel(new FinishedPanel(_entry)); } else { System.out.println("Unknown action event: " + cmd);