package codeOrchestra.colt.core.ui;

import codeOrchestra.colt.core.COLTException;
import codeOrchestra.colt.core.COLTProjectManager;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.stage.Stage;

/**
 * @author Alexander Eliseyev
 */
public class COLTApplication extends Application {

    public static COLTApplication instance;

    private Group root;
    private Node currentPluginNode;

    @Override
    public void start(Stage primaryStage) throws Exception {
        instance = this;

        root = new Group();
        primaryStage.setTitle("COLT 1.1");
        primaryStage.setScene(new Scene(root, 800, 700));

        Menu menu = new Menu("File");
        MenuItem menuLoad = new MenuItem("Load");
        menuLoad.setOnAction(t -> {
            // TODO: file chooser
            try {
                COLTProjectManager.getInstance().load("/Users/eliseyev/TMP/OriginalProject/AwesomeProject.colt2");
            } catch (COLTException e) {
                throw new RuntimeException(e); // TODO: handle nicely
            }
        });

        MenuItem menuSave = new MenuItem("Save");
        menuSave.setOnAction(t -> {

        });

        menu.getItems().addAll(menuLoad, menuSave);

        MenuBar menuBar = new MenuBar();
        menuBar.getMenus().addAll(menu);
        menuBar.setUseSystemMenuBar(true);

        root.getChildren().add(menuBar);

        primaryStage.show();
    }

    public void setPluginPane(Node node) {
        if (currentPluginNode != null) {
            root.getChildren().remove(currentPluginNode);
        }

        currentPluginNode = node;
        root.getChildren().add(node);
    }

    public static void main(String[] args) {
        launch(args);
    }

}

@@ -375,20 +375,75 @@
 x.stage.
-Stag
+FileChooser;%0Aimport javafx.stage.Stage;%0A%0Aimport java.io.Fil
 e;%0A%0A/**%0A
@@ -1005,30 +1005,281 @@
     
-// TODO: file chooser%0A
+FileChooser fileChooser = new FileChooser();%0A            fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter(%22COLT%22, %22*.colt2%22));%0A            File file = fileChooser.showOpenDialog(primaryStage.getScene().getWindow());%0A            if (file != null) %7B%0A    
     
@@ -1308,16 +1308,20 @@
         
+    
 COLTProj
@@ -1354,69 +1354,29 @@
 oad(
-%22/Users/eliseyev/TMP/OriginalProject/AwesomeProject.colt2%22);%0A
+file.getPath());%0A    
     
@@ -1427,16 +1427,20 @@
         
+    
 throw ne
@@ -1485,16 +1485,34 @@
  nicely%0A
+                %7D%0A
         

add FileChooser