/* For License see bottom */
package jpianotrain;
import javax.swing.JDialog;
import jpianotrain.gui.JPianoTrainFrame;
import jpianotrain.util.ErrorHandler;
import jpianotrain.util.UserConfiguration;
import org.apache.log4j.Logger;
/**
* Here is the starting point.
* <p>
* There are some secret switches one cannot set with
* any configuration dialog. They're set via system properties.
* To set any of the parameters call the program with
* arguments of the form
* <code>-D<param-name>[=<param-value>]</code>
* <ul>
* <li><code>with.insets</code>, no value, fixes some
* *nix Window Managers subtracting window decoration
* from window size. Multiple open/close sequences move
* window closer to upper left corner</li>
* </ul>
*/
public class JPianoTrain {
// not final, because we must assign
// it once after it was initiated
private static Logger log;
public JPianoTrain() {
}
/**
* Entry point. In case of emergency
* a global try/catch will write an
* explanation to the possibly available
* log.
*/
public static void main(String[] args) {
try {
initPrerequisites();
JPianoTrain jp=new JPianoTrain();
jp.init();
jp.run();
jp.done();
} catch (Exception ex) {
if (log==null) {
ex.printStackTrace();
} else {
log.error("terminating", ex);
}
System.exit(1);
}
}
protected void init() {
UserConfiguration.getInstance().init();
log.debug("os.name="+UserConfiguration.getOsName());
// dirty hacking and definitely not portable
// across layouts with user defined decorations
if (UserConfiguration.getOsName().startsWith("Windows")) {
log.warn("activating windows frame bound behaviour");
System.getProperties().put(Constants.D_WITH_INSETS_PROPERTY, "true");
}
log.debug("creating frame");
frame=new JPianoTrainFrame();
ErrorHandler.setErrorDisplay(frame);
ApplicationContext.getInstance().setDefaultDialogOwner(frame);
log.debug("initiating frame");
frame.initGui();
}
protected void run() {
log.debug("displaying frame");
frame.setVisible(true);
}
protected void done() {
}
/**
* Init all necessary and needed systems.
* Kill the whole application with an exception
* if even one system could not be initialized.
* When this method is done everything is
* fine and from this moment on it depends
* on the user.
*/
private static void initPrerequisites() {
// Logging
log=Logger.getLogger(JPianoTrain.class);
log.debug("log initiated");
// Some window managers (FVWM on
// *nix) make a difference between
// decoration of dialogs and frames
// but we want both to be decorated,
// e.g. to have window control elements
// --Alexander Methke
JDialog.setDefaultLookAndFeelDecorated(true);
}
private JPianoTrainFrame frame;
}
/*
Copyright (C) 2008 Alexander Methke
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (gplv3.txt).
*/