Use the new preferences system.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@1122 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: Importer.java,v 1.10 2002/03/03 21:17:03 mdb Exp $
|
// $Id: Importer.java,v 1.11 2003/05/07 17:27:39 mdb Exp $
|
||||||
|
|
||||||
package robodj.importer;
|
package robodj.importer;
|
||||||
|
|
||||||
@@ -8,17 +8,19 @@ import java.awt.Toolkit;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
|
|
||||||
import com.samskivert.io.PersistenceException;
|
import com.samskivert.io.PersistenceException;
|
||||||
import com.samskivert.jdbc.StaticConnectionProvider;
|
import com.samskivert.jdbc.StaticConnectionProvider;
|
||||||
|
|
||||||
import com.samskivert.swing.util.SwingUtil;
|
import com.samskivert.swing.util.SwingUtil;
|
||||||
import com.samskivert.util.ConfigUtil;
|
import com.samskivert.util.ConfigUtil;
|
||||||
import com.samskivert.util.PropertiesUtil;
|
import com.samskivert.util.PropertiesUtil;
|
||||||
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import robodj.Log;
|
import robodj.Log;
|
||||||
import robodj.repository.Repository;
|
import robodj.repository.Repository;
|
||||||
|
import robodj.util.RDJPrefs;
|
||||||
|
import robodj.util.RDJPrefsPanel;
|
||||||
|
import robodj.util.ErrorUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The importer is the GUI-based application for ripping, encoding and
|
* The importer is the GUI-based application for ripping, encoding and
|
||||||
@@ -32,37 +34,35 @@ public class Importer
|
|||||||
*/
|
*/
|
||||||
public static final String ENTRY_SOURCE = "CD";
|
public static final String ENTRY_SOURCE = "CD";
|
||||||
|
|
||||||
public static Properties config;
|
|
||||||
|
|
||||||
public static Repository repository;
|
public static Repository repository;
|
||||||
|
|
||||||
public static void main (String[] args)
|
public static void main (String[] args)
|
||||||
{
|
{
|
||||||
// load our main configuration
|
// loop until the user provides us with a configuration that works
|
||||||
String cpath = "conf/importer.properties";
|
// or requests to exit
|
||||||
try {
|
for (int ii = 0; ii < 100; ii++) {
|
||||||
config = ConfigUtil.loadProperties(cpath);
|
String repodir = RDJPrefs.getRepositoryDirectory();
|
||||||
} catch (IOException ioe) {
|
if (StringUtil.blank(repodir) || ii > 0) {
|
||||||
String err = "Unable to load configuration " +
|
// display the initial configuration wizard if we are not
|
||||||
"[path=" + cpath + "]: " + ioe;
|
// yet properly configured
|
||||||
reportError(err);
|
RDJPrefsPanel.display(true);
|
||||||
System.exit(-1);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// create an interface to the database repository
|
// create an interface to the database repository
|
||||||
try {
|
try {
|
||||||
StaticConnectionProvider scp =
|
StaticConnectionProvider scp =
|
||||||
new StaticConnectionProvider("conf/repository.properties");
|
new StaticConnectionProvider(RDJPrefs.getJDBCConfig());
|
||||||
repository = new Repository(scp);
|
repository = new Repository(scp);
|
||||||
|
|
||||||
} catch (IOException ioe) {
|
} catch (PersistenceException pe) {
|
||||||
reportError("Error loading repository config: " + ioe);
|
String errmsg = "Unable to communicate with database:";
|
||||||
System.exit(-1);
|
if (ErrorUtil.reportError(errmsg, pe)) {
|
||||||
|
System.exit(-1);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (PersistenceException pe) {
|
break;
|
||||||
reportError("Unable to establish communication " +
|
|
||||||
"with music database: " + pe);
|
|
||||||
System.exit(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create our frame and first panel
|
// create our frame and first panel
|
||||||
@@ -76,12 +76,4 @@ public class Importer
|
|||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void reportError (String error)
|
|
||||||
{
|
|
||||||
Object[] options = { "OK" };
|
|
||||||
JOptionPane.showOptionDialog(null, error, "Error",
|
|
||||||
JOptionPane.DEFAULT_OPTION,
|
|
||||||
JOptionPane.ERROR_MESSAGE,
|
|
||||||
null, options, options[0]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: RipPanel.java,v 1.9 2003/05/04 18:16:07 mdb Exp $
|
// $Id: RipPanel.java,v 1.10 2003/05/07 17:27:40 mdb Exp $
|
||||||
|
|
||||||
package robodj.importer;
|
package robodj.importer;
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ import com.samskivert.util.StringUtil;
|
|||||||
import robodj.Log;
|
import robodj.Log;
|
||||||
import robodj.convert.*;
|
import robodj.convert.*;
|
||||||
import robodj.repository.*;
|
import robodj.repository.*;
|
||||||
|
import robodj.util.RDJPrefs;
|
||||||
|
|
||||||
public class RipPanel
|
public class RipPanel
|
||||||
extends ImporterPanel
|
extends ImporterPanel
|
||||||
@@ -98,7 +99,7 @@ public class RipPanel
|
|||||||
|
|
||||||
protected static String createTempPath (int trackno, String ext)
|
protected static String createTempPath (int trackno, String ext)
|
||||||
{
|
{
|
||||||
String rbase = Importer.config.getProperty("repository.tmpdir");
|
String rbase = RDJPrefs.getRepositoryTemp();
|
||||||
return rbase + "/track" + trackno + "." + ext;
|
return rbase + "/track" + trackno + "." + ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,8 +215,7 @@ public class RipPanel
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// determine the target directory for the mp3 files
|
// determine the target directory for the mp3 files
|
||||||
String rbase =
|
String rbase = RDJPrefs.getRepositoryDirectory();
|
||||||
Importer.config.getProperty("repository.basedir");
|
|
||||||
if (StringUtil.blank(rbase)) {
|
if (StringUtil.blank(rbase)) {
|
||||||
throw new Exception("No mp3 repository directory " +
|
throw new Exception("No mp3 repository directory " +
|
||||||
"specified.");
|
"specified.");
|
||||||
|
|||||||
Reference in New Issue
Block a user