use of de.unijena.cheminf.mortar.controller.MainViewController in project MORTAR by FelixBaensch.
the class MainApp method start.
//
@Override
public void start(Stage aPrimaryStage) {
try {
// <editor-fold defaultstate="collapsed" desc="setting default locale">
Locale.setDefault(new Locale("en", "GB"));
Logger.getLogger(Main.class.getName()).info(Locale.getDefault().toString());
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Check Java version">
String tmpJavaVersion = System.getProperty("java.version");
if (MiscUtil.compareVersions(tmpJavaVersion, BasicDefinitions.MINIMUM_JAVA_VERSION) < 0) {
GuiUtil.guiMessageAlert(Alert.AlertType.ERROR, Message.get("Error.InvalidJavaVersion.Title"), null, String.format(Message.get("Error.InvalidJavaVersion.Context"), BasicDefinitions.MINIMUM_JAVA_VERSION));
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, "Java version lower than minimum: " + tmpJavaVersion);
System.exit(-1);
}
// </editor-fold>
// <editor-fold desc="Check single instance" defaultstate="collapsed">
boolean tmpLCKFilePresent = LogUtil.checkForLCKFileInLogDir();
if (tmpLCKFilePresent) {
if (GuiUtil.guiConformationAlert(Message.get("Error.SecondInstance.Title"), Message.get("Error.SecondInstance.Header"), Message.get("Error.SecondInstance.Content")) == ButtonType.CANCEL) {
System.exit(0);
}
// else: user wants to continue despite the possible second instance;
// this means that all existing .lck files will be removed below with LogUtil.manageLogFilesFolderIfExists()
}
// else: single MORTAR instance running
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Configure logging environment and log session start">
LogUtil.manageLogFilesFolderIfExists();
boolean tmpWasLoggingInitializationSuccessful = LogUtil.initializeLoggingEnvironment();
if (!tmpWasLoggingInitializationSuccessful) {
GuiUtil.guiMessageAlert(Alert.AlertType.INFORMATION, Message.get("Error.LoggingInitialization.Title"), null, Message.get("Error.LoggingInitialization"));
}
// Start new logging session
Logger.getLogger(Main.class.getName()).info(String.format(BasicDefinitions.MORTAR_SESSION_START_FORMAT, BasicDefinitions.MORTAR_VERSION));
// </editor-fold>
// <editor-fold desc="determining the application's directory and the default temp file path" defaultstate="collapsed">
String tmpAppDir = FileUtil.getAppDirPath();
// </editor-fold>
MainView tmpMainView = new MainView();
MainViewController tmpMainViewController = new MainViewController(aPrimaryStage, tmpMainView, tmpAppDir);
} catch (Exception | OutOfMemoryError anException) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, anException.toString(), anException);
if (anException instanceof OutOfMemoryError) {
GuiUtil.guiExceptionAlert(Message.get("Error.ExceptionAlert.Title"), Message.get("Error.ExceptionAlert.Header"), anException.getMessage(), new Exception(((OutOfMemoryError) anException).toString()));
} else {
GuiUtil.guiExceptionAlert(Message.get("Error.ExceptionAlert.Title"), Message.get("Error.ExceptionAlert.Header"), anException.getMessage(), (Exception) anException);
}
System.exit(-1);
}
}
Aggregations