2009-01-04 13:28:28 -05:00
|
|
|
|
2008-12-31 15:11:27 -05:00
|
|
|
package net.sourceforge.filebot;
|
2009-01-04 13:28:28 -05:00
|
|
|
|
|
|
|
|
2009-03-13 20:30:24 -04:00
|
|
|
import static javax.swing.JFrame.*;
|
|
|
|
|
2009-01-11 16:23:03 -05:00
|
|
|
import java.util.logging.ConsoleHandler;
|
2008-02-13 15:08:06 -05:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
2009-03-13 20:30:24 -04:00
|
|
|
import javax.swing.JFrame;
|
2007-12-23 14:28:04 -05:00
|
|
|
import javax.swing.SwingUtilities;
|
|
|
|
import javax.swing.UIManager;
|
|
|
|
|
2009-03-13 20:30:24 -04:00
|
|
|
import net.sourceforge.filebot.ui.MainFrame;
|
2008-12-28 15:04:13 -05:00
|
|
|
import net.sourceforge.filebot.ui.NotificationLoggingHandler;
|
2009-03-13 20:30:24 -04:00
|
|
|
import net.sourceforge.filebot.ui.SinglePanelFrame;
|
|
|
|
import net.sourceforge.filebot.ui.panel.analyze.AnalyzePanelBuilder;
|
|
|
|
import net.sourceforge.filebot.ui.panel.sfv.SfvPanelBuilder;
|
2008-07-30 18:37:01 -04:00
|
|
|
import org.kohsuke.args4j.CmdLineException;
|
|
|
|
import org.kohsuke.args4j.CmdLineParser;
|
2007-12-23 14:28:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
public class Main {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param args
|
|
|
|
*/
|
2009-01-24 19:08:57 -05:00
|
|
|
public static void main(String... args) throws Exception {
|
2008-02-13 15:08:06 -05:00
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
final ArgumentBean argumentBean = initializeArgumentBean(args);
|
2008-03-19 18:14:38 -04:00
|
|
|
|
2009-03-13 20:30:24 -04:00
|
|
|
if (argumentBean.help()) {
|
2009-01-24 19:08:57 -05:00
|
|
|
printUsage(argumentBean);
|
|
|
|
|
|
|
|
// just print help message and exit afterwards
|
|
|
|
System.exit(0);
|
|
|
|
}
|
|
|
|
|
2009-03-13 20:30:24 -04:00
|
|
|
if (argumentBean.clear()) {
|
2009-01-24 19:08:57 -05:00
|
|
|
// clear preferences
|
|
|
|
Settings.userRoot().clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
initializeLogging();
|
|
|
|
initializeSettings();
|
2009-01-04 13:28:28 -05:00
|
|
|
|
2007-12-23 14:28:04 -05:00
|
|
|
try {
|
2008-10-19 14:51:45 -04:00
|
|
|
// UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
|
2008-12-28 15:04:13 -05:00
|
|
|
// UIManager.setLookAndFeel("a03.swing.plaf.A03LookAndFeel");
|
|
|
|
// UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceBusinessBlueSteelLookAndFeel");
|
|
|
|
// UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceNebulaBrickWallLookAndFeel");
|
|
|
|
// UIManager.setLookAndFeel("org.jvnet.substance.skin.SubstanceSaharaLookAndFeel");
|
|
|
|
|
2007-12-23 14:28:04 -05:00
|
|
|
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
|
|
|
|
} catch (Exception e) {
|
2008-12-28 15:04:13 -05:00
|
|
|
Logger.getLogger("global").log(Level.SEVERE, e.toString(), e);
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
SwingUtilities.invokeLater(new Runnable() {
|
|
|
|
|
2008-03-19 18:14:38 -04:00
|
|
|
@Override
|
2007-12-23 14:28:04 -05:00
|
|
|
public void run() {
|
2009-03-13 20:30:24 -04:00
|
|
|
JFrame frame;
|
|
|
|
|
|
|
|
if (argumentBean.analyze()) {
|
|
|
|
frame = new SinglePanelFrame(new AnalyzePanelBuilder()).publish(argumentBean.transferable());
|
|
|
|
} else if (argumentBean.sfv()) {
|
|
|
|
frame = new SinglePanelFrame(new SfvPanelBuilder()).publish(argumentBean.transferable());
|
|
|
|
} else {
|
|
|
|
// default
|
|
|
|
frame = new MainFrame();
|
|
|
|
}
|
2008-06-21 15:24:18 -04:00
|
|
|
|
2009-03-13 20:30:24 -04:00
|
|
|
frame.setLocationByPlatform(true);
|
|
|
|
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
|
2008-06-21 15:24:18 -04:00
|
|
|
|
|
|
|
// start
|
2009-03-13 20:30:24 -04:00
|
|
|
frame.setVisible(true);
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2008-03-19 18:14:38 -04:00
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
private static void initializeLogging() {
|
2008-12-28 15:04:13 -05:00
|
|
|
Logger uiLogger = Logger.getLogger("ui");
|
2009-01-11 16:23:03 -05:00
|
|
|
|
|
|
|
// don't use parent handlers
|
2008-12-28 15:04:13 -05:00
|
|
|
uiLogger.setUseParentHandlers(false);
|
2009-01-11 16:23:03 -05:00
|
|
|
|
|
|
|
// ui handler
|
|
|
|
uiLogger.addHandler(new NotificationLoggingHandler());
|
|
|
|
|
|
|
|
// console handler (for warnings and errors only)
|
|
|
|
ConsoleHandler consoleHandler = new ConsoleHandler();
|
|
|
|
consoleHandler.setLevel(Level.WARNING);
|
|
|
|
|
|
|
|
uiLogger.addHandler(consoleHandler);
|
2008-12-28 15:04:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
private static void initializeSettings() {
|
|
|
|
Settings.userRoot().putDefault("thetvdb.apikey", "58B4AA94C59AD656");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static ArgumentBean initializeArgumentBean(String... args) throws CmdLineException {
|
2008-07-30 18:37:01 -04:00
|
|
|
ArgumentBean argumentBean = new ArgumentBean();
|
2008-03-19 18:14:38 -04:00
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
new CmdLineParser(argumentBean).parseArgument(args);
|
2008-12-28 15:04:13 -05:00
|
|
|
|
2008-07-30 18:37:01 -04:00
|
|
|
return argumentBean;
|
2008-03-19 18:14:38 -04:00
|
|
|
}
|
2008-10-11 16:42:03 -04:00
|
|
|
|
2009-01-24 19:08:57 -05:00
|
|
|
|
|
|
|
private static void printUsage(ArgumentBean argumentBean) {
|
|
|
|
System.out.println("Options:");
|
|
|
|
|
|
|
|
new CmdLineParser(argumentBean).printUsage(System.out);
|
|
|
|
}
|
|
|
|
|
2007-12-23 14:28:04 -05:00
|
|
|
}
|