package controller;

import javafx.beans.binding.Bindings;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.ObjectProperty;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.ListView;
import javafx.scene.control.TextArea;
import javafx.scene.layout.AnchorPane;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import model.FileModel;

import java.io.File;
import java.util.ArrayList;

/**
 * Created by SH on 2016-05-11.
 */
public class EditorSceneController {

    @FXML private TextArea textArea;
    @FXML private Button btnFileOpen;

    @FXML
    private void initialize(){

        // ListView와 TextArea의 스크롤을 동기화시킨다.
        DoubleProperty textAreaScrollTo = textArea.scrollTopProperty();

    }

    @FXML // 불러오기 버튼을 클릭했을 때의 동작
    private void onTBBtnLoadClicked(ActionEvent event) {
        Stage s = (Stage)btnFileOpen.getScene().getWindow();

        FileChooser fileChooser = new FileChooser();
        fileChooser.setTitle("Open Resource File");
        fileChooser.getExtensionFilters().addAll(
                new FileChooser.ExtensionFilter("Text Files", "*.txt"),
                new FileChooser.ExtensionFilter("Image Files", "*.png", "*.jpg", "*.gif"),
                new FileChooser.ExtensionFilter("Audio Files", "*.wav", "*.mp3", "*.aac"),
                new FileChooser.ExtensionFilter("All Files", "*.*"));

        File selectedFile = fileChooser.showOpenDialog(s);
        FileModel.getModel().readFileL(selectedFile.getPath());
        ArrayList<String> strings = FileModel.getModel().getStringL();
        for(String temp : strings) {
            textArea.appendText(temp);
        }
    }

}

@@ -892,24 +892,52 @@
 nt event) %7B%0A
+        //File chooser code%0A
         Stag
@@ -1525,16 +1525,52 @@
 log(s);%0A
+%0A        //Show text in Edit panel%0A%0A
         
@@ -1625,16 +1625,17 @@
 ath());%0A
+%0A
         
@@ -1693,24 +1693,25 @@
 tStringL();%0A
+%0A
         for(
@@ -1736,22 +1736,8 @@
 ngs)
- %7B%0A           
  tex
@@ -1764,18 +1764,8 @@
 p);%0A
-        %7D%0A
     

Load Function finished