/*
 * 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.trajectorydisplay;

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/TrajectoryDisplay.fxml"));

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

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

        stage.setTitle("Trajectory Display");
        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);
    }

}

@@ -819,38 +819,27 @@
 ort java
-fx.application.Applica
+.io.IOExcep
 tion;%0Aim
@@ -907,21 +907,51 @@
 afx.
-fxml.FXMLLoad
+event.Event;%0Aimport javafx.event.EventHandl
 er;%0A
@@ -970,22 +970,28 @@
 x.scene.
-Parent
+control.Menu
 ;%0Aimport
@@ -1004,21 +1004,32 @@
 x.scene.
-Scene
+control.MenuItem
 ;%0Aimport
@@ -1050,16 +1050,71 @@
 Stage;%0A%0A
+import openxal.extension.fxapplication.FxApplication;%0A%0A
 public c
@@ -1134,16 +1134,18 @@
 extends 
+Fx
 Applicat
@@ -1207,16 +1207,18 @@
  throws 
+IO
 Exceptio
@@ -1221,24 +1221,25 @@
 ption %7B%0A
+%0A
         
 Parent r
@@ -1234,61 +1234,21 @@
     
-Parent root = FXMLLoader.load(getClass().getResource(
+MAIN_SCENE = 
 %22/fx
@@ -1273,20 +1273,17 @@
 ay.fxml%22
-));%0A
+;
 %0A       
@@ -1287,106 +1287,200 @@
     
-Scene scene = new Scene(root);%0A        scene.getStylesheets().add(%22/styles/Styles.css
+CSS_STYLE = %22/styles/Styles.css%22;%0A        STAGE_TITLE = %22Trajectory Display%22;%0A        HAS_DOCUMENTS=false;%0A%0A        super.initialize();%0A        Menu trajectoryMenu = new Menu(%22File
 %22);%0A
-%0A
         
 stag
@@ -1479,84 +1479,61 @@
     
-stage.getProperties().put(%22hostServices%22, this.getHostServices()
+MenuItem tMenu = new MenuItem(%22Trajectory%22
 );%0A
-%0A
         
 stag
@@ -1532,24 +1532,30 @@
     
-stage.setTitle(%22
+tMenu.setOnAction(new 
 Traj
@@ -1560,25 +1560,22 @@
 ajectory
- Display%22
+Menu()
 );%0A     
@@ -1581,28 +1581,92 @@
     
-stage.setScene(scene
+trajectoryMenu.getItems().add(tMenu);%0A        MENU_BAR.getMenus().add(trajectoryMenu
 );%0A 
@@ -1677,18 +1677,24 @@
    s
-tage.show(
+uper.start(stage
 );%0A 
@@ -2112,8 +2112,249 @@
    %7D%0A%0A%7D%0A
+%0Aclass TrajectoryMenu implements EventHandler %7B%0A%0A    @Override%0A    public void handle(Event t) %7B%0A        throw new UnsupportedOperationException(%22Not supported yet.%22); //To change body of generated methods, choose Tools %7C Templates.%0A    %7D%0A%0A%7D

extend fxapplication class