/*
 * Copyright (C) 2018 European Spallation Source ERIC
 *
 * 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 2
 * 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; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package xal.app.trajectorycorrection;

import javafx.application.Application;
import static javafx.application.Application.launch;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MainApp extends Application {

    @Override
    public void start(Stage stage) throws Exception {

        Parent root = FXMLLoader.load(getClass().getResource("/fxml/MainPanel.fxml"));

        Scene scene = new Scene(root);
        scene.getStylesheets().add("/styles/Styles.css");

        stage.setOnCloseRequest(e -> System.exit(0));

        stage.getProperties().put("hostServices", this.getHostServices());

        stage.setTitle("Trajectory Correction");
        stage.setScene(scene);
        stage.show();
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }

}

@@ -822,38 +822,27 @@
 ort java
-fx.application.Applica
+.io.IOExcep
 tion;%0Aim
@@ -910,105 +910,74 @@
 afx.
-fxml.FXMLLoader;%0Aimport javafx.scene.Parent
+stage.Stage
 ;%0A
+%0A
 import 
-javafx.scene.Scene;%0Aimport javafx.stage.Stage
+openxal.extension.fxapplication.FxApplication
 ;%0A%0Ap
@@ -1004,16 +1004,18 @@
 extends 
+Fx
 Applicat
@@ -1077,16 +1077,18 @@
  throws 
+IO
 Exceptio
@@ -1104,61 +1104,21 @@
     
-Parent root = FXMLLoader.load(getClass().getResource(
+MAIN_SCENE = 
 %22/fx
@@ -1135,29 +1135,26 @@
 el.fxml%22
-))
 ;%0A
-%0A
         
 Scene sc
@@ -1149,74 +1149,20 @@
     
-Scene scene = new Scene(root);%0A        scene.getStylesheets().add(
+CSS_STYLE = 
 %22/st
@@ -1177,19 +1177,17 @@
 les.css%22
-);%0A
+;
 %0A       
@@ -1191,154 +1191,22 @@
     
-stage.setOnCloseRequest(e -%3E System.exit(0));%0A%0A        stage.getProperties().put(%22hostServices%22, this.getHostServices());%0A%0A        stage.setTitle(
+STAGE_TITLE = 
 %22Tra
@@ -1224,18 +1224,18 @@
 rection%22
-)
 ;
+%0A
 %0A       
@@ -1240,49 +1240,52 @@
    s
-tage.setScene(scene);%0A        stage.show(
+uper.initialize();%0A        super.start(stage
 );%0A 

extend fxapplication class